#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 main() {
  int i, j, nums[48616 + 1], x = 1;
  printf("The first 5000 prime numbers are:\n");
  for (i = 2; i <= 48616; i++) {
    if (nums[i] != 1) {
      printf("%d,", i);
      for (j = 2; (i * j) <= 48616; j++) {
        nums[i * j] = 1;
      }
    }
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2f7c0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x2f7b4(%rbp)
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x2,-0x8(%rbp)
cmpl   $0xbde8,-0x8(%rbp)
jg     11c4 <main+0xb4>
movslq -0x8(%rbp),%rax
cmpl   $0x1,-0x2f7b0(%rbp,%rax,4)
01
je     11b1 <main+0xa1>
mov    -0x8(%rbp),%esi
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x2,-0xc(%rbp)
mov    -0x8(%rbp),%eax
imul   -0xc(%rbp),%eax
cmp    $0xbde8,%eax
jg     11ac <main+0x9c>
mov    -0x8(%rbp),%eax
imul   -0xc(%rbp),%eax
cltq
movl   $0x1,-0x2f7b0(%rbp,%rax,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1178 <main+0x68>
jmp    11b1 <main+0xa1>
jmp    11b6 <main+0xa6>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1141 <main+0x31>
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x2f7c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2f7b0,%rsp
lea    0xebd(%rip),%rdi
call   1040 <puts@plt>
lea    0x10(%rsp),%r15
mov    $0x4,%r12d
mov    $0x2,%ebx
mov    $0x8,%r13d
lea    0xe97(%rip),%r14
jmp    1189 <main+0x59>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
add    $0x2,%r12
add    $0x8,%r15
add    $0x4,%r13
cmp    $0xbde9,%rbx
je     11c7 <main+0x97>
cmpl   $0x1,(%rsp,%rbx,4)
je     1170 <main+0x40>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0x5ef4,%rbx
ja     1170 <main+0x40>
mov    %r15,%rax
mov    %r12,%rcx
nopw   0x0(%rax,%rax,1)
movl   $0x1,(%rax)
add    %rbx,%rcx
add    %r13,%rax
cmp    $0xbde9,%rcx
jb     11b0 <main+0x80>
jmp    1170 <main+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x2f7b0,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [35 x i8] c"The first 5000 prime numbers are:\0A\00"
@.str.1 = [4 x i8] c"%d,\00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [48617 x i32]
%5 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %5
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
store i32 2, i32* %2
br label %7
7: ; preds = %35, %0
%8 = load i32, i32* %2
%9 = icmp sle i32 %8, 48616
br i1 %9, label %10, label %38
10: ; preds = %7
%11 = load i32, i32* %2
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [48617 x i32], [48617 x i32]* %4, i64 0, i64 %12
%14 = load i32, i32* %13
%15 = icmp ne i32 %14, 1
br i1 %15, label %16, label %34
16: ; preds = %10
%17 = load i32, i32* %2
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %17)
store i32 2, i32* %3
br label %19
19: ; preds = %30, %16
%20 = load i32, i32* %2
%21 = load i32, i32* %3
%22 = mul nsw i32 %20, %21
%23 = icmp sle i32 %22, 48616
br i1 %23, label %24, label %33
24: ; preds = %19
%25 = load i32, i32* %2
%26 = load i32, i32* %3
%27 = mul nsw i32 %25, %26
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [48617 x i32], [48617 x i32]* %4, i64 0, i64 %28
store i32 1, i32* %29
br label %30
30: ; preds = %24
%31 = load i32, i32* %3
%32 = add nsw i32 %31, 1
store i32 %32, i32* %3
br label %19
33: ; preds = %19
br label %34
34: ; preds = %33, %10
br label %35
35: ; preds = %34
%36 = load i32, i32* %2
%37 = add nsw i32 %36, 1
store i32 %37, i32* %2
br label %7
38: ; preds = %7
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%40 = load i32, i32* %1
ret i32 %40
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%d,\00"
@str = [34 x i8] c"The first 5000 prime numbers are:\00"
define i32 @main() {
%1 = alloca [48617 x i32]
%2 = bitcast [48617 x i32]* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
br label %4
4: ; preds = %0, %22
%5 = phi i64 [ 2, %0 ], [ %23, %22 ]
%6 = phi i64 [ 4, %0 ], [ %24, %22 ]
%7 = getelementptr inbounds [48617 x i32], [48617 x i32]* %1, i64 0, i64 %5
%8 = load i32, i32* %7
%9 = icmp eq i32 %8, 1
br i1 %9, label %22, label %10
10: ; preds = %4
%11 = trunc i64 %5 to i32
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = icmp ult i64 %5, 24309
br i1 %13, label %14, label %22
14: ; preds = %10, %14
%15 = phi i64 [ %18, %14 ], [ 2, %10 ]
%16 = phi i64 [ %20, %14 ], [ %6, %10 ]
%17 = getelementptr inbounds [48617 x i32], [48617 x i32]* %1, i64 0, i64 %16
store i32 1, i32* %17
%18 = add nuw nsw i64 %15, 1
%19 = mul nuw nsw i64 %18, %5
%20 = add nuw nsw i64 %16, %5
%21 = icmp ult i64 %19, 48617
br i1 %21, label %14, label %22
22: ; preds = %14, %10, %4
%23 = add nuw nsw i64 %5, 1
%24 = add nuw nsw i64 %6, 2
%25 = icmp eq i64 %23, 48617
br i1 %25, label %26, label %4
26: ; preds = %22
%27 = tail call i32 @putchar(i32 10)
ret i32 0
}