#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 EXIT_FAILURE;
int EXIT_SUCCESS;
size_t atoi(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ isPrimeNumber(size_t);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  size_t max, i;
  if (argc != 2) {
    fprintf(stderr, "prime_numbers [maximum_value]\n");
    return EXIT_FAILURE;
  }
  max = atoi(argv[1]);
  for (i = 1; i <= max; i++) {
    if (isPrimeNumber(i))
      fprintf(stdout, "%zu\n", i);
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1178 <main+0x48>
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
lea    0xea0(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e6a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11ef <main+0xbf>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %rax,-0x18(%rbp)
movq   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
ja     11e3 <main+0xb3>
mov    -0x20(%rbp),%rdi
call   1030 <isPrimeNumber@plt>
cmp    $0x0,%rax
je     11cd <main+0x9d>
mov    0x2e17(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xe59(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    11d2 <main+0xa2>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1191 <main+0x61>
mov    0x2dde(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
cmp    $0x2,%edi
jne    1199 <main+0x69>
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
mov    0x2e7a(%rip),%r12
test   %rax,%rax
je     11b7 <main+0x87>
mov    %rax,%r14
mov    $0x1,%ebx
mov    0x2e6e(%rip),%r13
lea    0xeb6(%rip),%r15
jmp    1179 <main+0x49>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    %r14,%rbx
ja     11b7 <main+0x87>
mov    %rbx,%rdi
call   1030 <isPrimeNumber@plt>
test   %rax,%rax
je     1170 <main+0x40>
mov    0x0(%r13),%edi
mov    %r15,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
jmp    1170 <main+0x40>
mov    0x2e40(%rip),%rax
mov    (%rax),%edi
lea    0xe57(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x2e21(%rip),%r12
mov    (%r12),%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [31 x i8] c"prime_numbers [maximum_value]\0A\00"
@EXIT_FAILURE = global i32 0
@stdout = global i32 0
@.str.1 = [5 x i8] c"%zu\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 2
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%13 = load i32, i32* @EXIT_FAILURE
store i32 %13, i32* %3
br label %37
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i64 @atoi(i8* %17)
store i64 %18, i64* %6
store i64 1, i64* %7
br label %19
19: ; preds = %32, %14
%20 = load i64, i64* %7
%21 = load i64, i64* %6
%22 = icmp ule i64 %20, %21
br i1 %22, label %23, label %35
23: ; preds = %19
%24 = load i64, i64* %7
%25 = call i64 @isPrimeNumber(i64 %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %31
27: ; preds = %23
%28 = load i32, i32* @stdout
%29 = load i64, i64* %7
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %29)
br label %31
31: ; preds = %27, %23
br label %32
32: ; preds = %31
%33 = load i64, i64* %7
%34 = add i64 %33, 1
store i64 %34, i64* %7
br label %19
35: ; preds = %19
%36 = load i32, i32* @EXIT_SUCCESS
store i32 %36, i32* %3
br label %37
37: ; preds = %35, %10
%38 = load i32, i32* %3
ret i32 %38
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [31 x i8] c"prime_numbers [maximum_value]\0A\00"
@EXIT_FAILURE = global i32 0
@stdout = global i32 0
@.str.1 = [5 x i8] c"%zu\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %22
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i64 @atoi(i8* %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %22, label %12
12: ; preds = %7, %19
%13 = phi i64 [ %20, %19 ], [ 1, %7 ]
%14 = tail call i64 @isPrimeNumber(i64 %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %12
%17 = load i32, i32* @stdout
%18 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %13)
br label %19
19: ; preds = %12, %16
%20 = add i64 %13, 1
%21 = icmp ugt i64 %20, %10
br i1 %21, label %22, label %12
22: ; preds = %19, %7, %4
%23 = phi i32* [ @EXIT_FAILURE, %4 ], [ @EXIT_SUCCESS, %7 ], [ @EXIT_SUCCESS, %19 ]
%24 = load i32, i32* %23
ret i32 %24
}