#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 lengthOfLIS(int *, int);
int *malloc(int);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char **argv) {
  int i;
  int *nums = malloc((argc - 1) * sizeof(int));
  for (i = 0; i < argc - 1; i++) {
    nums[i] = atoi(argv[i + 1]);
  }
  printf("%d\n", lengthOfLIS(nums, argc - 1));
  return 0;
}


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)
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11b6 <main+0x76>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <atoi@plt>
mov    %eax,%edx
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1174 <main+0x34>
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%esi
sub    $0x1,%esi
call   1060 <lengthOfLIS@plt>
mov    %eax,%esi
lea    0xe32(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
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     118b <main+0x4b>
mov    %r14d,%r15d
xor    %ebp,%ebp
lea    0x1(%rbp),%rbx
mov    0x8(%r12,%rbp,8),%rdi
call   1050 <atoi@plt>
mov    %eax,0x0(%r13,%rbp,4)
mov    %rbx,%rbp
cmp    %rbx,%r15
jne    1170 <main+0x30>
mov    %r13,%rdi
mov    %r14d,%esi
call   1060 <lengthOfLIS@plt>
lea    0xe63(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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