#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 get_add1(int, int *);
int get_inc(int, int *);
int /*<<< orphan*/ printf(char *, int, int, int, int, int);
int /*<<< orphan*/ puts(char *);
int main() {
  int a = 0;
  int f1, f2, r1, r2;
  do {
    f1 = get_add1(a, &r1) & 0x8c5;
    f2 = get_inc(a, &r2) & 0x8c5;
    if ((a & 0xffffff) == 0)
      printf("a=%x f1=%x r1=%x f2=%x r2=%x\n", a, f1, r1, f2, r2);
    if (f1 != f2 || r1 != r2) {
      printf("a=%x f1=%x r1=%x f2=%x r2=%x\n", a, f1, r1, f2, r2);
      puts("ERROR");
    }
    a++;
  } while (a != 0);
  puts("TEST FINISHED");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x14(%rbp),%rsi
call   1060 <get_add1@plt>
and    $0x8c5,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x18(%rbp),%rsi
call   1030 <get_inc@plt>
and    $0x8c5,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
and    $0xffffff,%eax
cmp    $0x0,%eax
jne    11ac <main+0x6c>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%r8d
mov    -0x18(%rbp),%r9d
lea    0xe59(%rip),%rdi
call   1050 <printf@plt>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jne    11c4 <main+0x84>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
je     11ed <main+0xad>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%r8d
mov    -0x18(%rbp),%r9d
lea    0xe24(%rip),%rdi
call   1050 <printf@plt>
lea    0xe36(%rip),%rdi
call   1040 <puts@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1156 <main+0x16>
lea    0xe1d(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %ebx,%ebx
lea    0x4(%rsp),%r14
mov    %rsp,%r15
lea    0xea4(%rip),%r12
jmp    117e <main+0x3e>
xchg   %ax,%ax
mov    %r12,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %r13d,%r8d
call   1050 <printf@plt>
lea    0xea8(%rip),%rdi
call   1040 <puts@plt>
add    $0x1,%ebx
mov    %ebx,%edi
mov    %r14,%rsi
call   1060 <get_add1@plt>
mov    %eax,%ebp
and    $0x8c5,%ebp
mov    %ebx,%edi
mov    %r15,%rsi
call   1030 <get_inc@plt>
mov    %eax,%r13d
and    $0x8c5,%r13d
test   $0xffffff,%ebx
jne    11c3 <main+0x83>
mov    0x4(%rsp),%ecx
mov    (%rsp),%r9d
mov    %r12,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %r13d,%r8d
call   1050 <printf@plt>
mov    0x4(%rsp),%ecx
mov    (%rsp),%r9d
cmp    %r13d,%ebp
jne    1160 <main+0x20>
cmp    %r9d,%ecx
je     117b <main+0x3b>
jmp    1160 <main+0x20>

LLVM IR (-O0):
@.str = [30 x i8] c"a=%x f1=%x r1=%x f2=%x r2=%x\0A\00"
@.str.1 = [6 x i8] c"ERROR\00"
@.str.2 = [14 x i8] c"TEST FINISHED\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
br label %7
7: ; preds = %43, %0
%8 = load i32, i32* %2
%9 = call i32 @get_add1(i32 %8, i32* %5)
%10 = and i32 %9, 2245
store i32 %10, i32* %3
%11 = load i32, i32* %2
%12 = call i32 @get_inc(i32 %11, i32* %6)
%13 = and i32 %12, 2245
store i32 %13, i32* %4
%14 = load i32, i32* %2
%15 = and i32 %14, 16777215
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %24
17: ; preds = %7
%18 = load i32, i32* %2
%19 = load i32, i32* %3
%20 = load i32, i32* %5
%21 = load i32, i32* %4
%22 = load i32, i32* %6
%23 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %18, i32 %19, i32 %20, i32 %21, i32 %22)
br label %24
24: ; preds = %17, %7
%25 = load i32, i32* %3
%26 = load i32, i32* %4
%27 = icmp ne i32 %25, %26
br i1 %27, label %32, label %28
28: ; preds = %24
%29 = load i32, i32* %5
%30 = load i32, i32* %6
%31 = icmp ne i32 %29, %30
br i1 %31, label %32, label %40
32: ; preds = %28, %24
%33 = load i32, i32* %2
%34 = load i32, i32* %3
%35 = load i32, i32* %5
%36 = load i32, i32* %4
%37 = load i32, i32* %6
%38 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %33, i32 %34, i32 %35, i32 %36, i32 %37)
%39 = call i32 @puts(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %40
40: ; preds = %32, %28
%41 = load i32, i32* %2
%42 = add nsw i32 %41, 1
store i32 %42, i32* %2
br label %43
43: ; preds = %40
%44 = load i32, i32* %2
%45 = icmp ne i32 %44, 0
br i1 %45, label %7, label %46
46: ; preds = %43
%47 = call i32 @puts(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [30 x i8] c"a=%x f1=%x r1=%x f2=%x r2=%x\0A\00"
@.str.1 = [6 x i8] c"ERROR\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
br label %5
5: ; preds = %26, %0
%6 = phi i32 [ 0, %0 ], [ %27, %26 ]
%7 = call i32 @get_add1(i32 %6, i32* %1)
%8 = and i32 %7, 2245
%9 = call i32 @get_inc(i32 %6, i32* %2)
%10 = and i32 %9, 2245
%11 = and i32 %6, 16777215
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %5
%14 = load i32, i32* %1
%15 = load i32, i32* %2
%16 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %8, i32 %14, i32 %10, i32 %15)
br label %17
17: ; preds = %13, %5
%18 = icmp eq i32 %8, %10
%19 = load i32, i32* %1
%20 = load i32, i32* %2
%21 = icmp eq i32 %19, %20
%22 = select i1 %18, i1 %21, i1 false
br i1 %22, label %26, label %23
23: ; preds = %17
%24 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %8, i32 %19, i32 %10, i32 %20)
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %26
26: ; preds = %17, %23
%27 = add nuw nsw i32 %6, 1
br label %5
}