#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*/ assert(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdout;
int main(int argc, char **argv) {
  int i;
  printf("This is a test.");
  for (i = 1; i < 10000; i++) {
    printf("counting %d...\n", i);
    fflush(stdout);
    assert(i % 999);
  }
  return 0;
}


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)
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x14(%rbp)
cmpl   $0x2710,-0x14(%rbp)
jge    11a7 <main+0x77>
mov    -0x14(%rbp),%esi
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e60(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    -0x14(%rbp),%eax
mov    $0x3e7,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
call   1040 <assert@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115b <main+0x2b>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xec2(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%ebx
lea    0xebf(%rip),%r14
mov    0x2e88(%rip),%r15
nopl   0x0(%rax,%rax,1)
mov    %ebx,%eax
imul   $0x6680a41,%rax,%rax
shr    $0x20,%rax
mov    %ebx,%ecx
sub    %eax,%ecx
shr    %ecx
add    %eax,%ecx
shr    $0x9,%ecx
imul   $0xfffffc19,%ecx,%ebp
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    (%r15),%edi
call   1050 <fflush@plt>
add    %ebx,%ebp
mov    %ebp,%edi
call   1040 <assert@plt>
add    $0x1,%ebx
cmp    $0x2710,%ebx
jne    1160 <main+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"This is a test.\00"
@.str.1 = [16 x i8] c"counting %d...\0A\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %6
br label %8
8: ; preds = %19, %2
%9 = load i32, i32* %6
%10 = icmp slt i32 %9, 10000
br i1 %10, label %11, label %22
11: ; preds = %8
%12 = load i32, i32* %6
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = load i32, i32* @stdout
%15 = call i32 @fflush(i32 %14)
%16 = load i32, i32* %6
%17 = srem i32 %16, 999
%18 = call i32 @assert(i32 %17)
br label %19
19: ; preds = %11
%20 = load i32, i32* %6
%21 = add nsw i32 %20, 1
store i32 %21, i32* %6
br label %8
22: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
@.str = [16 x i8] c"This is a test.\00"
@.str.1 = [16 x i8] c"counting %d...\0A\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %2, %4
%5 = phi i32 [ 1, %2 ], [ %13, %4 ]
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%7 = load i32, i32* @stdout
%8 = tail call i32 @fflush(i32 %7)
%9 = trunc i32 %5 to i16
%10 = urem i16 %9, 999
%11 = zext i16 %10 to i32
%12 = tail call i32 @assert(i32 %11)
%13 = add nuw nsw i32 %5, 1
%14 = icmp eq i32 %13, 10000
br i1 %14, label %15, label %4
15: ; preds = %4
ret i32 0
}