#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 = 2;
  int no_primo = 0;
  printf("Introduzca un valor: ");
  scanf("%d", &valor);
  while (i < valor) {
    if (0 == (valor % i)) {
      no_primo = 1;
      i = valor;
    }
    if (0 == (i % 2))
      i++;
    else
      i = i + 2;
  }
  if (no_primo == 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)
movl   $0x2,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec4(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11b6 <main+0x96>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
xor    %eax,%eax
cmp    %edx,%eax
jne    1185 <main+0x65>
movl   $0x1,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
xor    %eax,%eax
cmp    %edx,%eax
jne    11a8 <main+0x88>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11b1 <main+0x91>
mov    -0xc(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xc(%rbp)
jmp    115b <main+0x3b>
cmpl   $0x1,-0x10(%rbp)
jne    11d6 <main+0xb6>
mov    -0x8(%rbp),%esi
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e7 <main+0xc7>
mov    -0x8(%rbp),%esi
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xed4(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeda(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%esi
cmp    $0x3,%esi
jl     118d <main+0x6d>
mov    $0x2,%ecx
mov    $0x1,%edi
nopl   0x0(%rax)
mov    %esi,%eax
cltd
idiv   %ecx
test   %edx,%edx
cmove  %esi,%ecx
cmove  %edi,%ebx
mov    %ecx,%eax
and    $0x1,%eax
cmp    $0x1,%eax
sbb    $0x0,%ecx
add    $0x2,%ecx
cmp    %esi,%ecx
jl     1160 <main+0x40>
cmp    $0x1,%ebx
jne    118d <main+0x6d>
lea    0xe8e(%rip),%rdi
jmp    1194 <main+0x74>
lea    0xe95(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
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
store i32 2, i32* %3
store i32 0, i32* %4
%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)
br label %7
7: ; preds = %28, %0
%8 = load i32, i32* %3
%9 = load i32, i32* %2
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %29
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 %18
16: ; preds = %11
store i32 1, i32* %4
%17 = load i32, i32* %2
store i32 %17, i32* %3
br label %18
18: ; preds = %16, %11
%19 = load i32, i32* %3
%20 = srem i32 %19, 2
%21 = icmp eq i32 0, %20
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
br label %28
25: ; preds = %18
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 2
store i32 %27, i32* %3
br label %28
28: ; preds = %25, %22
br label %7
29: ; preds = %7
%30 = load i32, i32* %4
%31 = icmp eq i32 %30, 1
br i1 %31, label %32, label %35
32: ; preds = %29
%33 = load i32, i32* %2
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %33)
br label %38
35: ; preds = %29
%36 = load i32, i32* %2
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %36)
br label %38
38: ; preds = %35, %32
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 %21
7: ; preds = %0, %7
%8 = phi i32 [ %13, %7 ], [ 0, %0 ]
%9 = phi i32 [ %17, %7 ], [ 2, %0 ]
%10 = srem i32 %5, %9
%11 = icmp eq i32 %10, 0
%12 = select i1 %11, i32 %5, i32 %9
%13 = select i1 %11, i32 1, i32 %8
%14 = and i32 %12, 1
%15 = icmp eq i32 %14, 0
%16 = select i1 %15, i32 1, i32 2
%17 = add nsw i32 %16, %12
%18 = icmp slt i32 %17, %5
br i1 %18, label %7, label %19
19: ; preds = %7
%20 = icmp eq i32 %13, 1
br i1 %20, label %22, label %21
21: ; preds = %0, %19
br label %22
22: ; preds = %19, %21
%23 = phi i8* [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), %21 ], [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), %19 ]
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %23, i32 %5)
ret i32 0
}