#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 /*<<< orphan*/ sieve(int *, int);
int main(int argc, char **argv) {
  int i;
  int v[100];
  printf("C - Print all primes up to %d\n", 100);
  sieve(v, 100);
  for (i = 0; i < 100; i++) {
    if (v[i] == 1)
      printf("%d ", i);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xec0(%rip),%rdi
mov    $0x64,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x1b0(%rbp),%rdi
mov    $0x64,%esi
call   1040 <sieve@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x64,-0x14(%rbp)
jge    11a4 <main+0x84>
movslq -0x14(%rbp),%rax
cmpl   $0x1,-0x1b0(%rbp,%rax,4)
01
jne    1191 <main+0x71>
mov    -0x14(%rbp),%esi
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1196 <main+0x76>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1164 <main+0x44>
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x198,%rsp
lea    0xebf(%rip),%rdi
mov    $0x64,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rsp,%rdi
mov    $0x64,%esi
call   1050 <sieve@plt>
lea    0xebe(%rip),%r14
xor    %ebx,%ebx
jmp    117a <main+0x4a>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%rbx
cmp    $0x64,%rbx
je     118e <main+0x5e>
cmpl   $0x1,(%rsp,%rbx,4)
jne    1170 <main+0x40>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1170 <main+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x198,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [31 x i8] c"C - Print all primes up to %d\0A\00"
@.str.1 = [4 x i8] c"%d \00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [100 x i32]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 100)
%9 = getelementptr inbounds [100 x i32], [100 x i32]* %7, i64 0, i64 0
%10 = call i32 @sieve(i32* %9, i32 100)
store i32 0, i32* %6
br label %11
11: ; preds = %24, %2
%12 = load i32, i32* %6
%13 = icmp slt i32 %12, 100
br i1 %13, label %14, label %27
14: ; preds = %11
%15 = load i32, i32* %6
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [100 x i32], [100 x i32]* %7, i64 0, i64 %16
%18 = load i32, i32* %17
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %23
20: ; preds = %14
%21 = load i32, i32* %6
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %21)
br label %23
23: ; preds = %20, %14
br label %24
24: ; preds = %23
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 1
store i32 %26, i32* %6
br label %11
27: ; preds = %11
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [31 x i8] c"C - Print all primes up to %d\0A\00"
@.str.1 = [4 x i8] c"%d \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [100 x i32]
%4 = bitcast [100 x i32]* %3 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 100)
%6 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 0
%7 = call i32 @sieve(i32* %6, i32 100)
br label %8
8: ; preds = %2, %16
%9 = phi i64 [ 0, %2 ], [ %17, %16 ]
%10 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %9
%11 = load i32, i32* %10
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %16
13: ; preds = %8
%14 = trunc i64 %9 to i32
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %14)
br label %16
16: ; preds = %8, %13
%17 = add nuw nsw i64 %9, 1
%18 = icmp eq i64 %17, 100
br i1 %18, label %19, label %8
19: ; preds = %16
%20 = call i32 @putchar(i32 10)
ret i32 0
}