1#include <metal_stdlib>
2#include <simd/simd.h>
3using namespace metal;
4struct S {
5    int x;
6    int y;
7};
8struct Uniforms {
9    float4 colorGreen;
10    float4 colorRed;
11};
12struct Inputs {
13};
14struct Outputs {
15    float4 sk_FragColor [[color(0)]];
16};
17
18template <typename T, size_t N>
19bool operator==(thread const array<T, N>& left, thread const array<T, N>& right) {
20    for (size_t index = 0; index < N; ++index) {
21        if (!(left[index] == right[index])) {
22            return false;
23        }
24    }
25    return true;
26}
27
28template <typename T, size_t N>
29bool operator!=(thread const array<T, N>& left, thread const array<T, N>& right) {
30    return !(left == right);
31}
32thread bool operator==(thread const S& left, thread const S& right) {
33    return (left.x == right.x) &&
34           (left.y == right.y);
35}
36thread bool operator!=(thread const S& left, thread const S& right) {
37    return !(left == right);
38}
39
40fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
41    Outputs _out;
42    (void)_out;
43    array<float, 4> f1 = array<float, 4>{1.0, 2.0, 3.0, 4.0};
44    array<float, 4> f2 = array<float, 4>{1.0, 2.0, 3.0, 4.0};
45    array<float, 4> f3 = array<float, 4>{1.0, 2.0, 3.0, -4.0};
46    array<S, 3> s1 = array<S, 3>{S{1, 2}, S{3, 4}, S{5, 6}};
47    array<S, 3> s2 = array<S, 3>{S{1, 2}, S{0, 0}, S{5, 6}};
48    array<S, 3> s3 = array<S, 3>{S{1, 2}, S{3, 4}, S{5, 6}};
49    _out.sk_FragColor = ((f1 == f2 && f1 != f3) && s1 != s2) && s3 == s1 ? _uniforms.colorGreen : _uniforms.colorRed;
50    return _out;
51}
52