#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 */
scalar_t__ floor(int /*<<< orphan*/);
int /*<<< orphan*/ sqrt(double);
int findPrime(int value) {
  if (value <= 3)
    return 3;
  if ((value & 1) == 0)
    value++;
  for (;;) {
    int root = (int)floor(sqrt((double)value)) + 1;
    int divisor;
    for (divisor = 3; divisor <= root; divisor++) {
      if ((value % divisor) == 0)
        break;
    }
    if (divisor > root)
      return value;
    value += 2;
  }
}


x86 assembly (clang, -O0):
<findPrime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0x3,-0x8(%rbp)
jg     1141 <findPrime+0x21>
movl   $0x3,-0x4(%rbp)
jmp    11d5 <findPrime+0xb5>
mov    -0x8(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
jne    1159 <findPrime+0x39>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    115e <findPrime+0x3e>
cvtsi2sdl -0x8(%rbp),%xmm0
call   1030 <sqrt@plt>
mov    %eax,%edi
call   1040 <floor@plt>
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
movl   $0x3,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     11b0 <findPrime+0x90>
mov    -0x8(%rbp),%eax
cltd
idivl  -0x10(%rbp)
cmp    $0x0,%edx
jne    119d <findPrime+0x7d>
jmp    11b0 <findPrime+0x90>
jmp    11a2 <findPrime+0x82>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    117c <findPrime+0x5c>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    11c7 <findPrime+0xa7>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11d5 <findPrime+0xb5>
mov    -0x8(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x8(%rbp)
jmp    115e <findPrime+0x3e>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<findPrime>:
push   %rbx
mov    $0x3,%ebx
cmp    $0x4,%edi
jl     114c <findPrime+0x2c>
mov    %edi,%ebx
not    %ebx
and    $0x1,%ebx
add    %edi,%ebx
cvtsi2sd %ebx,%xmm0
call   1030 <sqrt@plt>
mov    %eax,%edi
call   1040 <floor@plt>
mov    %rax,%rcx
cmp    $0x2,%ecx
jge    1150 <findPrime+0x30>
mov    %ebx,%eax
pop    %rbx
ret
neg    %ecx
mov    $0x3,%esi
nopw   0x0(%rax,%rax,1)
mov    %ebx,%eax
cltd
idiv   %esi
test   %edx,%edx
je     1180 <findPrime+0x60>
lea    (%rcx,%rsi,1),%eax
add    $0x1,%eax
mov    %esi,%edx
add    $0x1,%edx
mov    %edx,%esi
cmp    $0x2,%eax
jne    1160 <findPrime+0x40>
jmp    114c <findPrime+0x2c>
nopl   (%rax)
add    $0x2,%ebx
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
call   1030 <sqrt@plt>
mov    %eax,%edi
call   1040 <floor@plt>
mov    %rax,%rcx
cmp    $0x1,%ecx
jg     1150 <findPrime+0x30>
jmp    114c <findPrime+0x2c>

LLVM IR (-O0):
define i32 @findPrime(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
%6 = load i32, i32* %3
%7 = icmp sle i32 %6, 3
br i1 %7, label %8, label %9
8: ; preds = %1
store i32 3, i32* %2
br label %47
9: ; preds = %1
%10 = load i32, i32* %3
%11 = and i32 %10, 1
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %9
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 1
store i32 %15, i32* %3
br label %16
16: ; preds = %13, %9
br label %17
17: ; preds = %44, %16
%18 = load i32, i32* %3
%19 = sitofp i32 %18 to double
%20 = call i32 @sqrt(double %19)
%21 = call i64 @floor(i32 %20)
%22 = trunc i64 %21 to i32
%23 = add nsw i32 %22, 1
store i32 %23, i32* %4
store i32 3, i32* %5
br label %24
24: ; preds = %35, %17
%25 = load i32, i32* %5
%26 = load i32, i32* %4
%27 = icmp sle i32 %25, %26
br i1 %27, label %28, label %38
28: ; preds = %24
%29 = load i32, i32* %3
%30 = load i32, i32* %5
%31 = srem i32 %29, %30
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %28
br label %38
34: ; preds = %28
br label %35
35: ; preds = %34
%36 = load i32, i32* %5
%37 = add nsw i32 %36, 1
store i32 %37, i32* %5
br label %24
38: ; preds = %33, %24
%39 = load i32, i32* %5
%40 = load i32, i32* %4
%41 = icmp sgt i32 %39, %40
br i1 %41, label %42, label %44
42: ; preds = %38
%43 = load i32, i32* %3
store i32 %43, i32* %2
br label %47
44: ; preds = %38
%45 = load i32, i32* %3
%46 = add nsw i32 %45, 2
store i32 %46, i32* %3
br label %17
47: ; preds = %42, %8
%48 = load i32, i32* %2
ret i32 %48
}

LLVM IR (-O2):
define i32 @findPrime(i32 %0) {
%2 = icmp slt i32 %0, 4
br i1 %2, label %30, label %3
3: ; preds = %1
%4 = and i32 %0, 1
%5 = xor i32 %4, 1
%6 = add nuw nsw i32 %5, %0
%7 = sitofp i32 %6 to double
%8 = tail call i32 @sqrt(double %7)
%9 = tail call i64 @floor(i32 %8)
%10 = trunc i64 %9 to i32
%11 = icmp slt i32 %10, 2
br i1 %11, label %30, label %12
12: ; preds = %3, %23
%13 = phi i32 [ %28, %23 ], [ %10, %3 ]
%14 = phi i32 [ %24, %23 ], [ %6, %3 ]
%15 = add nuw i32 %13, 1
br label %19
16: ; preds = %19
%17 = add nuw i32 %20, 1
%18 = icmp eq i32 %20, %15
br i1 %18, label %30, label %19
19: ; preds = %12, %16
%20 = phi i32 [ 3, %12 ], [ %17, %16 ]
%21 = srem i32 %14, %20
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %16
23: ; preds = %19
%24 = add nsw i32 %14, 2
%25 = sitofp i32 %24 to double
%26 = tail call i32 @sqrt(double %25)
%27 = tail call i64 @floor(i32 %26)
%28 = trunc i64 %27 to i32
%29 = icmp slt i32 %28, 2
br i1 %29, label %30, label %12
30: ; preds = %23, %16, %3, %1
%31 = phi i32 [ 3, %1 ], [ %6, %3 ], [ %14, %16 ], [ %24, %23 ]
ret i32 %31
}