#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 */
typedef scalar_t__ uint32_t;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, scalar_t__, scalar_t__, scalar_t__);
scalar_t__ ref(scalar_t__);
scalar_t__ try1(scalar_t__);
int main() {
  uint32_t x = 0;
  do {
    uint32_t r1 = ref(x);
    uint32_t r2 = try1(x);
    if (r1 != r2) {
      printf("FAIL: %x -> %x %x\n", x, r1, r2);
      exit(1);
    }
    if (x == 0xffffffff)
      break;
    x++;
  } while (1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <ref@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <try1@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
je     11a1 <main+0x61>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xe6e(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    $0xffffffff,%eax
cmp    %rax,-0x10(%rbp)
jne    11b5 <main+0x75>
jmp    11d0 <main+0x90>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    $0x1,%al
test   $0x1,%al
jne    1157 <main+0x17>
jmp    11d0 <main+0x90>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
xor    %ebx,%ebx
movabs $0x100000000,%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <ref@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1050 <try1@plt>
cmp    %rax,%r14
jne    1189 <main+0x49>
add    $0x1,%rbx
cmp    %r15,%rbx
jne    1160 <main+0x20>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe70(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %rax,%rcx
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [19 x i8] c"FAIL: %x -> %x %x\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
store i32 0, i32* %1
store i64 0, i64* %2
br label %5
5: ; preds = %26, %0
%6 = load i64, i64* %2
%7 = call i64 @ref(i64 %6)
store i64 %7, i64* %3
%8 = load i64, i64* %2
%9 = call i64 @try1(i64 %8)
store i64 %9, i64* %4
%10 = load i64, i64* %3
%11 = load i64, i64* %4
%12 = icmp ne i64 %10, %11
br i1 %12, label %13, label %19
13: ; preds = %5
%14 = load i64, i64* %2
%15 = load i64, i64* %3
%16 = load i64, i64* %4
%17 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i64 %14, i64 %15, i64 %16)
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %5
%20 = load i64, i64* %2
%21 = icmp eq i64 %20, 4294967295
br i1 %21, label %22, label %23
22: ; preds = %19
br label %27
23: ; preds = %19
%24 = load i64, i64* %2
%25 = add nsw i64 %24, 1
store i64 %25, i64* %2
br label %26
26: ; preds = %23
br i1 true, label %5, label %27
27: ; preds = %26, %22
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"FAIL: %x -> %x %x\0A\00"
define i32 @main() {
br label %1
1: ; preds = %9, %0
%2 = phi i64 [ 0, %0 ], [ %11, %9 ]
%3 = tail call i64 @ref(i64 %2)
%4 = tail call i64 @try1(i64 %2)
%5 = icmp eq i64 %3, %4
br i1 %5, label %9, label %6
6: ; preds = %1
%7 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i64 %2, i64 %3, i64 %4)
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %1
%10 = icmp eq i64 %2, 4294967295
%11 = add nuw nsw i64 %2, 1
br i1 %10, label %12, label %1
12: ; preds = %9
ret i32 0
}