#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*/ getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int numero;
  int listaprimos[200000];
  int primo = 2;
  int esprimo = 0;
  int i, j;
  printf("Este programa calcula todos los primos inferiores a un numero ");
  printf("natural \nmayor que 1 dado por el usuario: \n");
  printf("Introduce un numero: ");
  scanf("%d", &numero);
  for (i = 0; i < 200000; i++) {
    listaprimos[200000] = 0;
  }
  listaprimos[0] = 2;
  i = 0;
  while (primo <= numero) {
    primo++;
    esprimo = 1;
    for (j = 0; j <= i; j++) {
      if ((primo % listaprimos[j]) == 0)
        esprimo = 0;
    }
    if (esprimo == 1) {
      i++;
      listaprimos[i] = primo;
    }
  }
  printf("Los primos hasta %d son: \n", numero);
  for (j = 0; j <= i; j++)
    printf("%03d ", listaprimos[j]);
  getchar();
  getchar();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc3520,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2,-0xc3514(%rbp)
movl   $0x0,-0xc3518(%rbp)
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xefa(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x0,-0xc351c(%rbp)
cmpl   $0x30d40,-0xc351c(%rbp)
jge    11c5 <main+0x95>
movl   $0x0,-0x10(%rbp)
mov    -0xc351c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc351c(%rbp)
jmp    119a <main+0x6a>
movl   $0x2,-0xc3510(%rbp)
movl   $0x0,-0xc351c(%rbp)
mov    -0xc3514(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1293 <main+0x163>
mov    -0xc3514(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc3514(%rbp)
movl   $0x1,-0xc3518(%rbp)
movl   $0x0,-0xc3520(%rbp)
mov    -0xc3520(%rbp),%eax
cmp    -0xc351c(%rbp),%eax
jg     125e <main+0x12e>
mov    -0xc3514(%rbp),%eax
movslq -0xc3520(%rbp),%rcx
cltd
idivl  -0xc3510(%rbp,%rcx,4)
cmp    $0x0,%edx
jne    1245 <main+0x115>
movl   $0x0,-0xc3518(%rbp)
jmp    124a <main+0x11a>
mov    -0xc3520(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc3520(%rbp)
jmp    120b <main+0xdb>
cmpl   $0x1,-0xc3518(%rbp)
jne    128e <main+0x15e>
mov    -0xc351c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc351c(%rbp)
mov    -0xc3514(%rbp),%ecx
movslq -0xc351c(%rbp),%rax
mov    %ecx,-0xc3510(%rbp,%rax,4)
jmp    11d9 <main+0xa9>
mov    -0x8(%rbp),%esi
lea    0xde7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc3520(%rbp)
mov    -0xc3520(%rbp),%eax
cmp    -0xc351c(%rbp),%eax
jg     12f0 <main+0x1c0>
movslq -0xc3520(%rbp),%rax
mov    -0xc3510(%rbp,%rax,4),%esi
lea    0xdca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc3520(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc3520(%rbp)
jmp    12ae <main+0x17e>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    -0x4(%rbp),%eax
add    $0xc3520,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0xc3510,%rsp
lea    0xead(%rip),%rdi
xor    %r15d,%r15d
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf15(%rip),%rdi
call   1030 <puts@plt>
lea    0xecf(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed7(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
movl   $0x0,0xc3510(%rsp)
movl   $0x2,0x10(%rsp)
mov    0xc(%rsp),%esi
cmp    $0x2,%esi
jge    11ba <main+0x7a>
lea    0xead(%rip),%rdi
xor    %r15d,%r15d
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1272 <main+0x132>
mov    $0x2,%r8d
jmp    11e4 <main+0xa4>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movslq %r15d,%rax
add    $0x1,%r15d
mov    %r10d,0x14(%rsp,%rax,4)
cmp    %esi,%r8d
mov    %r10d,%r8d
je     125f <main+0x11f>
lea    0x1(%r8),%r10d
test   %r15d,%r15d
js     11d0 <main+0x90>
lea    0x1(%r15),%r9d
test   %r15d,%r15d
je     1250 <main+0x110>
mov    %r9d,%r11d
and    $0xfffffffe,%r11d
mov    $0x1,%ebx
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r10d,%eax
cltd
idivl  0x10(%rsp,%rcx,4)
mov    %edx,%edi
mov    %r10d,%eax
cltd
idivl  0x14(%rsp,%rcx,4)
test   %edi,%edi
cmove  %edi,%ebx
test   %edx,%edx
cmove  %edx,%ebx
add    $0x2,%rcx
cmp    %rcx,%r11
jne    1210 <main+0xd0>
test   $0x1,%r9b
je     1248 <main+0x108>
mov    %r10d,%eax
cltd
idivl  0x10(%rsp,%rcx,4)
test   %edx,%edx
cmove  %edx,%ebx
cmp    $0x1,%ebx
je     11d0 <main+0x90>
jmp    11dc <main+0x9c>
nop
mov    $0x1,%ebx
xor    %ecx,%ecx
test   $0x1,%r9b
jne    123b <main+0xfb>
jmp    1248 <main+0x108>
lea    0xdf2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %r15d,%r15d
js     1297 <main+0x157>
add    $0x1,%r15d
lea    0xdf6(%rip),%r14
xor    %ebx,%ebx
nop
mov    0x10(%rsp,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1280 <main+0x140>
xor    %eax,%eax
call   1050 <getchar@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
xor    %eax,%eax
add    $0xc3510,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [63 x i8] c"Este programa calcula todos los primos inferiores a un numero \00"
@.str.1 = [44 x i8] c"natural \0Amayor que 1 dado por el usuario: \0A\00"
@.str.2 = [22 x i8] c"Introduce un numero: \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [27 x i8] c"Los primos hasta %d son: \0A\00"
@.str.5 = [6 x i8] c"%03d \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [200000 x i32]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 2, i32* %4
store i32 0, i32* %5
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
store i32 0, i32* %6
br label %12
12: ; preds = %17, %0
%13 = load i32, i32* %6
%14 = icmp slt i32 %13, 200000
br i1 %14, label %15, label %20
15: ; preds = %12
%16 = getelementptr inbounds [200000 x i32], [200000 x i32]* %3, i64 0, i64 200000
store i32 0, i32* %16
br label %17
17: ; preds = %15
%18 = load i32, i32* %6
%19 = add nsw i32 %18, 1
store i32 %19, i32* %6
br label %12
20: ; preds = %12
%21 = getelementptr inbounds [200000 x i32], [200000 x i32]* %3, i64 0, i64 0
store i32 2, i32* %21
store i32 0, i32* %6
br label %22
22: ; preds = %56, %20
%23 = load i32, i32* %4
%24 = load i32, i32* %2
%25 = icmp sle i32 %23, %24
br i1 %25, label %26, label %57
26: ; preds = %22
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 1
store i32 %28, i32* %4
store i32 1, i32* %5
store i32 0, i32* %7
br label %29
29: ; preds = %43, %26
%30 = load i32, i32* %7
%31 = load i32, i32* %6
%32 = icmp sle i32 %30, %31
br i1 %32, label %33, label %46
33: ; preds = %29
%34 = load i32, i32* %4
%35 = load i32, i32* %7
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [200000 x i32], [200000 x i32]* %3, i64 0, i64 %36
%38 = load i32, i32* %37
%39 = srem i32 %34, %38
%40 = icmp eq i32 %39, 0
br i1 %40, label %41, label %42
41: ; preds = %33
store i32 0, i32* %5
br label %42
42: ; preds = %41, %33
br label %43
43: ; preds = %42
%44 = load i32, i32* %7
%45 = add nsw i32 %44, 1
store i32 %45, i32* %7
br label %29
46: ; preds = %29
%47 = load i32, i32* %5
%48 = icmp eq i32 %47, 1
br i1 %48, label %49, label %56
49: ; preds = %46
%50 = load i32, i32* %6
%51 = add nsw i32 %50, 1
store i32 %51, i32* %6
%52 = load i32, i32* %4
%53 = load i32, i32* %6
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [200000 x i32], [200000 x i32]* %3, i64 0, i64 %54
store i32 %52, i32* %55
br label %56
56: ; preds = %49, %46
br label %22
57: ; preds = %22
%58 = load i32, i32* %2
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i32 %58)
store i32 0, i32* %7
br label %60
60: ; preds = %70, %57
%61 = load i32, i32* %7
%62 = load i32, i32* %6
%63 = icmp sle i32 %61, %62
br i1 %63, label %64, label %73
64: ; preds = %60
%65 = load i32, i32* %7
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [200000 x i32], [200000 x i32]* %3, i64 0, i64 %66
%68 = load i32, i32* %67
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32 %68)
br label %70
70: ; preds = %64
%71 = load i32, i32* %7
%72 = add nsw i32 %71, 1
store i32 %72, i32* %7
br label %60
73: ; preds = %60
%74 = call i32 (...) @getchar()
%75 = call i32 (...) @getchar()
%76 = load i32, i32* %1
ret i32 %76
}

LLVM IR (-O2):
@.str = [63 x i8] c"Este programa calcula todos los primos inferiores a un numero \00"
@.str.2 = [22 x i8] c"Introduce un numero: \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [27 x i8] c"Los primos hasta %d son: \0A\00"
@.str.5 = [6 x i8] c"%03d \00"
@str = [43 x i8] c"natural \0Amayor que 1 dado por el usuario: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [200000 x i32]
%3 = bitcast i32* %1 to i8*
%4 = bitcast [200000 x i32]* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%9 = getelementptr inbounds [200000 x i32], [200000 x i32]* %2, i64 0, i64 200000
store i32 0, i32* %9
%10 = getelementptr inbounds [200000 x i32], [200000 x i32]* %2, i64 0, i64 0
store i32 2, i32* %10
%11 = load i32, i32* %1
%12 = icmp slt i32 %11, 2
br i1 %12, label %13, label %15
13: ; preds = %0
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i32 %11)
br label %69
15: ; preds = %0, %63
%16 = phi i32 [ %64, %63 ], [ 0, %0 ]
%17 = phi i32 [ %18, %63 ], [ 2, %0 ]
%18 = add nuw i32 %17, 1
%19 = icmp slt i32 %16, 0
br i1 %19, label %59, label %20
20: ; preds = %15
%21 = add nuw i32 %16, 1
%22 = zext i32 %21 to i64
%23 = and i64 %22, 1
%24 = icmp eq i32 %16, 0
br i1 %24, label %45, label %25
25: ; preds = %20
%26 = and i64 %22, 4294967294
br label %27
27: ; preds = %27, %25
%28 = phi i64 [ 0, %25 ], [ %42, %27 ]
%29 = phi i32 [ 1, %25 ], [ %41, %27 ]
%30 = phi i64 [ 0, %25 ], [ %43, %27 ]
%31 = getelementptr inbounds [200000 x i32], [200000 x i32]* %2, i64 0, i64 %28
%32 = load i32, i32* %31
%33 = srem i32 %18, %32
%34 = icmp eq i32 %33, 0
%35 = or i64 %28, 1
%36 = getelementptr inbounds [200000 x i32], [200000 x i32]* %2, i64 0, i64 %35
%37 = load i32, i32* %36
%38 = srem i32 %18, %37
%39 = icmp eq i32 %38, 0
%40 = select i1 %39, i1 true, i1 %34
%41 = select i1 %40, i32 0, i32 %29
%42 = add nuw nsw i64 %28, 2
%43 = add i64 %30, 2
%44 = icmp eq i64 %43, %26
br i1 %44, label %45, label %27
45: ; preds = %27, %20
%46 = phi i32 [ undef, %20 ], [ %41, %27 ]
%47 = phi i64 [ 0, %20 ], [ %42, %27 ]
%48 = phi i32 [ 1, %20 ], [ %41, %27 ]
%49 = icmp eq i64 %23, 0
br i1 %49, label %56, label %50
50: ; preds = %45
%51 = getelementptr inbounds [200000 x i32], [200000 x i32]* %2, i64 0, i64 %47
%52 = load i32, i32* %51
%53 = srem i32 %18, %52
%54 = icmp eq i32 %53, 0
%55 = select i1 %54, i32 0, i32 %48
br label %56
56: ; preds = %45, %50
%57 = phi i32 [ %46, %45 ], [ %55, %50 ]
%58 = icmp eq i32 %57, 1
br i1 %58, label %59, label %63
59: ; preds = %15, %56
%60 = add nsw i32 %16, 1
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [200000 x i32], [200000 x i32]* %2, i64 0, i64 %61
store i32 %18, i32* %62
br label %63
63: ; preds = %59, %56
%64 = phi i32 [ %60, %59 ], [ %16, %56 ]
%65 = icmp eq i32 %17, %11
br i1 %65, label %66, label %15
66: ; preds = %63
%67 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i32 %11)
%68 = icmp slt i32 %64, 0
br i1 %68, label %80, label %69
69: ; preds = %13, %66
%70 = phi i32 [ 0, %13 ], [ %64, %66 ]
%71 = add nuw i32 %70, 1
%72 = zext i32 %71 to i64
br label %73
73: ; preds = %69, %73
%74 = phi i64 [ 0, %69 ], [ %78, %73 ]
%75 = getelementptr inbounds [200000 x i32], [200000 x i32]* %2, i64 0, i64 %74
%76 = load i32, i32* %75
%77 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32 %76)
%78 = add nuw nsw i64 %74, 1
%79 = icmp eq i64 %78, %72
br i1 %79, label %80, label %73
80: ; preds = %73, %66
%81 = call i32 (...) @getchar()
%82 = call i32 (...) @getchar()
ret i32 0
}