#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*/ free(int *);
int *malloc(int);
int search(int *, int, int *);
int minCostClimbingStairs(int *cost, int costSize) {
  if (costSize <= 1) {
    return 0;
  }
  int *rec = malloc(costSize * sizeof(int));
  for (int i = 0; i < costSize; i++) {
    rec[i] = -1;
  }
  int min = search(cost, costSize, rec);
  free(rec);
  return min;
}


x86 assembly (clang, -O0):
<minCostClimbingStairs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jg     1155 <minCostClimbingStairs+0x25>
movl   $0x0,-0x4(%rbp)
jmp    11ba <minCostClimbingStairs+0x8a>
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1198 <minCostClimbingStairs+0x68>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movl   $0xffffffff,(%rax,%rcx,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    116f <minCostClimbingStairs+0x3f>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
call   1040 <search@plt>
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<minCostClimbingStairs>:
cmp    $0x2,%esi
jge    1148 <minCostClimbingStairs+0x8>
xor    %eax,%eax
ret
push   %r15
push   %r14
push   %rbx
mov    %esi,%ebx
mov    %rdi,%r14
lea    0x0(,%rbx,4),%edi
call   1060 <malloc@plt>
mov    %rax,%r15
mov    %ebx,%edx
shl    $0x2,%rdx
mov    %rax,%rdi
mov    $0xff,%esi
call   1050 <memset@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %r15,%rdx
call   1040 <search@plt>
mov    %eax,%ebx
mov    %r15,%rdi
call   1030 <free@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @minCostClimbingStairs(i32* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
%9 = load i32, i32* %5
%10 = icmp sle i32 %9, 1
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 0, i32* %3
br label %38
12: ; preds = %2
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = mul i64 %14, 4
%16 = trunc i64 %15 to i32
%17 = call i32* @malloc(i32 %16)
store i32* %17, i32** %6
store i32 0, i32* %7
br label %18
18: ; preds = %27, %12
%19 = load i32, i32* %7
%20 = load i32, i32* %5
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %30
22: ; preds = %18
%23 = load i32*, i32** %6
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i32, i32* %23, i64 %25
store i32 -1, i32* %26
br label %27
27: ; preds = %22
%28 = load i32, i32* %7
%29 = add nsw i32 %28, 1
store i32 %29, i32* %7
br label %18
30: ; preds = %18
%31 = load i32*, i32** %4
%32 = load i32, i32* %5
%33 = load i32*, i32** %6
%34 = call i32 @search(i32* %31, i32 %32, i32* %33)
store i32 %34, i32* %8
%35 = load i32*, i32** %6
%36 = call i32 @free(i32* %35)
%37 = load i32, i32* %8
store i32 %37, i32* %3
br label %38
38: ; preds = %30, %11
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
define i32 @minCostClimbingStairs(i32* %0, i32 %1) {
%3 = icmp slt i32 %1, 2
br i1 %3, label %12, label %4
4: ; preds = %2
%5 = shl i32 %1, 2
%6 = tail call i32* @malloc(i32 %5)
%7 = bitcast i32* %6 to i8*
%8 = zext i32 %1 to i64
%9 = shl nuw nsw i64 %8, 2
%10 = tail call i32 @search(i32* %0, i32 %1, i32* %6)
%11 = tail call i32 @free(i32* %6)
br label %12
12: ; preds = %2, %4
%13 = phi i32 [ %10, %4 ], [ 0, %2 ]
ret i32 %13
}