#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 */
typedef int /*<<< orphan*/ array3;
typedef int /*<<< orphan*/ array2;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int find_max_profit_by_cutting_a_rod_v1(int *, int, int);
int find_max_profit_by_cutting_a_rod_v2(int *, int, int);
int main() {
  int array2[] = {0, 1, 5, 8, 9, 10, 17, 17, 20};
  int len2 = sizeof(array2) / sizeof(int);
  int rod_length2 = 8;
  int max_profit2 = 22;
  assert(max_profit2 ==
         find_max_profit_by_cutting_a_rod_v1(array2, len2, rod_length2));
  assert(max_profit2 ==
         find_max_profit_by_cutting_a_rod_v2(array2, len2, rod_length2));
  int array3[] = {0, 3, 5, 8, 9, 10, 17, 17, 20};
  int len3 = sizeof(array3) / sizeof(int);
  int rod_length3 = 8;
  int max_profit3 = 24;
  assert(max_profit3 ==
         find_max_profit_by_cutting_a_rod_v1(array3, len3, rod_length3));
  assert(max_profit3 ==
         find_max_profit_by_cutting_a_rod_v2(array3, len3, rod_length3));
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xea3(%rip),%rsi
mov    $0x24,%edx
call   1050 <memcpy@plt>
movl   $0x9,-0x34(%rbp)
movl   $0x8,-0x38(%rbp)
movl   $0x16,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    %eax,-0x7c(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%esi
mov    -0x38(%rbp),%edx
call   1030 <find_max_profit_by_cutting_a_rod_v1@plt>
mov    %eax,%ecx
mov    -0x7c(%rbp),%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x78(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%esi
mov    -0x38(%rbp),%edx
call   1060 <find_max_profit_by_cutting_a_rod_v2@plt>
mov    %eax,%ecx
mov    -0x78(%rbp),%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    -0x60(%rbp),%rdi
lea    0xe57(%rip),%rsi
mov    $0x24,%edx
call   1050 <memcpy@plt>
movl   $0x9,-0x64(%rbp)
movl   $0x8,-0x68(%rbp)
movl   $0x18,-0x6c(%rbp)
mov    -0x6c(%rbp),%eax
mov    %eax,-0x74(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0x64(%rbp),%esi
mov    -0x68(%rbp),%edx
call   1030 <find_max_profit_by_cutting_a_rod_v1@plt>
mov    %eax,%ecx
mov    -0x74(%rbp),%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x6c(%rbp),%eax
mov    %eax,-0x70(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0x64(%rbp),%esi
mov    -0x68(%rbp),%edx
call   1060 <find_max_profit_by_cutting_a_rod_v2@plt>
mov    %eax,%ecx
mov    -0x70(%rbp),%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x60,%rsp
mov    0xee5(%rip),%eax
mov    %eax,0x50(%rsp)
movaps 0xeca(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xeae(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x9,%esi
mov    $0x8,%edx
call   1030 <find_max_profit_by_cutting_a_rod_v1@plt>
xor    %edi,%edi
cmp    $0x16,%eax
sete   %dil
call   1040 <assert@plt>
mov    %rbx,%rdi
mov    $0x9,%esi
mov    $0x8,%edx
call   1050 <find_max_profit_by_cutting_a_rod_v2@plt>
xor    %edi,%edi
cmp    $0x16,%eax
sete   %dil
call   1040 <assert@plt>
mov    0xeae(%rip),%eax
mov    %eax,0x20(%rsp)
movaps 0xe93(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe77(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x9,%esi
mov    $0x8,%edx
call   1030 <find_max_profit_by_cutting_a_rod_v1@plt>
xor    %edi,%edi
cmp    $0x18,%eax
sete   %dil
call   1040 <assert@plt>
mov    %rbx,%rdi
mov    $0x9,%esi
mov    $0x8,%edx
call   1050 <find_max_profit_by_cutting_a_rod_v2@plt>
xor    %edi,%edi
cmp    $0x18,%eax
sete   %dil
call   1040 <assert@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.array2 = [9 x i32] [i32 0, i32 1, i32 5, i32 8, i32 9, i32 10, i32 17, i32 17, i32 20]
@__const.main.array3 = [9 x i32] [i32 0, i32 3, i32 5, i32 8, i32 9, i32 10, i32 17, i32 17, i32 20]
define i32 @main() {
%1 = alloca i32
%2 = alloca [9 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [9 x i32]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
%10 = bitcast [9 x i32]* %2 to i8*
store i32 9, i32* %3
store i32 8, i32* %4
store i32 22, i32* %5
%11 = load i32, i32* %5
%12 = getelementptr inbounds [9 x i32], [9 x i32]* %2, i64 0, i64 0
%13 = load i32, i32* %3
%14 = load i32, i32* %4
%15 = call i32 @find_max_profit_by_cutting_a_rod_v1(i32* %12, i32 %13, i32 %14)
%16 = icmp eq i32 %11, %15
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = load i32, i32* %5
%20 = getelementptr inbounds [9 x i32], [9 x i32]* %2, i64 0, i64 0
%21 = load i32, i32* %3
%22 = load i32, i32* %4
%23 = call i32 @find_max_profit_by_cutting_a_rod_v2(i32* %20, i32 %21, i32 %22)
%24 = icmp eq i32 %19, %23
%25 = zext i1 %24 to i32
%26 = call i32 @assert(i32 %25)
%27 = bitcast [9 x i32]* %6 to i8*
store i32 9, i32* %7
store i32 8, i32* %8
store i32 24, i32* %9
%28 = load i32, i32* %9
%29 = getelementptr inbounds [9 x i32], [9 x i32]* %6, i64 0, i64 0
%30 = load i32, i32* %7
%31 = load i32, i32* %8
%32 = call i32 @find_max_profit_by_cutting_a_rod_v1(i32* %29, i32 %30, i32 %31)
%33 = icmp eq i32 %28, %32
%34 = zext i1 %33 to i32
%35 = call i32 @assert(i32 %34)
%36 = load i32, i32* %9
%37 = getelementptr inbounds [9 x i32], [9 x i32]* %6, i64 0, i64 0
%38 = load i32, i32* %7
%39 = load i32, i32* %8
%40 = call i32 @find_max_profit_by_cutting_a_rod_v2(i32* %37, i32 %38, i32 %39)
%41 = icmp eq i32 %36, %40
%42 = zext i1 %41 to i32
%43 = call i32 @assert(i32 %42)
ret i32 0
}

LLVM IR (-O2):
@__const.main.array2 = [9 x i32] [i32 0, i32 1, i32 5, i32 8, i32 9, i32 10, i32 17, i32 17, i32 20]
@__const.main.array3 = [9 x i32] [i32 0, i32 3, i32 5, i32 8, i32 9, i32 10, i32 17, i32 17, i32 20]
define i32 @main() {
%1 = alloca [9 x i32]
%2 = alloca [9 x i32]
%3 = bitcast [9 x i32]* %1 to i8*
%4 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 0, i64 0
%5 = call i32 @find_max_profit_by_cutting_a_rod_v1(i32* %4, i32 9, i32 8)
%6 = icmp eq i32 %5, 22
%7 = zext i1 %6 to i32
%8 = call i32 @assert(i32 %7)
%9 = call i32 @find_max_profit_by_cutting_a_rod_v2(i32* %4, i32 9, i32 8)
%10 = icmp eq i32 %9, 22
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = bitcast [9 x i32]* %2 to i8*
%14 = getelementptr inbounds [9 x i32], [9 x i32]* %2, i64 0, i64 0
%15 = call i32 @find_max_profit_by_cutting_a_rod_v1(i32* %14, i32 9, i32 8)
%16 = icmp eq i32 %15, 24
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = call i32 @find_max_profit_by_cutting_a_rod_v2(i32* %14, i32 9, i32 8)
%20 = icmp eq i32 %19, 24
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
ret i32 0
}