#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 */
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int valor;
  int i;
  int control;
  printf("Introduzca un valor: ");
  scanf("%d", &valor);
  for (i = 2; i < valor; i++) {
    if (0 == (valor % i))
      control = 1;
    else
      control = 0;
  }
  if (control == 1)
    printf("%d no es primo\n", valor);
  else
    printf("%d es primo\n", valor);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed2(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1197 <main+0x77>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
xor    %eax,%eax
cmp    %edx,%eax
jne    117d <main+0x5d>
movl   $0x1,-0x10(%rbp)
jmp    1184 <main+0x64>
movl   $0x0,-0x10(%rbp)
jmp    1189 <main+0x69>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1154 <main+0x34>
cmpl   $0x1,-0x10(%rbp)
jne    11b7 <main+0x97>
mov    -0x8(%rbp),%esi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c8 <main+0xa8>
mov    -0x8(%rbp),%esi
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee0(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%esi
cmp    $0x3,%esi
jl     1168 <main+0x48>
lea    -0x1(%rsi),%ecx
mov    %esi,%eax
xor    %edx,%edx
div    %ecx
test   %edx,%edx
lea    0xebe(%rip),%rax
lea    0xec7(%rip),%rdi
cmove  %rax,%rdi
jmp    116f <main+0x4f>
lea    0xeaa(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Introduzca un valor: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [16 x i8] c"%d no es primo\0A\00"
@.str.3 = [13 x i8] c"%d es primo\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
store i32 2, i32* %3
br label %7
7: ; preds = %19, %0
%8 = load i32, i32* %3
%9 = load i32, i32* %2
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %22
11: ; preds = %7
%12 = load i32, i32* %2
%13 = load i32, i32* %3
%14 = srem i32 %12, %13
%15 = icmp eq i32 0, %14
br i1 %15, label %16, label %17
16: ; preds = %11
store i32 1, i32* %4
br label %18
17: ; preds = %11
store i32 0, i32* %4
br label %18
18: ; preds = %17, %16
br label %19
19: ; preds = %18
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
store i32 %21, i32* %3
br label %7
22: ; preds = %7
%23 = load i32, i32* %4
%24 = icmp eq i32 %23, 1
br i1 %24, label %25, label %28
25: ; preds = %22
%26 = load i32, i32* %2
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %26)
br label %31
28: ; preds = %22
%29 = load i32, i32* %2
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %29)
br label %31
31: ; preds = %28, %25
ret i32 0
}

LLVM IR (-O2):
@.str = [22 x i8] c"Introduzca un valor: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [16 x i8] c"%d no es primo\0A\00"
@.str.3 = [13 x i8] c"%d es primo\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp sgt i32 %5, 2
br i1 %6, label %7, label %12
7: ; preds = %0
%8 = add nsw i32 %5, -1
%9 = urem i32 %5, %8
%10 = icmp eq i32 %9, 0
%11 = select i1 %10, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0)
br label %12
12: ; preds = %7, %0
%13 = phi i8* [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), %0 ], [ %11, %7 ]
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %13, i32 %5)
ret i32 0
}