int get_max_product_cuttng_a_rod_v1(int length) {
  int sub_len, max_product, temp_product;
  if (length <= 0) {
    return (0);
  }
  if (length == 1) {
    return (1);
  }
  max_product = 0;
  for (sub_len = 1; sub_len < length; ++sub_len) {
    temp_product = get_max_product_cuttng_a_rod_v1(sub_len) *
                   get_max_product_cuttng_a_rod_v1(length - sub_len);
    if (temp_product > max_product) {
      max_product = temp_product;
    }
  }
  return (max_product);
}


x86 assembly (clang, -O0):
<get_max_product_cuttng_a_rod_v1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jg     1131 <get_max_product_cuttng_a_rod_v1+0x21>
movl   $0x0,-0x4(%rbp)
jmp    11ad <get_max_product_cuttng_a_rod_v1+0x9d>
cmpl   $0x1,-0x8(%rbp)
jne    1147 <get_max_product_cuttng_a_rod_v1+0x37>
movl   $0x1,-0x4(%rbp)
jmp    11ad <get_max_product_cuttng_a_rod_v1+0x9d>
movl   $0x0,-0x10(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11a7 <get_max_product_cuttng_a_rod_v1+0x97>
mov    -0xc(%rbp),%edi
call   1030 <get_max_product_cuttng_a_rod_v1@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
sub    -0xc(%rbp),%edi
call   1030 <get_max_product_cuttng_a_rod_v1@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    1194 <get_max_product_cuttng_a_rod_v1+0x84>
mov    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    1199 <get_max_product_cuttng_a_rod_v1+0x89>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1155 <get_max_product_cuttng_a_rod_v1+0x45>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_max_product_cuttng_a_rod_v1>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %edi,%edi
jle    1166 <get_max_product_cuttng_a_rod_v1+0x56>
mov    %edi,%r14d
mov    $0x1,%ebp
cmp    $0x1,%edi
je     1168 <get_max_product_cuttng_a_rod_v1+0x58>
add    $0xffffffff,%r14d
mov    $0x1,%ebx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebx,%edi
call   1030 <get_max_product_cuttng_a_rod_v1@plt>
mov    %eax,%r15d
mov    %r14d,%edi
call   1030 <get_max_product_cuttng_a_rod_v1@plt>
imul   %r15d,%eax
cmp    %ebp,%eax
cmovg  %eax,%ebp
add    $0x1,%ebx
add    $0xffffffff,%r14d
jne    1140 <get_max_product_cuttng_a_rod_v1+0x30>
jmp    1168 <get_max_product_cuttng_a_rod_v1+0x58>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @get_max_product_cuttng_a_rod_v1(i32 %0) {
%2 = icmp slt i32 %0, 1
br i1 %2, label %16, label %3
3: ; preds = %1
%4 = icmp eq i32 %0, 1
br i1 %4, label %16, label %5
5: ; preds = %3, %5
%6 = phi i32 [ %13, %5 ], [ 0, %3 ]
%7 = phi i32 [ %14, %5 ], [ 1, %3 ]
%8 = tail call i32 @get_max_product_cuttng_a_rod_v1(i32 %7)
%9 = sub nsw i32 %0, %7
%10 = tail call i32 @get_max_product_cuttng_a_rod_v1(i32 %9)
%11 = mul nsw i32 %10, %8
%12 = icmp sgt i32 %11, %6
%13 = select i1 %12, i32 %11, i32 %6
%14 = add nuw nsw i32 %7, 1
%15 = icmp eq i32 %14, %0
br i1 %15, label %16, label %5
16: ; preds = %5, %3, %1
%17 = phi i32 [ 0, %1 ], [ 1, %3 ], [ %13, %5 ]
ret i32 %17
}