#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(int);
int maxProfit(int, int *, int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  int prices[] = {2, 3, 1, 5};
  if (!(maxProfit(1, prices, 0) == 0)) {
    printf("assert fail: %s\n", "0 -> 0");
    exit(-1);
  };
  if (!(maxProfit(1, prices, 1) == 0)) {
    printf("assert fail: %s\n", "1 -> 0");
    exit(-1);
  };
  if (!(maxProfit(1, prices, 4) == 4)) {
    printf("assert fail: %s\n", "1 4 -> 5");
    exit(-1);
  };
  if (!(maxProfit(2, prices, 4) == 5)) {
    printf("assert fail: %s\n", "2 4 -> 5");
    exit(-1);
  };
  if (!(maxProfit(3, prices, 4) == 5)) {
    printf("assert fail: %s\n", "3 4 -> 5");
    exit(-1);
  };
  if (!(maxProfit(4, prices, 4) == 5)) {
    printf("assert fail: %s\n", "4 4 -> 5");
    exit(-1);
  };
  printf("everything is fine!\n");
  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    0xeb3(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeb0(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    -0x20(%rbp),%rsi
mov    $0x1,%edi
xor    %edx,%edx
call   1040 <maxProfit@plt>
cmp    $0x0,%eax
je     1194 <main+0x64>
lea    0xe94(%rip),%rdi
lea    0xe9e(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
lea    -0x20(%rbp),%rsi
mov    $0x1,%edx
mov    %edx,%edi
call   1040 <maxProfit@plt>
cmp    $0x0,%eax
je     11cc <main+0x9c>
lea    0xe5c(%rip),%rdi
lea    0xe6d(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
lea    -0x20(%rbp),%rsi
mov    $0x1,%edi
mov    $0x4,%edx
call   1040 <maxProfit@plt>
cmp    $0x4,%eax
je     1207 <main+0xd7>
lea    0xe21(%rip),%rdi
lea    0xe39(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
lea    -0x20(%rbp),%rsi
mov    $0x2,%edi
mov    $0x4,%edx
call   1040 <maxProfit@plt>
cmp    $0x5,%eax
je     1242 <main+0x112>
lea    0xde6(%rip),%rdi
lea    0xe07(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
lea    -0x20(%rbp),%rsi
mov    $0x3,%edi
mov    $0x4,%edx
call   1040 <maxProfit@plt>
cmp    $0x5,%eax
je     127d <main+0x14d>
lea    0xdab(%rip),%rdi
lea    0xdd5(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
lea    -0x20(%rbp),%rsi
mov    $0x4,%edx
mov    %edx,%edi
call   1040 <maxProfit@plt>
cmp    $0x5,%eax
je     12b5 <main+0x185>
lea    0xd73(%rip),%rdi
lea    0xda6(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
lea    0xd97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
movaps 0xeb5(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rsi
mov    $0x1,%edi
xor    %edx,%edx
call   1050 <maxProfit@plt>
test   %eax,%eax
jne    11eb <main+0xab>
mov    %rsp,%rsi
mov    $0x1,%edi
mov    $0x1,%edx
call   1050 <maxProfit@plt>
test   %eax,%eax
jne    11fb <main+0xbb>
mov    %rsp,%rsi
mov    $0x1,%edi
mov    $0x4,%edx
call   1050 <maxProfit@plt>
cmp    $0x4,%eax
jne    120b <main+0xcb>
mov    %rsp,%rsi
mov    $0x2,%edi
mov    $0x4,%edx
call   1050 <maxProfit@plt>
cmp    $0x5,%eax
jne    121b <main+0xdb>
mov    %rsp,%rsi
mov    $0x3,%edi
mov    $0x4,%edx
call   1050 <maxProfit@plt>
cmp    $0x5,%eax
jne    122b <main+0xeb>
mov    %rsp,%rsi
mov    $0x4,%edi
mov    $0x4,%edx
call   1050 <maxProfit@plt>
cmp    $0x5,%eax
jne    123b <main+0xfb>
lea    0xe74(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret
lea    0xe1e(%rip),%rdi
lea    0xe28(%rip),%rsi
jmp    1249 <main+0x109>
lea    0xe0e(%rip),%rdi
lea    0xe1f(%rip),%rsi
jmp    1249 <main+0x109>
lea    0xdfe(%rip),%rdi
lea    0xe16(%rip),%rsi
jmp    1249 <main+0x109>
lea    0xdee(%rip),%rdi
lea    0xe0f(%rip),%rsi
jmp    1249 <main+0x109>
lea    0xdde(%rip),%rdi
lea    0xe08(%rip),%rsi
jmp    1249 <main+0x109>
lea    0xdce(%rip),%rdi
lea    0xe01(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@__const.main.prices = [4 x i32] [i32 2, i32 3, i32 1, i32 5]
@.str = [17 x i8] c"assert fail: %s\0A\00"
@.str.1 = [7 x i8] c"0 -> 0\00"
@.str.2 = [7 x i8] c"1 -> 0\00"
@.str.3 = [9 x i8] c"1 4 -> 5\00"
@.str.4 = [9 x i8] c"2 4 -> 5\00"
@.str.5 = [9 x i8] c"3 4 -> 5\00"
@.str.6 = [9 x i8] c"4 4 -> 5\00"
@.str.7 = [21 x i8] c"everything is fine!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [4 x i32]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = bitcast [4 x i32]* %6 to i8*
%8 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 0
%9 = call i32 @maxProfit(i32 1, i32* %8, i32 0)
%10 = icmp eq i32 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @exit(i32 -1)
unreachable
14: ; preds = %2
%15 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 0
%16 = call i32 @maxProfit(i32 1, i32* %15, i32 1)
%17 = icmp eq i32 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %14
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%20 = call i32 @exit(i32 -1)
unreachable
21: ; preds = %14
%22 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 0
%23 = call i32 @maxProfit(i32 1, i32* %22, i32 4)
%24 = icmp eq i32 %23, 4
br i1 %24, label %28, label %25
25: ; preds = %21
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%27 = call i32 @exit(i32 -1)
unreachable
28: ; preds = %21
%29 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 0
%30 = call i32 @maxProfit(i32 2, i32* %29, i32 4)
%31 = icmp eq i32 %30, 5
br i1 %31, label %35, label %32
32: ; preds = %28
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%34 = call i32 @exit(i32 -1)
unreachable
35: ; preds = %28
%36 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 0
%37 = call i32 @maxProfit(i32 3, i32* %36, i32 4)
%38 = icmp eq i32 %37, 5
br i1 %38, label %42, label %39
39: ; preds = %35
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%41 = call i32 @exit(i32 -1)
unreachable
42: ; preds = %35
%43 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 0
%44 = call i32 @maxProfit(i32 4, i32* %43, i32 4)
%45 = icmp eq i32 %44, 5
br i1 %45, label %49, label %46
46: ; preds = %42
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%48 = call i32 @exit(i32 -1)
unreachable
49: ; preds = %42
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@__const.main.prices = [4 x i32] [i32 2, i32 3, i32 1, i32 5]
@.str = [17 x i8] c"assert fail: %s\0A\00"
@.str.1 = [7 x i8] c"0 -> 0\00"
@.str.2 = [7 x i8] c"1 -> 0\00"
@.str.3 = [9 x i8] c"1 4 -> 5\00"
@.str.4 = [9 x i8] c"2 4 -> 5\00"
@.str.5 = [9 x i8] c"3 4 -> 5\00"
@.str.6 = [9 x i8] c"4 4 -> 5\00"
@str = [20 x i8] c"everything is fine!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [4 x i32]
%4 = bitcast [4 x i32]* %3 to i8*
%5 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 0
%6 = call i32 @maxProfit(i32 1, i32* %5, i32 0)
%7 = icmp eq i32 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @exit(i32 -1)
unreachable
11: ; preds = %2
%12 = call i32 @maxProfit(i32 1, i32* %5, i32 1)
%13 = icmp eq i32 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %11
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 @exit(i32 -1)
unreachable
17: ; preds = %11
%18 = call i32 @maxProfit(i32 1, i32* %5, i32 4)
%19 = icmp eq i32 %18, 4
br i1 %19, label %23, label %20
20: ; preds = %17
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%22 = call i32 @exit(i32 -1)
unreachable
23: ; preds = %17
%24 = call i32 @maxProfit(i32 2, i32* %5, i32 4)
%25 = icmp eq i32 %24, 5
br i1 %25, label %29, label %26
26: ; preds = %23
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%28 = call i32 @exit(i32 -1)
unreachable
29: ; preds = %23
%30 = call i32 @maxProfit(i32 3, i32* %5, i32 4)
%31 = icmp eq i32 %30, 5
br i1 %31, label %35, label %32
32: ; preds = %29
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%34 = call i32 @exit(i32 -1)
unreachable
35: ; preds = %29
%36 = call i32 @maxProfit(i32 4, i32* %5, i32 4)
%37 = icmp eq i32 %36, 5
br i1 %37, label %41, label %38
38: ; preds = %35
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%40 = call i32 @exit(i32 -1)
unreachable
41: ; preds = %35
%42 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
ret i32 0
}