#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 primes[50];
  int pc = 1, m = 3, k;
  printf("\n The first %d prime numbers are:\n", 50);
  primes[0] = 2;
  while (pc < 50) {
    k = 0;
    while (primes[k] * primes[k] <= m)
      if (m % primes[k] == 0) {
        m += 2;
        k = 1;
      } else
        k++;
    primes[pc++] = m;
    m += 2;
  }
  for (k = 0; k < pc; k++)
    printf("%4d", primes[k]);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0xd4(%rbp)
movl   $0x3,-0xd8(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x32,%esi
call   1030 <printf@plt>
movl   $0x2,-0xd0(%rbp)
cmpl   $0x32,-0xd4(%rbp)
jge    1215 <main+0x105>
movl   $0x0,-0xdc(%rbp)
movslq -0xdc(%rbp),%rax
mov    -0xd0(%rbp,%rax,4),%eax
movslq -0xdc(%rbp),%rcx
imul   -0xd0(%rbp,%rcx,4),%eax
ff
cmp    -0xd8(%rbp),%eax
jg     11e1 <main+0xd1>
mov    -0xd8(%rbp),%eax
movslq -0xdc(%rbp),%rcx
cltd
idivl  -0xd0(%rbp,%rcx,4)
cmp    $0x0,%edx
jne    11cd <main+0xbd>
mov    -0xd8(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xd8(%rbp)
movl   $0x1,-0xdc(%rbp)
jmp    11dc <main+0xcc>
mov    -0xdc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xdc(%rbp)
jmp    1168 <main+0x58>
mov    -0xd8(%rbp),%ecx
mov    -0xd4(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0xd4(%rbp)
cltq
mov    %ecx,-0xd0(%rbp,%rax,4)
mov    -0xd8(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xd8(%rbp)
jmp    1151 <main+0x41>
movl   $0x0,-0xdc(%rbp)
mov    -0xdc(%rbp),%eax
cmp    -0xd4(%rbp),%eax
jge    125f <main+0x14f>
movslq -0xdc(%rbp),%rax
mov    -0xd0(%rbp,%rax,4),%esi
lea    0xddd(%rip),%rdi
call   1030 <printf@plt>
mov    -0xdc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xdc(%rbp)
jmp    121f <main+0x10f>
mov    -0x4(%rbp),%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0xc8,%rsp
lea    0xedf(%rip),%rdi
mov    $0x32,%esi
call   1030 <printf@plt>
movl   $0x2,(%rsp)
mov    $0x3,%ecx
mov    $0x1,%r8d
mov    $0x1,%edi
jmp    1165 <main+0x55>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ecx,%eax
mov    %eax,(%rsp,%r8,4)
add    $0x1,%r8
add    $0x2,%eax
mov    %eax,%ecx
cmp    $0x32,%r8
je     11a6 <main+0x96>
cmp    $0x4,%ecx
jl     1150 <main+0x40>
xor    %ebx,%ebx
mov    $0x2,%esi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ecx,%eax
cltd
idiv   %esi
lea    0x2(%rcx),%eax
add    $0x1,%ebx
test   %edx,%edx
cmovne %ecx,%eax
cmove  %edi,%ebx
movslq %ebx,%rcx
mov    (%rsp,%rcx,4),%esi
mov    %esi,%edx
imul   %esi,%edx
mov    %eax,%ecx
cmp    %eax,%edx
jle    1180 <main+0x70>
jmp    1152 <main+0x42>
lea    0xe76(%rip),%r14
mov    %r14,%rdi
mov    $0x2,%esi
call   1030 <printf@plt>
mov    $0x1,%ebx
nop
mov    (%rsp,%rbx,4),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    $0x32,%rbx
jne    11c0 <main+0xb0>
xor    %eax,%eax
add    $0xc8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [35 x i8] c"\0A The first %d prime numbers are:\0A\00"
@.str.1 = [4 x i8] c"%4d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [50 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %3
store i32 3, i32* %4
%6 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 50)
%7 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 0
store i32 2, i32* %7
br label %8
8: ; preds = %39, %0
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 50
br i1 %10, label %11, label %47
11: ; preds = %8
store i32 0, i32* %5
br label %12
12: ; preds = %38, %11
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %14
%16 = load i32, i32* %15
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %18
%20 = load i32, i32* %19
%21 = mul nsw i32 %16, %20
%22 = load i32, i32* %4
%23 = icmp sle i32 %21, %22
br i1 %23, label %24, label %39
24: ; preds = %12
%25 = load i32, i32* %4
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %27
%29 = load i32, i32* %28
%30 = srem i32 %25, %29
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %24
%33 = load i32, i32* %4
%34 = add nsw i32 %33, 2
store i32 %34, i32* %4
store i32 1, i32* %5
br label %38
35: ; preds = %24
%36 = load i32, i32* %5
%37 = add nsw i32 %36, 1
store i32 %37, i32* %5
br label %38
38: ; preds = %35, %32
br label %12
39: ; preds = %12
%40 = load i32, i32* %4
%41 = load i32, i32* %3
%42 = add nsw i32 %41, 1
store i32 %42, i32* %3
%43 = sext i32 %41 to i64
%44 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %43
store i32 %40, i32* %44
%45 = load i32, i32* %4
%46 = add nsw i32 %45, 2
store i32 %46, i32* %4
br label %8
47: ; preds = %8
store i32 0, i32* %5
br label %48
48: ; preds = %58, %47
%49 = load i32, i32* %5
%50 = load i32, i32* %3
%51 = icmp slt i32 %49, %50
br i1 %51, label %52, label %61
52: ; preds = %48
%53 = load i32, i32* %5
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %54
%56 = load i32, i32* %55
%57 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %56)
br label %58
58: ; preds = %52
%59 = load i32, i32* %5
%60 = add nsw i32 %59, 1
store i32 %60, i32* %5
br label %48
61: ; preds = %48
%62 = load i32, i32* %1
ret i32 %62
}

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