#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 sqrt(int);
int main(void) {
  int i, j, is_prime;
  for (i = 2; i <= 10; i++) {
    is_prime = !0;
    for (j = 2; j < sqrt(i) + 1 && !0 == is_prime; j++)
      if (i % j == 0)
        is_prime = 0;
    if (!0 == is_prime)
      printf("%d is prime number.\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   $0xa,-0x8(%rbp)
jg     11e9 <main+0xc9>
movl   $0x1,-0x10(%rbp)
movl   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <sqrt@plt>
mov    -0x18(%rbp),%ecx
mov    %eax,%edx
add    $0x1,%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x11(%rbp)
jge    117f <main+0x5f>
mov    $0x1,%eax
cmp    -0x10(%rbp),%eax
sete   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    118f <main+0x6f>
jmp    11b9 <main+0x99>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    11a6 <main+0x86>
movl   $0x0,-0x10(%rbp)
jmp    11ab <main+0x8b>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114e <main+0x2e>
mov    $0x1,%eax
cmp    -0x10(%rbp),%eax
jne    11d6 <main+0xb6>
mov    -0x8(%rbp),%esi
lea    0xe2f(%rip),%rdi
call   1030 <printf@plt>
jmp    11db <main+0xbb>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1136 <main+0x16>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x2,%r15d
lea    0xecc(%rip),%r14
jmp    1155 <main+0x35>
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15d,%esi
call   1030 <printf@plt>
add    $0x1,%r15d
cmp    $0xb,%r15d
je     1194 <main+0x74>
mov    %r15d,%edi
call   1040 <sqrt@plt>
cmp    $0x2,%eax
jl     1140 <main+0x20>
mov    $0x2,%ebx
nopw   0x0(%rax,%rax,1)
mov    %r15d,%eax
xor    %edx,%edx
div    %ebx
mov    %edx,%ebp
mov    %r15d,%edi
call   1040 <sqrt@plt>
test   %ebp,%ebp
je     118e <main+0x6e>
lea    0x1(%rbx),%ecx
cmp    %eax,%ebx
mov    %ecx,%ebx
jl     1170 <main+0x50>
test   %ebp,%ebp
jne    1140 <main+0x20>
jmp    114b <main+0x2b>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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