#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(long, double);
int is_prime(long 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    %rdi,-0x10(%rbp)
cmpq   $0x2,-0x10(%rbp)
jge    1133 <is_prime+0x23>
movl   $0x0,-0x4(%rbp)
jmp    11bd <is_prime+0xad>
cmpq   $0x2,-0x10(%rbp)
jne    114a <is_prime+0x3a>
movl   $0x1,-0x4(%rbp)
jmp    11bd <is_prime+0xad>
jmp    114f <is_prime+0x3f>
movq   $0x2,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
movsd  0xe95(%rip),%xmm0
call   1030 <pow@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
jg     11b6 <is_prime+0xa6>
mov    -0x10(%rbp),%rax
cqto
idivq  -0x18(%rbp)
cmp    $0x0,%rdx
jne    11a0 <is_prime+0x90>
movl   $0x0,-0x4(%rbp)
jmp    11bd <is_prime+0xad>
jmp    11a5 <is_prime+0x95>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1157 <is_prime+0x47>
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   %rbx
push   %rax
xor    %r14d,%r14d
cmp    $0x2,%rdi
jl     11ad <is_prime+0x9d>
mov    $0x1,%r14d
je     11ad <is_prime+0x9d>
mov    %rdi,%rbx
movsd  0xec5(%rip),%xmm0
call   1030 <pow@plt>
cmp    $0x2,%rax
jl     11ad <is_prime+0x9d>
mov    $0x1,%ebp
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbp
mov    %rbx,%rax
or     %rbp,%rax
shr    $0x20,%rax
je     1180 <is_prime+0x70>
mov    %rbx,%rax
cqto
idiv   %rbp
mov    %rdx,%r15
test   %r15,%r15
jne    118e <is_prime+0x7e>
jmp    11a3 <is_prime+0x93>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebx,%eax
xor    %edx,%edx
div    %ebp
mov    %edx,%r15d
test   %r15,%r15
je     11a3 <is_prime+0x93>
mov    %rbx,%rdi
movsd  0xe67(%rip),%xmm0
call   1030 <pow@plt>
cmp    %rax,%rbp
jl     1150 <is_prime+0x40>
xor    %r14d,%r14d
test   %r15,%r15
setne  %r14b
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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