#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*/ puts(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int num = 2, i = 1, c = 0, mod = 0;
  while (num != 0) {
    printf("Numero: ");
    scanf("%d", &num);
    while (i <= num) {
      mod = num % i;
      if (mod == 0)
        c++;
      i++;
    }
    if (c == 2) {
      puts("Es primo");
    } else {
      puts("No es primo");
    }
    i = 1;
    c = 0;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     11f2 <main+0xc2>
lea    0xe94(%rip),%rdi
call   1040 <printf@plt>
lea    0xe91(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11b8 <main+0x88>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    11aa <main+0x7a>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1181 <main+0x51>
cmpl   $0x2,-0x10(%rbp)
jne    11d3 <main+0xa3>
lea    0xe43(%rip),%rdi
call   1030 <puts@plt>
jmp    11df <main+0xaf>
lea    0xe3b(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
jmp    115b <main+0x2b>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movl   $0x2,0x4(%rsp)
lea    0xeb6(%rip),%r14
lea    0xeb8(%rip),%r15
lea    0x4(%rsp),%r13
lea    0xeb8(%rip),%r12
lea    0xea8(%rip),%rbx
jmp    1183 <main+0x53>
cs nopw 0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1030 <puts@plt>
cmpl   $0x0,0x4(%rsp)
je     1214 <main+0xe4>
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%ecx
test   %ecx,%ecx
jle    1170 <main+0x40>
cmp    $0x1,%ecx
jne    11c0 <main+0x90>
mov    $0x1,%edi
xor    %esi,%esi
test   $0x1,%cl
jne    11f8 <main+0xc8>
jmp    1203 <main+0xd3>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%r8
mov    %ecx,%ebx
and    $0xfffffffe,%ebx
mov    $0x1,%edi
xor    %esi,%esi
nop
mov    %ecx,%eax
cltd
idiv   %edi
cmp    $0x1,%edx
adc    $0x0,%esi
lea    0x1(%rdi),%ebp
mov    %ecx,%eax
cltd
idiv   %ebp
cmp    $0x1,%edx
adc    $0x0,%esi
add    $0x2,%edi
cmp    %ebx,%ebp
jne    11d0 <main+0xa0>
mov    %r8,%rbx
test   $0x1,%cl
je     1203 <main+0xd3>
mov    %ecx,%eax
cltd
idiv   %edi
cmp    $0x1,%edx
adc    $0x0,%esi
mov    %rbx,%rdi
cmp    $0x2,%esi
jne    1170 <main+0x40>
jmp    1173 <main+0x43>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [9 x i8] c"Numero: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [9 x i8] c"Es primo\00"
@.str.3 = [12 x i8] c"No es primo\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 2, i32* %1
br label %3
3: ; preds = %0, %43
%4 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = icmp slt i32 %6, 1
br i1 %7, label %42, label %8
8: ; preds = %3
%9 = and i32 %6, 1
%10 = icmp eq i32 %6, 1
br i1 %10, label %29, label %11
11: ; preds = %8
%12 = and i32 %6, -2
br label %13
13: ; preds = %13, %11
%14 = phi i32 [ 0, %11 ], [ %25, %13 ]
%15 = phi i32 [ 1, %11 ], [ %26, %13 ]
%16 = phi i32 [ 0, %11 ], [ %27, %13 ]
%17 = srem i32 %6, %15
%18 = icmp eq i32 %17, 0
%19 = zext i1 %18 to i32
%20 = add nuw nsw i32 %14, %19
%21 = add nuw i32 %15, 1
%22 = srem i32 %6, %21
%23 = icmp eq i32 %22, 0
%24 = zext i1 %23 to i32
%25 = add nuw nsw i32 %20, %24
%26 = add nuw i32 %15, 2
%27 = add i32 %16, 2
%28 = icmp eq i32 %27, %12
br i1 %28, label %29, label %13
29: ; preds = %13, %8
%30 = phi i32 [ undef, %8 ], [ %25, %13 ]
%31 = phi i32 [ 0, %8 ], [ %25, %13 ]
%32 = phi i32 [ 1, %8 ], [ %26, %13 ]
%33 = icmp eq i32 %9, 0
br i1 %33, label %39, label %34
34: ; preds = %29
%35 = srem i32 %6, %32
%36 = icmp eq i32 %35, 0
%37 = zext i1 %36 to i32
%38 = add nuw nsw i32 %31, %37
br label %39
39: ; preds = %29, %34
%40 = phi i32 [ %30, %29 ], [ %38, %34 ]
%41 = icmp eq i32 %40, 2
br i1 %41, label %43, label %42
42: ; preds = %3, %39
br label %43
43: ; preds = %39, %42
%44 = phi i8* [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), %42 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), %39 ]
%45 = call i32 @puts(i8* dereferenceable(1) %44)
%46 = load i32, i32* %1
%47 = icmp eq i32 %46, 0
br i1 %47, label %48, label %3
48: ; preds = %43
ret i32 0
}