#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 /*<<< orphan*/ create_array(int **, 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]);
  create_array(&myarr, 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),%esi
lea    -0x18(%rbp),%rdi
call   1080 <create_array@plt>
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   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
movq   $0x0,0x8(%rsp)
cmp    $0x2,%edi
jne    11d8 <main+0x78>
mov    0x8(%rsi),%rdi
call   1060 <atoi@plt>
mov    %eax,%ebp
lea    0x8(%rsp),%rdi
mov    %eax,%esi
call   1080 <create_array@plt>
mov    0x8(%rsp),%rbx
test   %ebp,%ebp
jle    11be <main+0x5e>
movslq %ebp,%rbp
lea    0xe78(%rip),%r14
mov    (%rbx),%esi
mov    %r14,%rdi
call   1040 <printf@plt>
add    $0x4,%rbx
mov    0x8(%rsp),%rdi
lea    (%rdi,%rbp,4),%rax
cmp    %rax,%rbx
jb     11a0 <main+0x40>
jmp    11c1 <main+0x61>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x2e03(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xe15(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2de1(%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** %6, i32 %24)
%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 = alloca i32*
%4 = bitcast i32** %3 to i8*
store i32* null, i32** %3
%5 = icmp eq i32 %0, 2
br i1 %5, label %12, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = tail call i32 @atoi(i8* %14)
%16 = call i32 @create_array(i32** %3, i32 %15)
%17 = load i32*, i32** %3
%18 = sext i32 %15 to i64
%19 = icmp sgt i32 %15, 0
br i1 %19, label %20, label %28
20: ; preds = %12, %20
%21 = phi i32* [ %24, %20 ], [ %17, %12 ]
%22 = load i32, i32* %21
%23 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %22)
%24 = getelementptr inbounds i32, i32* %21, i64 1
%25 = load i32*, i32** %3
%26 = getelementptr inbounds i32, i32* %25, i64 %18
%27 = icmp ult i32* %24, %26
br i1 %27, label %20, label %28
28: ; preds = %20, %12
%29 = phi i32* [ %17, %12 ], [ %25, %20 ]
%30 = call i32 @free(i32* %29)
%31 = load i32, i32* @EXIT_SUCCESS
ret i32 %31
}