#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 main() {
  int i, j;
  for (i = 2; i < 100; i++) {
    for (j = 2; j <= (i / j); j++) {
      if (!(i % j))
        break;
    }
    if (j > (i / j))
      printf("%d is prime\n", i);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2,-0x8(%rbp)
cmpl   $0x64,-0x8(%rbp)
jge    11b5 <main+0xa5>
movl   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
cmp    %ecx,%eax
jg     1179 <main+0x69>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    1166 <main+0x56>
jmp    1179 <main+0x69>
jmp    116b <main+0x5b>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1137 <main+0x27>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
jle    11a2 <main+0x92>
mov    -0x8(%rbp),%esi
lea    0xe63(%rip),%rdi
call   1030 <printf@plt>
jmp    11a7 <main+0x97>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1126 <main+0x16>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x2,%ebx
lea    0xee0(%rip),%r14
jmp    1142 <main+0x32>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
add    $0x1,%ebx
cmp    $0x64,%ebx
je     116e <main+0x5e>
cmp    $0x4,%ebx
jb     1130 <main+0x20>
mov    $0x1,%ecx
nopl   0x0(%rax)
lea    0x1(%rcx),%esi
mov    %ebx,%eax
xor    %edx,%edx
div    %esi
test   %edx,%edx
je     113a <main+0x2a>
add    $0x2,%ecx
mov    %ebx,%eax
xor    %edx,%edx
div    %ecx
mov    %esi,%ecx
cmp    %eax,%esi
jb     1150 <main+0x40>
jmp    1130 <main+0x20>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [13 x i8] c"%d is prime\0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %14
%2 = phi i32 [ 2, %0 ], [ %15, %14 ]
%3 = icmp ult i32 %2, 4
br i1 %3, label %12, label %7
4: ; preds = %7
%5 = udiv i32 %2, %11
%6 = icmp ult i32 %8, %5
br i1 %6, label %7, label %12
7: ; preds = %1, %4
%8 = phi i32 [ %11, %4 ], [ 2, %1 ]
%9 = urem i32 %2, %8
%10 = icmp eq i32 %9, 0
%11 = add nuw nsw i32 %8, 1
br i1 %10, label %14, label %4
12: ; preds = %4, %1
%13 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %2)
br label %14
14: ; preds = %7, %12
%15 = add nuw nsw i32 %2, 1
%16 = icmp eq i32 %15, 100
br i1 %16, label %17, label %1
17: ; preds = %14
ret i32 0
}