#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 */
double ceil(int /*<<< orphan*/);
int /*<<< orphan*/ sqrt(int);
int teste(int primo) {
  double raiz_n;
  raiz_n = ceil(sqrt(primo));
  (int)raiz_n;
  if (primo % 2 == 0)
    return 1;
  for (int i = 3; i <= raiz_n; i = i + 2) {
    if ((primo % i) == 0)
      return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<teste>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <sqrt@plt>
mov    %eax,%edi
call   1030 <ceil@plt>
movsd  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    115f <teste+0x3f>
movl   $0x1,-0x4(%rbp)
jmp    11b0 <teste+0x90>
movl   $0x3,-0x14(%rbp)
cvtsi2sdl -0x14(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     11a9 <teste+0x89>
mov    -0x8(%rbp),%eax
cltd
idivl  -0x14(%rbp)
cmp    $0x0,%edx
jne    1196 <teste+0x76>
movl   $0x1,-0x4(%rbp)
jmp    11b0 <teste+0x90>
jmp    119b <teste+0x7b>
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x14(%rbp)
jmp    1166 <teste+0x46>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<teste>:
push   %rbx
mov    %edi,%ebx
call   1040 <sqrt@plt>
mov    %eax,%edi
call   1030 <ceil@plt>
mov    $0x1,%ecx
test   $0x1,%bl
je     116b <teste+0x4b>
ucomisd 0xebf(%rip),%xmm0
jb     1169 <teste+0x49>
mov    $0x3,%esi
nopl   0x0(%rax,%rax,1)
mov    %ebx,%eax
cltd
idiv   %esi
test   %edx,%edx
je     116b <teste+0x4b>
add    $0x2,%esi
xorps  %xmm1,%xmm1
cvtsi2sd %esi,%xmm1
ucomisd %xmm1,%xmm0
jae    1150 <teste+0x30>
xor    %ecx,%ecx
mov    %ecx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @teste(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca double
%5 = alloca i32
store i32 %0, i32* %3
%6 = load i32, i32* %3
%7 = call i32 @sqrt(i32 %6)
%8 = call double @ceil(i32 %7)
store double %8, double* %4
%9 = load double, double* %4
%10 = fptosi double %9 to i32
%11 = load i32, i32* %3
%12 = srem i32 %11, 2
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %1
store i32 1, i32* %2
br label %32
15: ; preds = %1
store i32 3, i32* %5
br label %16
16: ; preds = %28, %15
%17 = load i32, i32* %5
%18 = sitofp i32 %17 to double
%19 = load double, double* %4
%20 = fcmp ole double %18, %19
br i1 %20, label %21, label %31
21: ; preds = %16
%22 = load i32, i32* %3
%23 = load i32, i32* %5
%24 = srem i32 %22, %23
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %21
store i32 1, i32* %2
br label %32
27: ; preds = %21
br label %28
28: ; preds = %27
%29 = load i32, i32* %5
%30 = add nsw i32 %29, 2
store i32 %30, i32* %5
br label %16
31: ; preds = %16
store i32 0, i32* %2
br label %32
32: ; preds = %31, %26, %14
%33 = load i32, i32* %2
ret i32 %33
}

LLVM IR (-O2):
define i32 @teste(i32 %0) {
%2 = tail call i32 @sqrt(i32 %0)
%3 = tail call double @ceil(i32 %2)
%4 = and i32 %0, 1
%5 = icmp eq i32 %4, 0
br i1 %5, label %16, label %6
6: ; preds = %1
%7 = fcmp ult double %3, 3.000000e+00
br i1 %7, label %16, label %11
8: ; preds = %11
%9 = sitofp i32 %15 to double
%10 = fcmp ult double %3, %9
br i1 %10, label %16, label %11
11: ; preds = %6, %8
%12 = phi i32 [ %15, %8 ], [ 3, %6 ]
%13 = srem i32 %0, %12
%14 = icmp eq i32 %13, 0
%15 = add nuw nsw i32 %12, 2
br i1 %14, label %16, label %8
16: ; preds = %8, %11, %6, %1
%17 = phi i32 [ 1, %1 ], [ 0, %6 ], [ 0, %8 ], [ 1, %11 ]
ret i32 %17
}