#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 num, div, flag;
  div = 2;
  flag = 1;
  printf("\nIngrese un numero: ");
  scanf("%d", &num);
  if (num == 0)
    printf("\nEl numero no es primo\n\n");
  else if (num == 1)
    printf("\nEl numero no es primo\n\n");
  else {
    for (div = 2; div <= num - 1 && flag == 1; div++) {
      if (num % div == 0)
        flag = 0;
    }
    if (flag == 1)
      printf("\nEl numero es primo\n\n");
    else
      printf("\nEl numero no es primo\n\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
lea    0xebc(%rip),%rdi
call   1030 <printf@plt>
lea    0xec5(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    1174 <main+0x54>
lea    0xeae(%rip),%rdi
call   1030 <printf@plt>
jmp    1221 <main+0x101>
cmpl   $0x1,-0x8(%rbp)
jne    118f <main+0x6f>
lea    0xe93(%rip),%rdi
call   1030 <printf@plt>
jmp    121c <main+0xfc>
movl   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%edx
sub    $0x1,%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x11(%rbp)
jg     11b6 <main+0x96>
cmpl   $0x1,-0x10(%rbp)
sete   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    11c6 <main+0xa6>
jmp    11f0 <main+0xd0>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    11dd <main+0xbd>
movl   $0x0,-0x10(%rbp)
jmp    11e2 <main+0xc2>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1196 <main+0x76>
cmpl   $0x1,-0x10(%rbp)
jne    120b <main+0xeb>
lea    0xe30(%rip),%rdi
call   1030 <printf@plt>
jmp    1217 <main+0xf7>
lea    0xe06(%rip),%rdi
call   1030 <printf@plt>
jmp    121c <main+0xfc>
jmp    1221 <main+0x101>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xec8(%rip),%rdi
call   1040 <printf@plt>
lea    0xed1(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%ecx
cmp    $0x2,%ecx
jae    1160 <main+0x30>
lea    0xecf(%rip),%rdi
jmp    11a0 <main+0x70>
jle    1199 <main+0x69>
mov    $0x3,%esi
nopw   0x0(%rax,%rax,1)
lea    -0x1(%rsi),%edi
mov    %ecx,%eax
cltd
idiv   %edi
cmp    %ecx,%esi
jge    1183 <main+0x53>
add    $0x1,%esi
test   %edx,%edx
jne    1170 <main+0x40>
test   %edx,%edx
lea    0xe8c(%rip),%rax
lea    0xe9a(%rip),%rdi
cmovne %rax,%rdi
jmp    11a0 <main+0x70>
lea    0xe78(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str = [21 x i8] c"\0AIngrese un numero: \00"
@.str.1 = [3 x i8] c"%d\00"
@str.4 = [21 x i8] c"\0AEl numero es primo\0A\00"
@str.6 = [24 x i8] c"\0AEl numero no es primo\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 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 0, label %18
i32 1, label %8
]
6: ; preds = %0
%7 = icmp sgt i32 %5, 2
br i1 %7, label %9, label %18
8: ; preds = %0
br label %18
9: ; preds = %6, %9
%10 = phi i32 [ %13, %9 ], [ 2, %6 ]
%11 = srem i32 %5, %10
%12 = icmp ne i32 %11, 0
%13 = add nuw nsw i32 %10, 1
%14 = icmp slt i32 %13, %5
%15 = and i1 %14, %12
br i1 %15, label %9, label %16
16: ; preds = %9
%17 = select i1 %12, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @str.4, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @str.6, i64 0, i64 0)
br label %18
18: ; preds = %16, %6, %0, %8
%19 = phi i8* [ getelementptr inbounds ([24 x i8], [24 x i8]* @str.6, i64 0, i64 0), %8 ], [ getelementptr inbounds ([24 x i8], [24 x i8]* @str.6, i64 0, i64 0), %0 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @str.4, i64 0, i64 0), %6 ], [ %17, %16 ]
%20 = call i32 @puts(i8* dereferenceable(1) %19)
ret i32 0
}