#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 */
long pow(int, double);
int is_prime(int i) {
  if (i < 2)
    return 0;
  else if (i == 2)
    return 1;
  for (long j = 2; j <= pow(i, 0.5); j++) {
    if (i % j == 0)
      return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<is_prime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1131 <is_prime+0x21>
movl   $0x0,-0x4(%rbp)
jmp    11b9 <is_prime+0xa9>
cmpl   $0x2,-0x8(%rbp)
jne    1147 <is_prime+0x37>
movl   $0x1,-0x4(%rbp)
jmp    11b9 <is_prime+0xa9>
jmp    114c <is_prime+0x3c>
movq   $0x2,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
movsd  0xe99(%rip),%xmm0
call   1030 <pow@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
cmp    %rcx,%rax
jg     11b2 <is_prime+0xa2>
movslq -0x8(%rbp),%rax
cqto
idivq  -0x10(%rbp)
cmp    $0x0,%rdx
jne    119c <is_prime+0x8c>
movl   $0x0,-0x4(%rbp)
jmp    11b9 <is_prime+0xa9>
jmp    11a1 <is_prime+0x91>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1154 <is_prime+0x44>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_prime>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %ebp,%ebp
cmp    $0x2,%edi
jl     118c <is_prime+0x7c>
mov    $0x1,%ebp
je     118c <is_prime+0x7c>
mov    %edi,%r14d
movsd  0xecf(%rip),%xmm0
call   1030 <pow@plt>
cmp    $0x2,%rax
jl     118c <is_prime+0x7c>
mov    %r14d,%r15d
mov    $0x2,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%r12
cmp    %rbp,%r15
jb     1162 <is_prime+0x52>
mov    %r15d,%eax
xor    %edx,%edx
div    %ebp
mov    %edx,%r12d
test   %r12,%r12
je     1183 <is_prime+0x73>
lea    0x1(%rbp),%rbx
mov    %r14d,%edi
movsd  0xe8a(%rip),%xmm0
call   1030 <pow@plt>
cmp    %rax,%rbp
mov    %rbx,%rbp
jl     1150 <is_prime+0x40>
xor    %ebp,%ebp
test   %r12,%r12
setne  %bpl
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @is_prime(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i64
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 2
br i1 %6, label %7, label %8
7: ; preds = %1
store i32 0, i32* %2
br label %31
8: ; preds = %1
%9 = load i32, i32* %3
%10 = icmp eq i32 %9, 2
br i1 %10, label %11, label %12
11: ; preds = %8
store i32 1, i32* %2
br label %31
12: ; preds = %8
br label %13
13: ; preds = %12
store i64 2, i64* %4
br label %14
14: ; preds = %27, %13
%15 = load i64, i64* %4
%16 = load i32, i32* %3
%17 = call i64 @pow(i32 %16, double 5.000000e-01)
%18 = icmp sle i64 %15, %17
br i1 %18, label %19, label %30
19: ; preds = %14
%20 = load i32, i32* %3
%21 = sext i32 %20 to i64
%22 = load i64, i64* %4
%23 = srem i64 %21, %22
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %19
store i32 0, i32* %2
br label %31
26: ; preds = %19
br label %27
27: ; preds = %26
%28 = load i64, i64* %4
%29 = add nsw i64 %28, 1
store i64 %29, i64* %4
br label %14
30: ; preds = %14
store i32 1, i32* %2
br label %31
31: ; preds = %30, %25, %11, %7
%32 = load i32, i32* %2
ret i32 %32
}

LLVM IR (-O2):
define i32 @is_prime(i32 %0) {
%2 = icmp slt i32 %0, 2
br i1 %2, label %20, label %3
3: ; preds = %1
%4 = icmp eq i32 %0, 2
br i1 %4, label %20, label %5
5: ; preds = %3
%6 = zext i32 %0 to i64
%7 = tail call i64 @pow(i32 %0, double 5.000000e-01)
%8 = icmp slt i64 %7, 2
br i1 %8, label %20, label %13
9: ; preds = %13
%10 = add nuw nsw i64 %14, 1
%11 = tail call i64 @pow(i32 %0, double 5.000000e-01)
%12 = icmp slt i64 %14, %11
br i1 %12, label %13, label %17
13: ; preds = %5, %9
%14 = phi i64 [ %10, %9 ], [ 2, %5 ]
%15 = urem i64 %6, %14
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %9
17: ; preds = %13, %9
%18 = xor i1 %16, true
%19 = zext i1 %18 to i32
br label %20
20: ; preds = %5, %17, %3, %1
%21 = phi i32 [ 0, %1 ], [ 1, %3 ], [ 1, %5 ], [ %19, %17 ]
ret i32 %21
}