#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*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int atoi(char *);
int *create_array(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  int *myarr = NULL;
  int *tmp = NULL;
  int sz;
  if (argc != 2) {
    fprintf(stderr, "Usage: %s <array size>\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  sz = atoi(argv[1]);
  myarr = create_array(sz);
  for (tmp = myarr; tmp < (myarr + sz); tmp++)
    printf("%d\n", *tmp);
  free(myarr);
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11ba <main+0x5a>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe59(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
call   1080 <create_array@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
movslq -0x24(%rbp),%rdx
shl    $0x2,%rdx
add    %rdx,%rcx
cmp    %rcx,%rax
jae    121d <main+0xbd>
mov    -0x20(%rbp),%rax
mov    (%rax),%esi
lea    0xe11(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x20(%rbp)
jmp    11de <main+0x7e>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    0x2da3(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    11d0 <main+0x70>
mov    0x8(%rsi),%rdi
call   1060 <atoi@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1080 <create_array@plt>
mov    %rax,%r14
test   %ebx,%ebx
jle    11b3 <main+0x53>
movslq %ebx,%rax
lea    (%r14,%rax,4),%r12
lea    0xe84(%rip),%r15
mov    %r14,%rbx
nopw   0x0(%rax,%rax,1)
mov    (%rbx),%esi
mov    %r15,%rdi
call   1040 <printf@plt>
add    $0x4,%rbx
cmp    %r12,%rbx
jb     11a0 <main+0x40>
mov    %r14,%rdi
call   1030 <free@plt>
mov    0x2e0e(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xe1d(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2de9(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [24 x i8] c"Usage: %s <array size>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [4 x i8] c"%d\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 i32*
%7 = alloca i32*
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32* null, i32** %6
store i32* null, i32** %7
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %19
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = load i32, i32* @EXIT_FAILURE
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32 @atoi(i8* %22)
store i32 %23, i32* %8
%24 = load i32, i32* %8
%25 = call i32* @create_array(i32 %24)
store i32* %25, i32** %6
%26 = load i32*, i32** %6
store i32* %26, i32** %7
br label %27
27: ; preds = %38, %19
%28 = load i32*, i32** %7
%29 = load i32*, i32** %6
%30 = load i32, i32* %8
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %29, i64 %31
%33 = icmp ult i32* %28, %32
br i1 %33, label %34, label %41
34: ; preds = %27
%35 = load i32*, i32** %7
%36 = load i32, i32* %35
%37 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %36)
br label %38
38: ; preds = %34
%39 = load i32*, i32** %7
%40 = getelementptr inbounds i32, i32* %39, i32 1
store i32* %40, i32** %7
br label %27
41: ; preds = %27
%42 = load i32*, i32** %6
%43 = call i32 @free(i32* %42)
%44 = load i32, i32* @EXIT_SUCCESS
ret i32 %44
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [24 x i8] c"Usage: %s <array size>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [4 x i8] c"%d\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 %10, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = load i32, i32* @EXIT_FAILURE
%9 = tail call i32 @exit(i32 %8)
unreachable
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32 @atoi(i8* %12)
%14 = tail call i32* @create_array(i32 %13)
%15 = sext i32 %13 to i64
%16 = getelementptr inbounds i32, i32* %14, i64 %15
%17 = icmp sgt i32 %13, 0
br i1 %17, label %18, label %24
18: ; preds = %10, %18
%19 = phi i32* [ %22, %18 ], [ %14, %10 ]
%20 = load i32, i32* %19
%21 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %20)
%22 = getelementptr inbounds i32, i32* %19, i64 1
%23 = icmp ult i32* %22, %16
br i1 %23, label %18, label %24
24: ; preds = %18, %10
%25 = tail call i32 @free(i32* %14)
%26 = load i32, i32* @EXIT_SUCCESS
ret i32 %26
}