#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 p, n;
  printf("Ingrese un numero entre el 1 y el 20: ");
  scanf("%d", &n);
  p = 1;
  if (n == 1) {
    printf("No es primo\n");
  } else if (n == 2) {
    printf("Primo!\n");
  } else {
    for (int i = 2; i < n; i++) {
      if (n % i == 0) {
        p = 0;
        break;
      }
    }
    if (p)
      printf("Primo!\n");
    else
      printf("No es primo\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
call   1030 <printf@plt>
lea    0xee5(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x1,-0x8(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    116d <main+0x4d>
lea    0xec7(%rip),%rdi
call   1030 <printf@plt>
jmp    11fb <main+0xdb>
cmpl   $0x2,-0xc(%rbp)
jne    1188 <main+0x68>
lea    0xeb9(%rip),%rdi
call   1030 <printf@plt>
jmp    11f6 <main+0xd6>
movl   $0x2,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11ca <main+0xaa>
mov    -0xc(%rbp),%eax
cltd
idivl  -0x10(%rbp)
cmp    $0x0,%edx
jne    11b7 <main+0x97>
movl   $0x0,-0x8(%rbp)
jmp    11ca <main+0xaa>
jmp    11bc <main+0x9c>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    118f <main+0x6f>
cmpl   $0x0,-0x8(%rbp)
je     11e5 <main+0xc5>
lea    0xe5c(%rip),%rdi
call   1030 <printf@plt>
jmp    11f1 <main+0xd1>
lea    0xe3e(%rip),%rdi
call   1030 <printf@plt>
jmp    11f6 <main+0xd6>
jmp    11fb <main+0xdb>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xec8(%rip),%rdi
call   1040 <printf@plt>
lea    0xee3(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
lea    0xedc(%rip),%rdi
mov    0x4(%rsp),%ecx
cmp    $0x1,%ecx
je     1193 <main+0x63>
cmp    $0x2,%ecx
jne    116c <main+0x3c>
lea    0xec0(%rip),%rdi
jmp    1193 <main+0x63>
lea    0xeb7(%rip),%r8
jle    1190 <main+0x60>
mov    $0x2,%esi
nopw   0x0(%rax,%rax,1)
mov    %ecx,%eax
cltd
idiv   %esi
test   %edx,%edx
je     1193 <main+0x63>
add    $0x1,%esi
cmp    %esi,%ecx
jne    1180 <main+0x50>
mov    %r8,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [39 x i8] c"Ingrese un numero entre el 1 y el 20: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [13 x i8] c"No es primo\0A\00"
@.str.3 = [8 x i8] c"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 @printf(i8* getelementptr inbounds ([39 x i8], [39 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* %3)
store i32 1, i32* %2
%7 = load i32, i32* %3
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %40
11: ; preds = %0
%12 = load i32, i32* %3
%13 = icmp eq i32 %12, 2
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %39
16: ; preds = %11
store i32 2, i32* %4
br label %17
17: ; preds = %28, %16
%18 = load i32, i32* %4
%19 = load i32, i32* %3
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %31
21: ; preds = %17
%22 = load i32, i32* %3
%23 = load i32, i32* %4
%24 = srem i32 %22, %23
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %21
store i32 0, i32* %2
br label %31
27: ; preds = %21
br label %28
28: ; preds = %27
%29 = load i32, i32* %4
%30 = add nsw i32 %29, 1
store i32 %30, i32* %4
br label %17
31: ; preds = %26, %17
%32 = load i32, i32* %2
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %31
%35 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %38
36: ; preds = %31
%37 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %38
38: ; preds = %36, %34
br label %39
39: ; preds = %38, %14
br label %40
40: ; preds = %39, %9
ret i32 0
}

LLVM IR (-O2):
@.str = [39 x i8] c"Ingrese un numero entre el 1 y el 20: \00"
@.str.1 = [3 x i8] c"%d\00"
@str.5 = [7 x i8] c"Primo!\00"
@str.6 = [12 x i8] c"No es primo\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 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
switch i32 %5, label %6 [
i32 1, label %16
i32 2, label %8
]
6: ; preds = %0
%7 = icmp sgt i32 %5, 2
br i1 %7, label %11, label %16
8: ; preds = %0
br label %16
9: ; preds = %11
%10 = icmp eq i32 %15, %5
br i1 %10, label %16, label %11
11: ; preds = %6, %9
%12 = phi i32 [ %15, %9 ], [ 2, %6 ]
%13 = srem i32 %5, %12
%14 = icmp eq i32 %13, 0
%15 = add nuw nsw i32 %12, 1
br i1 %14, label %16, label %9
16: ; preds = %11, %9, %6, %0, %8
%17 = phi i8* [ getelementptr inbounds ([7 x i8], [7 x i8]* @str.5, i64 0, i64 0), %8 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @str.6, i64 0, i64 0), %0 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @str.5, i64 0, i64 0), %6 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @str.5, i64 0, i64 0), %9 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @str.6, i64 0, i64 0), %11 ]
%18 = call i32 @puts(i8* dereferenceable(1) %17)
ret i32 0
}