#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*/ printf(char *, int);
int primetester(int i) {
  int j, prime, c;
  prime = 1;
  for (j = 2; j < i && prime == 1; ++j) {
    if (i % j == 0) {
      prime = 0;
    }
  }
  if (prime == 1) {
    printf("%d\t", i);
    ++c;
  }
}


x86 assembly (clang, -O0):
<primetester>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
movl   $0x1,-0x10(%rbp)
movl   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%ecx
xor    %eax,%eax
cmp    -0x8(%rbp),%ecx
mov    %al,-0x15(%rbp)
jge    1144 <primetester+0x34>
cmpl   $0x1,-0x10(%rbp)
sete   %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    1154 <primetester+0x44>
jmp    117e <primetester+0x6e>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    116b <primetester+0x5b>
movl   $0x0,-0x10(%rbp)
jmp    1170 <primetester+0x60>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1129 <primetester+0x19>
cmpl   $0x1,-0x10(%rbp)
jne    11a0 <primetester+0x90>
mov    -0x8(%rbp),%esi
lea    0xe6e(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<primetester>:
mov    %edi,%esi
cmp    $0x3,%edi
jl     1137 <primetester+0x27>
mov    $0x3,%ecx
nopl   0x0(%rax)
lea    -0x1(%rcx),%edi
mov    %esi,%eax
cltd
idiv   %edi
cmp    %esi,%ecx
jge    1133 <primetester+0x23>
add    $0x1,%ecx
test   %edx,%edx
jne    1120 <primetester+0x10>
test   %edx,%edx
je     1148 <primetester+0x38>
push   %rax
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
add    $0x8,%rsp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\09\00"
define i32 @primetester(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i32 1, i32* %5
store i32 2, i32* %4
br label %7
7: ; preds = %23, %1
%8 = load i32, i32* %4
%9 = load i32, i32* %3
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %14
11: ; preds = %7
%12 = load i32, i32* %5
%13 = icmp eq i32 %12, 1
br label %14
14: ; preds = %11, %7
%15 = phi i1 [ false, %7 ], [ %13, %11 ]
br i1 %15, label %16, label %26
16: ; preds = %14
%17 = load i32, i32* %3
%18 = load i32, i32* %4
%19 = srem i32 %17, %18
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %16
store i32 0, i32* %5
br label %22
22: ; preds = %21, %16
br label %23
23: ; preds = %22
%24 = load i32, i32* %4
%25 = add nsw i32 %24, 1
store i32 %25, i32* %4
br label %7
26: ; preds = %14
%27 = load i32, i32* %5
%28 = icmp eq i32 %27, 1
br i1 %28, label %29, label %34
29: ; preds = %26
%30 = load i32, i32* %3
%31 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %30)
%32 = load i32, i32* %6
%33 = add nsw i32 %32, 1
store i32 %33, i32* %6
br label %34
34: ; preds = %29, %26
%35 = load i32, i32* %2
ret i32 %35
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\09\00"
define i32 @primetester(i32 %0) {
%2 = icmp sgt i32 %0, 2
br i1 %2, label %3, label %11
3: ; preds = %1, %3
%4 = phi i32 [ %7, %3 ], [ 2, %1 ]
%5 = srem i32 %0, %4
%6 = icmp ne i32 %5, 0
%7 = add nuw nsw i32 %4, 1
%8 = icmp slt i32 %7, %0
%9 = and i1 %8, %6
br i1 %9, label %3, label %10
10: ; preds = %3
br i1 %6, label %11, label %13
11: ; preds = %1, %10
%12 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %13
13: ; preds = %11, %10
ret i32 undef
}