#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 */
scalar_t__ increment(int);
int /*<<< orphan*/ printf(char *, int, ...);
int /*<<< orphan*/ system(char *);
int main(void) {
  int counter = 6;
  int currentPrime = 13;
  while (counter < 10001) {
    currentPrime += increment(currentPrime);
    counter++;
    printf("%d\n", currentPrime);
  }
  printf("The current prime is %d with a counter of %d.\n", currentPrime,
         counter);
  system("PAUSE");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x6,-0x8(%rbp)
movl   $0xd,-0xc(%rbp)
cmpl   $0x2711,-0x8(%rbp)
jge    118e <main+0x5e>
mov    -0xc(%rbp),%edi
call   1030 <increment@plt>
mov    %rax,%rcx
movslq -0xc(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    114d <main+0x1d>
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe8a(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0xd,%ebx
mov    $0x270b,%ebp
lea    0xeb8(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    %ebx,%r15d
mov    %ebx,%edi
call   1030 <increment@plt>
mov    %rax,%rbx
add    %r15d,%ebx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0xffffffff,%ebp
jne    1150 <main+0x20>
lea    0xe8c(%rip),%rdi
mov    %ebx,%esi
mov    $0x2711,%edx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xea6(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [47 x i8] c"The current prime is %d with a counter of %d.\0A\00"
@.str.2 = [6 x i8] c"PAUSE\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 6, i32* %2
store i32 13, i32* %3
br label %4
4: ; preds = %7, %0
%5 = load i32, i32* %2
%6 = icmp slt i32 %5, 10001
br i1 %6, label %7, label %18
7: ; preds = %4
%8 = load i32, i32* %3
%9 = call i64 @increment(i32 %8)
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = add nsw i64 %11, %9
%13 = trunc i64 %12 to i32
store i32 %13, i32* %3
%14 = load i32, i32* %2
%15 = add nsw i32 %14, 1
store i32 %15, i32* %2
%16 = load i32, i32* %3
%17 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %16)
br label %4
18: ; preds = %4
%19 = load i32, i32* %3
%20 = load i32, i32* %2
%21 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32 %19, i32 %20)
%22 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [47 x i8] c"The current prime is %d with a counter of %d.\0A\00"
@.str.2 = [6 x i8] c"PAUSE\00"
define i32 @main() {
br label %1
1: ; preds = %0, %1
%2 = phi i32 [ 13, %0 ], [ %6, %1 ]
%3 = phi i32 [ 6, %0 ], [ %7, %1 ]
%4 = tail call i64 @increment(i32 %2)
%5 = trunc i64 %4 to i32
%6 = add i32 %2, %5
%7 = add nuw nsw i32 %3, 1
%8 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %6)
%9 = icmp eq i32 %7, 10001
br i1 %9, label %10, label %1
10: ; preds = %1
%11 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32 %6, i32 10001)
%12 = tail call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}