#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(long long);
int esPrimo(long long int n) {
  long i;
  for (i = 2; i < (int)floor(sqrt(n)) + 1; i++)
    if (n % i == 0)
      return 0;
  return 1;
}


x86 assembly (clang, -O0):
<esPrimo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x2,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <sqrt@plt>
mov    %eax,%edi
call   1040 <floor@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
add    $0x1,%ecx
movslq %ecx,%rcx
cmp    %rcx,%rax
jge    1198 <esPrimo+0x78>
mov    -0x10(%rbp),%rax
cqto
idivq  -0x18(%rbp)
cmp    $0x0,%rdx
jne    1182 <esPrimo+0x62>
movl   $0x0,-0x4(%rbp)
jmp    119f <esPrimo+0x7f>
jmp    1187 <esPrimo+0x67>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1134 <esPrimo+0x14>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<esPrimo>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
movabs $0x100000000,%r15
call   1030 <sqrt@plt>
mov    %eax,%edi
call   1040 <floor@plt>
shl    $0x20,%rax
add    %r15,%rax
mov    $0x1,%r14d
movabs $0x200000001,%rcx
cmp    %rcx,%rax
jl     11c3 <esPrimo+0xa3>
mov    $0x2,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rax
or     %rbp,%rax
shr    $0x20,%rax
je     1190 <esPrimo+0x70>
mov    %rbx,%rax
cqto
idiv   %rbp
test   %rdx,%rdx
jne    119b <esPrimo+0x7b>
jmp    11c0 <esPrimo+0xa0>
nopl   0x0(%rax,%rax,1)
mov    %ebx,%eax
xor    %edx,%edx
div    %ebp
test   %rdx,%rdx
je     11c0 <esPrimo+0xa0>
add    $0x1,%rbp
mov    %rbx,%rdi
call   1030 <sqrt@plt>
mov    %eax,%edi
call   1040 <floor@plt>
shl    $0x20,%rax
add    %r15,%rax
sar    $0x20,%rax
cmp    %rax,%rbp
jl     1170 <esPrimo+0x50>
jmp    11c3 <esPrimo+0xa3>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @esPrimo(i64 %0) {
%2 = alloca i32
%3 = alloca i64
%4 = alloca i64
store i64 %0, i64* %3
store i64 2, i64* %4
br label %5
5: ; preds = %21, %1
%6 = load i64, i64* %4
%7 = load i64, i64* %3
%8 = call i32 @sqrt(i64 %7)
%9 = call i64 @floor(i32 %8)
%10 = trunc i64 %9 to i32
%11 = add nsw i32 %10, 1
%12 = sext i32 %11 to i64
%13 = icmp slt i64 %6, %12
br i1 %13, label %14, label %24
14: ; preds = %5
%15 = load i64, i64* %3
%16 = load i64, i64* %4
%17 = srem i64 %15, %16
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %14
store i32 0, i32* %2
br label %25
20: ; preds = %14
br label %21
21: ; preds = %20
%22 = load i64, i64* %4
%23 = add nsw i64 %22, 1
store i64 %23, i64* %4
br label %5
24: ; preds = %5
store i32 1, i32* %2
br label %25
25: ; preds = %24, %19
%26 = load i32, i32* %2
ret i32 %26
}

LLVM IR (-O2):
define i32 @esPrimo(i64 %0) {
%2 = tail call i32 @sqrt(i64 %0)
%3 = tail call i64 @floor(i32 %2)
%4 = shl i64 %3, 32
%5 = add i64 %4, 4294967296
%6 = icmp sgt i64 %5, 8589934592
br i1 %6, label %14, label %19
7: ; preds = %14
%8 = tail call i32 @sqrt(i64 %0)
%9 = tail call i64 @floor(i32 %8)
%10 = shl i64 %9, 32
%11 = add i64 %10, 4294967296
%12 = ashr exact i64 %11, 32
%13 = icmp slt i64 %18, %12
br i1 %13, label %14, label %19
14: ; preds = %1, %7
%15 = phi i64 [ %18, %7 ], [ 2, %1 ]
%16 = srem i64 %0, %15
%17 = icmp eq i64 %16, 0
%18 = add nuw nsw i64 %15, 1
br i1 %17, label %19, label %7
19: ; preds = %14, %7, %1
%20 = phi i32 [ 1, %1 ], [ 1, %7 ], [ 0, %14 ]
ret i32 %20
}