#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*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int /*<<< orphan*/ stdin;
int main(int argc, char *argv[]) {
  int n1 = 0, i = 1, modulo1 = -1;
  char linea[180];
  printf("Intruduce un numero entero: ");
  fgets(linea, 180, stdin);
  sscanf(linea, "%d", &n1);
  while (i < (n1 * 2)) {
    modulo1 = n1 % (i + 1);
    if (modulo1 != 0) {
      break;
    } else {
      i++;
    }
  }
  if (modulo1 != 0) {
    printf("\nEl es primo");
  } else {
    printf("\nEl no es primo");
  }
  printf("\nPulsa Cuanquier tecla para terminar: ");
  fgets(linea, 180, stdin);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0xffffffff,-0x1c(%rbp)
lea    0xe9b(%rip),%rdi
call   1030 <printf@plt>
lea    -0xd0(%rbp),%rdi
mov    0x2e70(%rip),%rax
mov    (%rax),%edx
mov    $0xb4,%esi
call   1040 <fgets@plt>
lea    -0xd0(%rbp),%rdi
lea    0xe8b(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1050 <sscanf@plt>
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
shl    $0x1,%ecx
cmp    %ecx,%eax
jge    11d8 <main+0xa8>
mov    -0x14(%rbp),%eax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     11ca <main+0x9a>
jmp    11d8 <main+0xa8>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    119b <main+0x6b>
cmpl   $0x0,-0x1c(%rbp)
je     11f3 <main+0xc3>
lea    0xe37(%rip),%rdi
call   1030 <printf@plt>
jmp    11ff <main+0xcf>
lea    0xe33(%rip),%rdi
call   1030 <printf@plt>
lea    0xe37(%rip),%rdi
call   1030 <printf@plt>
lea    -0xd0(%rbp),%rdi
mov    0x2dcf(%rip),%rax
mov    (%rax),%edx
mov    $0xb4,%esi
call   1040 <fgets@plt>
xor    %eax,%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0xc8,%rsp
movl   $0x0,0xc(%rsp)
lea    0xeb7(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e93(%rip),%r14
mov    (%r14),%edx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xb4,%esi
call   1040 <fgets@plt>
lea    0xeac(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %rbx,%rdi
call   1050 <sscanf@plt>
mov    0xc(%rsp),%ecx
lea    0xe97(%rip),%rdi
test   %ecx,%ecx
jle    11ce <main+0x9e>
lea    (%rcx,%rcx,1),%esi
cmp    $0x3,%esi
mov    $0x2,%ebx
cmovl  %ebx,%esi
neg    %esi
lea    0xe89(%rip),%r8
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ecx,%eax
cltd
idiv   %ebx
test   %edx,%edx
jne    11ce <main+0x9e>
lea    (%rsi,%rbx,1),%eax
add    $0x1,%eax
mov    %ebx,%edx
add    $0x1,%edx
mov    %edx,%ebx
cmp    $0x1,%eax
jne    11b0 <main+0x80>
mov    %r8,%rdi
call   1030 <printf@plt>
lea    0xe63(%rip),%rdi
call   1030 <printf@plt>
mov    (%r14),%edx
lea    0x10(%rsp),%rdi
mov    $0xb4,%esi
call   1040 <fgets@plt>
xor    %eax,%eax
add    $0xc8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [29 x i8] c"Intruduce un numero entero: \00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [13 x i8] c"\0AEl es primo\00"
@.str.3 = [16 x i8] c"\0AEl no es primo\00"
@.str.4 = [39 x i8] c"\0APulsa Cuanquier tecla para terminar: \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [180 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 1, i32* %7
store i32 -1, i32* %8
%10 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%11 = getelementptr inbounds [180 x i8], [180 x i8]* %9, i64 0, i64 0
%12 = load i32, i32* @stdin
%13 = call i32 @fgets(i8* %11, i32 180, i32 %12)
%14 = getelementptr inbounds [180 x i8], [180 x i8]* %9, i64 0, i64 0
%15 = call i32 @sscanf(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
br label %16
16: ; preds = %32, %2
%17 = load i32, i32* %7
%18 = load i32, i32* %6
%19 = mul nsw i32 %18, 2
%20 = icmp slt i32 %17, %19
br i1 %20, label %21, label %33
21: ; preds = %16
%22 = load i32, i32* %6
%23 = load i32, i32* %7
%24 = add nsw i32 %23, 1
%25 = srem i32 %22, %24
store i32 %25, i32* %8
%26 = load i32, i32* %8
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %21
br label %33
29: ; preds = %21
%30 = load i32, i32* %7
%31 = add nsw i32 %30, 1
store i32 %31, i32* %7
br label %32
32: ; preds = %29
br label %16
33: ; preds = %28, %16
%34 = load i32, i32* %8
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %33
%37 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %40
38: ; preds = %33
%39 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %40
40: ; preds = %38, %36
%41 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0))
%42 = getelementptr inbounds [180 x i8], [180 x i8]* %9, i64 0, i64 0
%43 = load i32, i32* @stdin
%44 = call i32 @fgets(i8* %42, i32 180, i32 %43)
ret i32 0
}

LLVM IR (-O2):
@.str = [29 x i8] c"Intruduce un numero entero: \00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [13 x i8] c"\0AEl es primo\00"
@.str.3 = [16 x i8] c"\0AEl no es primo\00"
@.str.4 = [39 x i8] c"\0APulsa Cuanquier tecla para terminar: \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca [180 x i8]
%5 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%6 = getelementptr inbounds [180 x i8], [180 x i8]* %4, i64 0, i64 0
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* @stdin
%9 = call i32 @fgets(i8* %6, i32 180, i32 %8)
%10 = call i32 @sscanf(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%11 = load i32, i32* %3
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %23
13: ; preds = %2
%14 = shl nuw i32 %11, 1
%15 = call i32 @llvm.smax.i32(i32 %14, i32 2)
br label %18
16: ; preds = %18
%17 = icmp eq i32 %20, %15
br i1 %17, label %23, label %18
18: ; preds = %13, %16
%19 = phi i32 [ %20, %16 ], [ 1, %13 ]
%20 = add nuw nsw i32 %19, 1
%21 = srem i32 %11, %20
%22 = icmp eq i32 %21, 0
br i1 %22, label %16, label %23
23: ; preds = %16, %18, %2
%24 = phi i8* [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), %2 ], [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), %16 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), %18 ]
%25 = call i32 @printf(i8* dereferenceable(1) %24)
%26 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0))
%27 = load i32, i32* @stdin
%28 = call i32 @fgets(i8* %6, i32 180, i32 %27)
ret i32 0
}