#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int test(int, int);
int test2(int, int);
int test3(int, int);
int test4(int, int);
int main(int index) {
  int x, y;
  printf("testing...\n");
  int totalBad = 0;
  for (y = 0; y < 2; y++) {
    for (x = 0; x < 2; x++) {
      int a = test(x, y);
      int b = test2(x, y);
      if (a != b) {
        printf("Results differ: OR x=%d y=%d a=%d b=%d\n", x, y, a, b);
        totalBad++;
      }
      a = test3(x, y);
      b = test4(x, y);
      if (a != b) {
        printf("Results differ: AND x=%d y=%d a=%d b=%d\n", x, y, a, b);
        totalBad++;
      }
    }
  }
  printf("Total bad: %d\n", totalBad);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x2,-0x10(%rbp)
jge    1257 <main+0x107>
movl   $0x0,-0xc(%rbp)
cmpl   $0x2,-0xc(%rbp)
jge    1244 <main+0xf4>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1070 <test@plt>
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1060 <test2@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
je     11e5 <main+0x95>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1030 <test3@plt>
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1050 <test4@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
je     1231 <main+0xe1>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
lea    0xe13(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1236 <main+0xe6>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    118f <main+0x3f>
jmp    1249 <main+0xf9>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    117e <main+0x2e>
mov    -0x14(%rbp),%esi
lea    0xdfc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xef6(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
xor    %edi,%edi
xor    %esi,%esi
call   1080 <test@plt>
mov    %eax,%ebp
xor    %edi,%edi
xor    %esi,%esi
call   1070 <test2@plt>
cmp    %eax,%ebp
je     11a5 <main+0x45>
lea    0xe70(%rip),%rdi
xor    %esi,%esi
xor    %edx,%edx
mov    %ebp,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%ebx
xor    %edi,%edi
xor    %esi,%esi
call   1040 <test3@plt>
mov    %eax,%ebp
xor    %edi,%edi
xor    %esi,%esi
call   1060 <test4@plt>
cmp    %eax,%ebp
je     11d7 <main+0x77>
lea    0xe64(%rip),%rdi
xor    %esi,%esi
xor    %edx,%edx
mov    %ebp,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebx
mov    $0x1,%edi
xor    %esi,%esi
call   1080 <test@plt>
mov    %eax,%ebp
mov    $0x1,%edi
xor    %esi,%esi
call   1070 <test2@plt>
cmp    %eax,%ebp
je     1212 <main+0xb2>
lea    0xe04(%rip),%rdi
mov    $0x1,%esi
xor    %edx,%edx
mov    %ebp,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebx
mov    $0x1,%edi
xor    %esi,%esi
call   1040 <test3@plt>
mov    %eax,%ebp
mov    $0x1,%edi
xor    %esi,%esi
call   1060 <test4@plt>
cmp    %eax,%ebp
je     124d <main+0xed>
lea    0xdf1(%rip),%rdi
mov    $0x1,%esi
xor    %edx,%edx
mov    %ebp,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebx
xor    %edi,%edi
mov    $0x1,%esi
call   1080 <test@plt>
mov    %eax,%ebp
xor    %edi,%edi
mov    $0x1,%esi
call   1070 <test2@plt>
cmp    %eax,%ebp
je     1288 <main+0x128>
lea    0xd8e(%rip),%rdi
xor    %esi,%esi
mov    $0x1,%edx
mov    %ebp,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebx
xor    %edi,%edi
mov    $0x1,%esi
call   1040 <test3@plt>
mov    %eax,%ebp
xor    %edi,%edi
mov    $0x1,%esi
call   1060 <test4@plt>
cmp    %eax,%ebp
je     12c3 <main+0x163>
lea    0xd7b(%rip),%rdi
xor    %esi,%esi
mov    $0x1,%edx
mov    %ebp,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebx
mov    $0x1,%edi
mov    $0x1,%esi
call   1080 <test@plt>
mov    %eax,%ebp
mov    $0x1,%edi
mov    $0x1,%esi
call   1070 <test2@plt>
cmp    %eax,%ebp
je     1307 <main+0x1a7>
lea    0xd12(%rip),%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %ebp,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebx
mov    $0x1,%edi
mov    $0x1,%esi
call   1040 <test3@plt>
mov    %eax,%ebp
mov    $0x1,%edi
mov    $0x1,%esi
call   1060 <test4@plt>
cmp    %eax,%ebp
je     134b <main+0x1eb>
lea    0xcf6(%rip),%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %ebp,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebx
lea    0xcff(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"testing...\0A\00"
@.str.1 = [40 x i8] c"Results differ: OR x=%d y=%d a=%d b=%d\0A\00"
@.str.2 = [41 x i8] c"Results differ: AND x=%d y=%d a=%d b=%d\0A\00"
@.str.3 = [15 x i8] c"Total bad: %d\0A\00"
define i32 @main(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %2
store i32 %0, i32* %3
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %6
store i32 0, i32* %5
br label %10
10: ; preds = %58, %1
%11 = load i32, i32* %5
%12 = icmp slt i32 %11, 2
br i1 %12, label %13, label %61
13: ; preds = %10
store i32 0, i32* %4
br label %14
14: ; preds = %54, %13
%15 = load i32, i32* %4
%16 = icmp slt i32 %15, 2
br i1 %16, label %17, label %57
17: ; preds = %14
%18 = load i32, i32* %4
%19 = load i32, i32* %5
%20 = call i32 @test(i32 %18, i32 %19)
store i32 %20, i32* %7
%21 = load i32, i32* %4
%22 = load i32, i32* %5
%23 = call i32 @test2(i32 %21, i32 %22)
store i32 %23, i32* %8
%24 = load i32, i32* %7
%25 = load i32, i32* %8
%26 = icmp ne i32 %24, %25
br i1 %26, label %27, label %35
27: ; preds = %17
%28 = load i32, i32* %4
%29 = load i32, i32* %5
%30 = load i32, i32* %7
%31 = load i32, i32* %8
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i32 %28, i32 %29, i32 %30, i32 %31)
%33 = load i32, i32* %6
%34 = add nsw i32 %33, 1
store i32 %34, i32* %6
br label %35
35: ; preds = %27, %17
%36 = load i32, i32* %4
%37 = load i32, i32* %5
%38 = call i32 @test3(i32 %36, i32 %37)
store i32 %38, i32* %7
%39 = load i32, i32* %4
%40 = load i32, i32* %5
%41 = call i32 @test4(i32 %39, i32 %40)
store i32 %41, i32* %8
%42 = load i32, i32* %7
%43 = load i32, i32* %8
%44 = icmp ne i32 %42, %43
br i1 %44, label %45, label %53
45: ; preds = %35
%46 = load i32, i32* %4
%47 = load i32, i32* %5
%48 = load i32, i32* %7
%49 = load i32, i32* %8
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i32 %46, i32 %47, i32 %48, i32 %49)
%51 = load i32, i32* %6
%52 = add nsw i32 %51, 1
store i32 %52, i32* %6
br label %53
53: ; preds = %45, %35
br label %54
54: ; preds = %53
%55 = load i32, i32* %4
%56 = add nsw i32 %55, 1
store i32 %56, i32* %4
br label %14
57: ; preds = %14
br label %58
58: ; preds = %57
%59 = load i32, i32* %5
%60 = add nsw i32 %59, 1
store i32 %60, i32* %5
br label %10
61: ; preds = %10
%62 = load i32, i32* %6
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %62)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [40 x i8] c"Results differ: OR x=%d y=%d a=%d b=%d\0A\00"
@.str.2 = [41 x i8] c"Results differ: AND x=%d y=%d a=%d b=%d\0A\00"
@.str.3 = [15 x i8] c"Total bad: %d\0A\00"
@str = [11 x i8] c"testing...\00"
define i32 @main(i32 %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 @test(i32 0, i32 0)
%4 = tail call i32 @test2(i32 0, i32 0)
%5 = icmp eq i32 %3, %4
br i1 %5, label %8, label %6
6: ; preds = %1
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 0, i32 %3, i32 %4)
br label %8
8: ; preds = %6, %1
%9 = phi i32 [ 1, %6 ], [ 0, %1 ]
%10 = tail call i32 @test3(i32 0, i32 0)
%11 = tail call i32 @test4(i32 0, i32 0)
%12 = icmp eq i32 %10, %11
br i1 %12, label %16, label %13
13: ; preds = %8
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i32 0, i32 0, i32 %10, i32 %11)
%15 = add nuw nsw i32 %9, 1
br label %16
16: ; preds = %13, %8
%17 = phi i32 [ %15, %13 ], [ %9, %8 ]
%18 = tail call i32 @test(i32 1, i32 0)
%19 = tail call i32 @test2(i32 1, i32 0)
%20 = icmp eq i32 %18, %19
br i1 %20, label %24, label %21
21: ; preds = %16
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 0, i32 %18, i32 %19)
%23 = add nuw nsw i32 %17, 1
br label %24
24: ; preds = %21, %16
%25 = phi i32 [ %23, %21 ], [ %17, %16 ]
%26 = tail call i32 @test3(i32 1, i32 0)
%27 = tail call i32 @test4(i32 1, i32 0)
%28 = icmp eq i32 %26, %27
br i1 %28, label %32, label %29
29: ; preds = %24
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i32 1, i32 0, i32 %26, i32 %27)
%31 = add nuw nsw i32 %25, 1
br label %32
32: ; preds = %29, %24
%33 = phi i32 [ %31, %29 ], [ %25, %24 ]
%34 = tail call i32 @test(i32 0, i32 1)
%35 = tail call i32 @test2(i32 0, i32 1)
%36 = icmp eq i32 %34, %35
br i1 %36, label %40, label %37
37: ; preds = %32
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 1, i32 %34, i32 %35)
%39 = add nuw nsw i32 %33, 1
br label %40
40: ; preds = %37, %32
%41 = phi i32 [ %39, %37 ], [ %33, %32 ]
%42 = tail call i32 @test3(i32 0, i32 1)
%43 = tail call i32 @test4(i32 0, i32 1)
%44 = icmp eq i32 %42, %43
br i1 %44, label %48, label %45
45: ; preds = %40
%46 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i32 0, i32 1, i32 %42, i32 %43)
%47 = add nuw nsw i32 %41, 1
br label %48
48: ; preds = %45, %40
%49 = phi i32 [ %47, %45 ], [ %41, %40 ]
%50 = tail call i32 @test(i32 1, i32 1)
%51 = tail call i32 @test2(i32 1, i32 1)
%52 = icmp eq i32 %50, %51
br i1 %52, label %56, label %53
53: ; preds = %48
%54 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 1, i32 %50, i32 %51)
%55 = add nuw nsw i32 %49, 1
br label %56
56: ; preds = %53, %48
%57 = phi i32 [ %55, %53 ], [ %49, %48 ]
%58 = tail call i32 @test3(i32 1, i32 1)
%59 = tail call i32 @test4(i32 1, i32 1)
%60 = icmp eq i32 %58, %59
br i1 %60, label %64, label %61
61: ; preds = %56
%62 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i32 1, i32 1, i32 %58, i32 %59)
%63 = add nuw nsw i32 %57, 1
br label %64
64: ; preds = %61, %56
%65 = phi i32 [ %63, %61 ], [ %57, %56 ]
%66 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %65)
ret i32 0
}