#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*/ e_debug_init(int);
int /*<<< orphan*/ e_debug_read(unsigned int, unsigned int *);
int /*<<< orphan*/ e_debug_write(unsigned int, unsigned int);
int /*<<< orphan*/ printf(char *, unsigned int, ...);
int main(int argc, char *argv[]) {
  unsigned int i;
  unsigned int dstaddr;
  unsigned int data, rdata;
  e_debug_init(0x1);
  dstaddr = 0x80800000;
  for (i = 0; i < 1000000000; i++) {
    data = i;
    if (!(i % 100000)) {
      printf("LOOP(%d)\n", i);
    }
    e_debug_write(dstaddr, data);
    e_debug_read(dstaddr, &rdata);
    if (rdata != data) {
      printf("LOOP %d: ERROR %08x != %08x\n", i, data, rdata);
      break;
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x1,%edi
call   1060 <e_debug_init@plt>
movl   $0x80800000,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x3b9aca00,-0x14(%rbp)
jae    11f9 <main+0xb9>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x186a0,%ecx
xor    %edx,%edx
div    %ecx
cmp    $0x0,%edx
jne    11a7 <main+0x67>
mov    -0x14(%rbp),%esi
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1030 <e_debug_write@plt>
mov    -0x18(%rbp),%edi
lea    -0x20(%rbp),%rsi
call   1050 <e_debug_read@plt>
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
je     11e6 <main+0xa6>
mov    -0x14(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11f9 <main+0xb9>
jmp    11eb <main+0xab>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116e <main+0x2e>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    $0x1,%edi
call   1060 <e_debug_init@plt>
lea    0xea6(%rip),%r14
lea    0xc(%rsp),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebx,%eax
shr    $0x5,%eax
imul   $0xa7c5ac5,%rax,%rax
shr    $0x27,%rax
imul   $0x186a0,%eax,%eax
cmp    %ebx,%eax
jne    1196 <main+0x56>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x80800000,%edi
mov    %ebx,%esi
call   1030 <e_debug_write@plt>
mov    $0x80800000,%edi
mov    %r15,%rsi
call   1050 <e_debug_read@plt>
mov    0xc(%rsp),%ecx
cmp    %ecx,%ebx
jne    11c4 <main+0x84>
add    $0x1,%ebx
cmp    $0x3b9aca00,%ebx
jne    1170 <main+0x30>
jmp    11d6 <main+0x96>
lea    0xe3f(%rip),%rdi
mov    %ebx,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [10 x i8] c"LOOP(%d)\0A\00"
@.str.1 = [29 x i8] c"LOOP %d: ERROR %08x != %08x\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32 @e_debug_init(i32 1)
store i32 -2139095040, i32* %7
store i32 0, i32* %6
br label %11
11: ; preds = %37, %2
%12 = load i32, i32* %6
%13 = icmp ult i32 %12, 1000000000
br i1 %13, label %14, label %40
14: ; preds = %11
%15 = load i32, i32* %6
store i32 %15, i32* %8
%16 = load i32, i32* %6
%17 = urem i32 %16, 100000
%18 = icmp ne i32 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %14
%20 = load i32, i32* %6
%21 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %20)
br label %22
22: ; preds = %19, %14
%23 = load i32, i32* %7
%24 = load i32, i32* %8
%25 = call i32 @e_debug_write(i32 %23, i32 %24)
%26 = load i32, i32* %7
%27 = call i32 @e_debug_read(i32 %26, i32* %9)
%28 = load i32, i32* %9
%29 = load i32, i32* %8
%30 = icmp ne i32 %28, %29
br i1 %30, label %31, label %36
31: ; preds = %22
%32 = load i32, i32* %6
%33 = load i32, i32* %8
%34 = load i32, i32* %9
%35 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %32, i32 %33, i32 %34)
br label %40
36: ; preds = %22
br label %37
37: ; preds = %36
%38 = load i32, i32* %6
%39 = add i32 %38, 1
store i32 %39, i32* %6
br label %11
40: ; preds = %31, %11
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
@.str = [10 x i8] c"LOOP(%d)\0A\00"
@.str.1 = [29 x i8] c"LOOP %d: ERROR %08x != %08x\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 @e_debug_init(i32 1)
br label %6
6: ; preds = %2, %19
%7 = phi i32 [ 0, %2 ], [ %20, %19 ]
%8 = urem i32 %7, 100000
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %7)
br label %12
12: ; preds = %10, %6
%13 = call i32 @e_debug_write(i32 -2139095040, i32 %7)
%14 = call i32 @e_debug_read(i32 -2139095040, i32* %3)
%15 = load i32, i32* %3
%16 = icmp eq i32 %15, %7
br i1 %16, label %19, label %17
17: ; preds = %12
%18 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %7, i32 %7, i32 %15)
br label %22
19: ; preds = %12
%20 = add nuw nsw i32 %7, 1
%21 = icmp eq i32 %20, 1000000000
br i1 %21, label %22, label %6
22: ; preds = %19, %17
ret i32 0
}