#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 */
typedef double clock_t;

/* Variables and functions */
double CLOCKS_PER_SEC;
double clock();
int floor(int);
int /*<<< orphan*/ memset(int *, int, int);
int /*<<< orphan*/ printf(char *, ...);
int sqrt(int);
int main(int argc, char *argv[]) {
  clock_t start = clock();
  int size = 48615;
  bool primes[size];
  int stop = floor(sqrt(size));
  int stop1, i, j, k;
  int newline = 0;
  int l = 0;
  double time;
  memset(primes, false, size);
  for (i = 2; i <= stop; i++) {
    if (!primes[i]) {
      stop1 = floor(size / i);
      for (j = i; j <= stop1; j++) {
        primes[i * j] = true;
      }
    }
  }
  time = ((double)clock() - start) / CLOCKS_PER_SEC * 1000;
  printf("Los primeros números primos son:\n");
  for (i = 2; i <= size; i++) {
    if (!primes[i]) {
      printf("%d, ", i);
      newline++;
      l++;
    }
    if (newline == 10 | i == size) {
      printf("\n");
      newline = 0;
    }
  }
  printf("Se encontraron %d números primos, y el tiempo transcurrido fue de %f "
         "milisegundos \n",
         l, time);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
call   1030 <clock@plt>
movsd  %xmm0,-0x18(%rbp)
movl   $0xbde7,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x60(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
mov    -0x1c(%rbp),%edi
call   1060 <sqrt@plt>
mov    %eax,%edi
call   1070 <floor@plt>
mov    -0x60(%rbp),%rdi
mov    %eax,-0x34(%rbp)
movl   $0x0,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x1c(%rbp),%edx
xor    %esi,%esi
call   1050 <memset@plt>
movl   $0x2,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x34(%rbp),%eax
jg     1251 <main+0x101>
mov    -0x60(%rbp),%rax
movslq -0x3c(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    123e <main+0xee>
mov    -0x1c(%rbp),%eax
cltd
idivl  -0x3c(%rbp)
mov    %eax,%edi
call   1070 <floor@plt>
mov    %eax,-0x38(%rbp)
mov    -0x3c(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x38(%rbp),%eax
jg     1239 <main+0xe9>
mov    -0x60(%rbp),%rax
mov    -0x3c(%rbp),%ecx
imul   -0x40(%rbp),%ecx
movslq %ecx,%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    120a <main+0xba>
jmp    123e <main+0xee>
jmp    1243 <main+0xf3>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11d5 <main+0x85>
mov    $0x0,%al
call   1030 <clock@plt>
subsd  -0x18(%rbp),%xmm0
mov    0x2d84(%rip),%rax
divsd  (%rax),%xmm0
movsd  0xd90(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
lea    0xd88(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x2,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jg     131d <main+0x1cd>
mov    -0x60(%rbp),%rax
movslq -0x3c(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    12cf <main+0x17f>
mov    -0x3c(%rbp),%esi
lea    0xd75(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
cmpl   $0xa,-0x48(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    -0x3c(%rbp),%ecx
cmp    -0x1c(%rbp),%ecx
sete   %cl
and    $0x1,%cl
movzbl %cl,%ecx
or     %ecx,%eax
cmp    $0x0,%eax
je     130a <main+0x1ba>
lea    0xd87(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x48(%rbp)
jmp    130f <main+0x1bf>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    128e <main+0x13e>
mov    -0x4c(%rbp),%esi
movsd  -0x58(%rbp),%xmm0
lea    0xd04(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x2f7c8,%rsp
xor    %eax,%eax
call   1050 <clock@plt>
movsd  %xmm0,0x18(%rsp)
mov    $0xbde7,%edi
call   1080 <sqrt@plt>
mov    %eax,%edi
call   1090 <floor@plt>
mov    %eax,%r14d
lea    0x20(%rsp),%rdi
xor    %esi,%esi
mov    $0xbde7,%edx
call   1070 <memset@plt>
cmp    $0x2,%r14d
jge    127e <main+0x10e>
xor    %eax,%eax
call   1050 <clock@plt>
movsd  %xmm0,0x10(%rsp)
mov    0x2e1b(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,0x8(%rsp)
lea    0xe84(%rip),%rdi
call   1040 <puts@plt>
mov    $0x2,%ebx
lea    0xe19(%rip),%r14
xor    %r15d,%r15d
xor    %ebp,%ebp
jmp    1219 <main+0xa9>
cs nopw 0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %ebp,%ebp
add    $0x1,%rbx
cmp    $0xbde8,%rbx
je     1243 <main+0xd3>
cmpl   $0x0,0x20(%rsp,%rbx,4)
jne    1233 <main+0xc3>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%ebp
add    $0x1,%r15d
cmp    $0xbde7,%rbx
je     1200 <main+0x90>
cmp    $0xa,%ebp
jne    120c <main+0x9c>
jmp    1200 <main+0x90>
movsd  0x10(%rsp),%xmm0
subsd  0x18(%rsp),%xmm0
divsd  0x8(%rsp),%xmm0
mulsd  0xda3(%rip),%xmm0
lea    0xda9(%rip),%rdi
mov    %r15d,%esi
mov    $0x1,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x2f7c8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
add    $0x1,%r14d
mov    $0x2,%ebp
mov    $0x5,%ebx
mov    $0x4,%r15d
jmp    12b4 <main+0x144>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rbp
add    %rbx,%r15
add    $0x2,%rbx
cmp    %r14,%rbp
je     11b9 <main+0x49>
cmpl   $0x0,0x20(%rsp,%rbp,4)
jne    12a0 <main+0x130>
mov    $0xbde7,%eax
xor    %edx,%edx
div    %ebp
mov    %eax,%edi
call   1090 <floor@plt>
movslq %eax,%rcx
cmp    %rcx,%rbp
jg     12a0 <main+0x130>
add    $0x1,%eax
mov    %r15,%rcx
nopl   0x0(%rax)
mov    %ecx,%edx
movl   $0x1,0x20(%rsp,%rdx,4)
add    %rbp,%rcx
add    $0xffffffffffffffff,%rax
cmp    %rax,%rbp
jne    12e0 <main+0x170>
jmp    12a0 <main+0x130>

LLVM IR (-O0):
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str = [35 x i8] c"Los primeros n\C3\BAmeros primos son:\0A\00"
@.str.1 = [5 x i8] c"%d, \00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [85 x i8] c"Se encontraron %d n\C3\BAmeros primos, y el tiempo transcurrido fue de %f milisegundos \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%18 = call double (...) @clock()
store double %18, double* %6
store i32 48615, i32* %7
%19 = load i32, i32* %7
%20 = zext i32 %19 to i64
%21 = call i8* @llvm.stacksave()
store i8* %21, i8** %8
%22 = alloca i32, i64 %20
store i64 %20, i64* %9
%23 = load i32, i32* %7
%24 = call i32 @sqrt(i32 %23)
%25 = call i32 @floor(i32 %24)
store i32 %25, i32* %10
store i32 0, i32* %15
store i32 0, i32* %16
%26 = load i32, i32* %7
%27 = call i32 @memset(i32* %22, i32 0, i32 %26)
store i32 2, i32* %12
br label %28
28: ; preds = %59, %2
%29 = load i32, i32* %12
%30 = load i32, i32* %10
%31 = icmp sle i32 %29, %30
br i1 %31, label %32, label %62
32: ; preds = %28
%33 = load i32, i32* %12
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i32, i32* %22, i64 %34
%36 = load i32, i32* %35
%37 = icmp ne i32 %36, 0
br i1 %37, label %58, label %38
38: ; preds = %32
%39 = load i32, i32* %7
%40 = load i32, i32* %12
%41 = sdiv i32 %39, %40
%42 = call i32 @floor(i32 %41)
store i32 %42, i32* %11
%43 = load i32, i32* %12
store i32 %43, i32* %13
br label %44
44: ; preds = %54, %38
%45 = load i32, i32* %13
%46 = load i32, i32* %11
%47 = icmp sle i32 %45, %46
br i1 %47, label %48, label %57
48: ; preds = %44
%49 = load i32, i32* %12
%50 = load i32, i32* %13
%51 = mul nsw i32 %49, %50
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i32, i32* %22, i64 %52
store i32 1, i32* %53
br label %54
54: ; preds = %48
%55 = load i32, i32* %13
%56 = add nsw i32 %55, 1
store i32 %56, i32* %13
br label %44
57: ; preds = %44
br label %58
58: ; preds = %57, %32
br label %59
59: ; preds = %58
%60 = load i32, i32* %12
%61 = add nsw i32 %60, 1
store i32 %61, i32* %12
br label %28
62: ; preds = %28
%63 = call double (...) @clock()
%64 = load double, double* %6
%65 = fsub double %63, %64
%66 = load double, double* @CLOCKS_PER_SEC
%67 = fdiv double %65, %66
%68 = fmul double %67, 1.000000e+03
store double %68, double* %17
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
store i32 2, i32* %12
br label %70
70: ; preds = %100, %62
%71 = load i32, i32* %12
%72 = load i32, i32* %7
%73 = icmp sle i32 %71, %72
br i1 %73, label %74, label %103
74: ; preds = %70
%75 = load i32, i32* %12
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds i32, i32* %22, i64 %76
%78 = load i32, i32* %77
%79 = icmp ne i32 %78, 0
br i1 %79, label %87, label %80
80: ; preds = %74
%81 = load i32, i32* %12
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %81)
%83 = load i32, i32* %15
%84 = add nsw i32 %83, 1
store i32 %84, i32* %15
%85 = load i32, i32* %16
%86 = add nsw i32 %85, 1
store i32 %86, i32* %16
br label %87
87: ; preds = %80, %74
%88 = load i32, i32* %15
%89 = icmp eq i32 %88, 10
%90 = zext i1 %89 to i32
%91 = load i32, i32* %12
%92 = load i32, i32* %7
%93 = icmp eq i32 %91, %92
%94 = zext i1 %93 to i32
%95 = or i32 %90, %94
%96 = icmp ne i32 %95, 0
br i1 %96, label %97, label %99
97: ; preds = %87
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %15
br label %99
99: ; preds = %97, %87
br label %100
100: ; preds = %99
%101 = load i32, i32* %12
%102 = add nsw i32 %101, 1
store i32 %102, i32* %12
br label %70
103: ; preds = %70
%104 = load i32, i32* %16
%105 = load double, double* %17
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([85 x i8], [85 x i8]* @.str.3, i64 0, i64 0), i32 %104, double %105)
store i32 0, i32* %3
%107 = load i8*, i8** %8
%108 = load i32, i32* %3
ret i32 %108
}

LLVM IR (-O2):
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.1 = [5 x i8] c"%d, \00"
@.str.3 = [85 x i8] c"Se encontraron %d n\C3\BAmeros primos, y el tiempo transcurrido fue de %f milisegundos \0A\00"
@str = [34 x i8] c"Los primeros n\C3\BAmeros primos son:\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call double (...) @clock()
%4 = alloca [48615 x i32]
%5 = getelementptr inbounds [48615 x i32], [48615 x i32]* %4, i64 0, i64 0
%6 = tail call i32 @sqrt(i32 48615)
%7 = tail call i32 @floor(i32 %6)
%8 = call i32 @memset(i32* %5, i32 0, i32 48615)
%9 = icmp slt i32 %7, 2
br i1 %9, label %37, label %10
10: ; preds = %2
%11 = add nuw i32 %7, 1
%12 = zext i32 %11 to i64
br label %13
13: ; preds = %10, %34
%14 = phi i64 [ 2, %10 ], [ %35, %34 ]
%15 = getelementptr inbounds [48615 x i32], [48615 x i32]* %4, i64 0, i64 %14
%16 = load i32, i32* %15
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %34
18: ; preds = %13
%19 = trunc i64 %14 to i32
%20 = udiv i32 48615, %19
%21 = call i32 @floor(i32 %20)
%22 = sext i32 %21 to i64
%23 = icmp sgt i64 %14, %22
br i1 %23, label %34, label %24
24: ; preds = %18
%25 = add i32 %21, 1
%26 = zext i32 %25 to i64
br label %27
27: ; preds = %24, %27
%28 = phi i64 [ %14, %24 ], [ %32, %27 ]
%29 = mul i64 %28, %14
%30 = and i64 %29, 4294967295
%31 = getelementptr inbounds [48615 x i32], [48615 x i32]* %4, i64 0, i64 %30
store i32 1, i32* %31
%32 = add nuw nsw i64 %28, 1
%33 = icmp eq i64 %32, %26
br i1 %33, label %34, label %27
34: ; preds = %27, %18, %13
%35 = add nuw nsw i64 %14, 1
%36 = icmp eq i64 %35, %12
br i1 %36, label %37, label %13
37: ; preds = %34, %2
%38 = call double (...) @clock()
%39 = load double, double* @CLOCKS_PER_SEC
%40 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
br label %41
41: ; preds = %37, %61
%42 = phi i64 [ 2, %37 ], [ %63, %61 ]
%43 = phi i32 [ 0, %37 ], [ %55, %61 ]
%44 = phi i32 [ 0, %37 ], [ %62, %61 ]
%45 = getelementptr inbounds [48615 x i32], [48615 x i32]* %4, i64 0, i64 %42
%46 = load i32, i32* %45
%47 = icmp eq i32 %46, 0
br i1 %47, label %48, label %53
48: ; preds = %41
%49 = trunc i64 %42 to i32
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %49)
%51 = add nsw i32 %44, 1
%52 = add nsw i32 %43, 1
br label %53
53: ; preds = %48, %41
%54 = phi i32 [ %44, %41 ], [ %51, %48 ]
%55 = phi i32 [ %43, %41 ], [ %52, %48 ]
%56 = icmp eq i32 %54, 10
%57 = icmp eq i64 %42, 48615
%58 = or i1 %57, %56
br i1 %58, label %59, label %61
59: ; preds = %53
%60 = call i32 @putchar(i32 10)
br label %61
61: ; preds = %53, %59
%62 = phi i32 [ 0, %59 ], [ %54, %53 ]
%63 = add nuw nsw i64 %42, 1
%64 = icmp eq i64 %63, 48616
br i1 %64, label %65, label %41
65: ; preds = %61
%66 = fsub double %38, %3
%67 = fdiv double %66, %39
%68 = fmul double %67, 1.000000e+03
%69 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([85 x i8], [85 x i8]* @.str.3, i64 0, i64 0), i32 %55, double %68)
ret i32 0
}