#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 *, unsigned long);
int isPrime(unsigned long number) {
  int a;
  printf("%d\n", number);
  for (a = 2; a * a < number; a++) {
    if (number % a == 0)
      return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<isPrime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xed9(%rip),%rdi
call   1030 <printf@plt>
movl   $0x2,-0x14(%rbp)
mov    -0x14(%rbp),%eax
imul   -0x14(%rbp),%eax
cltq
cmp    -0x10(%rbp),%rax
jae    117c <isPrime+0x6c>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
xor    %edx,%edx
div    %rcx
cmp    $0x0,%rdx
jne    1169 <isPrime+0x59>
movl   $0x0,-0x4(%rbp)
jmp    1183 <isPrime+0x73>
jmp    116e <isPrime+0x5e>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1133 <isPrime+0x23>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isPrime>:
push   %rbx
mov    %rdi,%rbx
lea    0xee5(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    $0x1,%ecx
cmp    $0x5,%rbx
jb     117d <isPrime+0x6d>
mov    $0x2,%esi
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rax
or     %rsi,%rax
shr    $0x20,%rax
je     1160 <isPrime+0x50>
mov    %rbx,%rax
xor    %edx,%edx
div    %rsi
test   %rdx,%rdx
jne    116b <isPrime+0x5b>
jmp    117b <isPrime+0x6b>
nopl   0x0(%rax,%rax,1)
mov    %ebx,%eax
xor    %edx,%edx
div    %esi
test   %rdx,%rdx
je     117b <isPrime+0x6b>
add    $0x1,%rsi
mov    %esi,%eax
imul   %eax,%eax
cmp    %rbx,%rax
jb     1140 <isPrime+0x30>
jmp    117d <isPrime+0x6d>
xor    %ecx,%ecx
mov    %ecx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
define i32 @isPrime(i64 %0) {
%2 = alloca i32
%3 = alloca i64
%4 = alloca i32
store i64 %0, i64* %3
%5 = load i64, i64* %3
%6 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 %5)
store i32 2, i32* %4
br label %7
7: ; preds = %22, %1
%8 = load i32, i32* %4
%9 = load i32, i32* %4
%10 = mul nsw i32 %8, %9
%11 = sext i32 %10 to i64
%12 = load i64, i64* %3
%13 = icmp ult i64 %11, %12
br i1 %13, label %14, label %25
14: ; preds = %7
%15 = load i64, i64* %3
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = urem i64 %15, %17
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %14
store i32 0, i32* %2
br label %26
21: ; preds = %14
br label %22
22: ; preds = %21
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 1
store i32 %24, i32* %4
br label %7
25: ; preds = %7
store i32 1, i32* %2
br label %26
26: ; preds = %25, %20
%27 = load i32, i32* %2
ret i32 %27
}

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