#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 atoi(char *);
int find_max(int *, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char *argv[]) {
  int c;
  int fixed_array[12] = {0, 2, 12, 5, 7, 3, 19, 9, 1, 8, 15, 11};
  int *arg_array = NULL;
  if (argc == 1) {
    printf("max: %d\n", find_max(fixed_array, 12));
  } else {
    arg_array = (int *)malloc((argc - 1) * sizeof(int));
    for (c = 1; c < argc; c++) {
      arg_array[c - 2] = atoi(argv[c]);
    }
    printf("max: %d\n", find_max(arg_array, argc - 1));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xe8f(%rip),%rsi
mov    $0x30,%edx
call   1040 <memcpy@plt>
movq   $0x0,-0x58(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    11ae <main+0x5e>
lea    -0x50(%rbp),%rdi
mov    $0xc,%esi
call   1070 <find_max@plt>
mov    %eax,%esi
lea    0xe8c(%rip),%rdi
call   1030 <printf@plt>
jmp    1226 <main+0xd6>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x58(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1209 <main+0xb9>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1060 <atoi@plt>
mov    %eax,%edx
mov    -0x58(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11cc <main+0x7c>
mov    -0x58(%rbp),%rdi
mov    -0x8(%rbp),%esi
sub    $0x1,%esi
call   1070 <find_max@plt>
mov    %eax,%esi
lea    0xe0f(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
movaps 0xecb(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xeaf(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe93(%rip),%xmm0
movaps %xmm0,(%rsp)
cmp    $0x1,%edi
jne    1180 <main+0x40>
mov    %rsp,%rdi
mov    $0xc,%esi
jmp    11ce <main+0x8e>
mov    %rsi,%r12
mov    %edi,%r15d
lea    -0x1(%r15),%r14d
lea    -0x4(,%r15,4),%edi
ff
call   1040 <malloc@plt>
mov    %rax,%r13
cmp    $0x2,%r15d
jl     11c8 <main+0x88>
mov    %r15d,%ebx
add    $0xffffffffffffffff,%rbx
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    0x8(%r12,%rbp,8),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x4(%r13,%rbp,4)
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    11b0 <main+0x70>
mov    %r13,%rdi
mov    %r14d,%esi
call   1060 <find_max@plt>
lea    0xe56(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.fixed_array = [12 x i32] [i32 0, i32 2, i32 12, i32 5, i32 7, i32 3, i32 19, i32 9, i32 1, i32 8, i32 15, i32 11]
@.str = [9 x i8] c"max: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [12 x i32]
%8 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = bitcast [12 x i32]* %7 to i8*
store i32* null, i32** %8
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %16
12: ; preds = %2
%13 = getelementptr inbounds [12 x i32], [12 x i32]* %7, i64 0, i64 0
%14 = call i32 @find_max(i32* %13, i32 12)
%15 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %14)
br label %49
16: ; preds = %2
%17 = load i32, i32* %4
%18 = sub nsw i32 %17, 1
%19 = sext i32 %18 to i64
%20 = mul i64 %19, 4
%21 = trunc i64 %20 to i32
%22 = call i64 @malloc(i32 %21)
%23 = inttoptr i64 %22 to i32*
store i32* %23, i32** %8
store i32 1, i32* %6
br label %24
24: ; preds = %40, %16
%25 = load i32, i32* %6
%26 = load i32, i32* %4
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %43
28: ; preds = %24
%29 = load i8**, i8*** %5
%30 = load i32, i32* %6
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8*, i8** %29, i64 %31
%33 = load i8*, i8** %32
%34 = call i32 @atoi(i8* %33)
%35 = load i32*, i32** %8
%36 = load i32, i32* %6
%37 = sub nsw i32 %36, 2
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* %35, i64 %38
store i32 %34, i32* %39
br label %40
40: ; preds = %28
%41 = load i32, i32* %6
%42 = add nsw i32 %41, 1
store i32 %42, i32* %6
br label %24
43: ; preds = %24
%44 = load i32*, i32** %8
%45 = load i32, i32* %4
%46 = sub nsw i32 %45, 1
%47 = call i32 @find_max(i32* %44, i32 %46)
%48 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %47)
br label %49
49: ; preds = %43, %12
ret i32 0
}

LLVM IR (-O2):
@__const.main.fixed_array = [12 x i32] [i32 0, i32 2, i32 12, i32 5, i32 7, i32 3, i32 19, i32 9, i32 1, i32 8, i32 15, i32 11]
@.str = [9 x i8] c"max: %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [12 x i32]
%4 = bitcast [12 x i32]* %3 to i8*
%5 = icmp eq i32 %0, 1
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = getelementptr inbounds [12 x i32], [12 x i32]* %3, i64 0, i64 0
%8 = call i32 @find_max(i32* %7, i32 12)
%9 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %8)
br label %30
10: ; preds = %2
%11 = add nsw i32 %0, -1
%12 = shl i32 %11, 2
%13 = tail call i64 @malloc(i32 %12)
%14 = inttoptr i64 %13 to i32*
%15 = icmp sgt i32 %0, 1
br i1 %15, label %16, label %27
16: ; preds = %10
%17 = zext i32 %0 to i64
br label %18
18: ; preds = %16, %18
%19 = phi i64 [ 1, %16 ], [ %25, %18 ]
%20 = getelementptr inbounds i8*, i8** %1, i64 %19
%21 = load i8*, i8** %20
%22 = tail call i32 @atoi(i8* %21)
%23 = add nsw i64 %19, -2
%24 = getelementptr inbounds i32, i32* %14, i64 %23
store i32 %22, i32* %24
%25 = add nuw nsw i64 %19, 1
%26 = icmp eq i64 %25, %17
br i1 %26, label %27, label %18
27: ; preds = %18, %10
%28 = tail call i32 @find_max(i32* %14, i32 %11)
%29 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %27, %6
ret i32 0
}