#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 MemoizedCutRod(double *, int, double *, int *);
int /*<<< orphan*/ printf(char *, double);
test_BottomUpCutRod() {
  int n = 10;
  double p[10] = {1, 5, 8, 9, 10, 17, 17, 20, 24, 30};
  double rn = 0;
  int s[10] = {0};
  int ret = 0;
  ret = MemoizedCutRod(p, n, &rn, s);
  if (ret) {
    printf("MemoizedCutMod error %d\n", ret);
  }
  printf("rn=%lf\n", rn);
  return 0;
}


x86 assembly (clang, -O0):
<test_BottomUpCutRod>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0xa,-0x4(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xea3(%rip),%rsi
mov    $0x50,%edx
call   1050 <memcpy@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x68(%rbp)
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1040 <memset@plt>
movl   $0x0,-0x94(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0x4(%rbp),%esi
lea    -0x90(%rbp),%rcx
lea    -0x68(%rbp),%rdx
call   1060 <MemoizedCutRod@plt>
mov    %eax,-0x94(%rbp)
cmpl   $0x0,-0x94(%rbp)
je     11ca <test_BottomUpCutRod+0x8a>
cvtsi2sdl -0x94(%rbp),%xmm0
ff
lea    0xe8b(%rip),%rdi
call   1030 <printf@plt>
movsd  -0x68(%rbp),%xmm0
lea    0xe93(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_BottomUpCutRod>:
sub    $0x98,%rsp
movaps 0xf12(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movaps 0xef3(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xed7(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xebb(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movapd 0xe9e(%rip),%xmm0
movapd %xmm0,0x40(%rsp)
movq   $0x0,0x8(%rsp)
xorpd  %xmm0,%xmm0
movapd %xmm0,0x20(%rsp)
movapd %xmm0,0x10(%rsp)
movq   $0x0,0x30(%rsp)
lea    0x40(%rsp),%rdi
lea    0x8(%rsp),%rdx
lea    0x10(%rsp),%rcx
mov    $0xa,%esi
call   1040 <MemoizedCutRod@plt>
test   %eax,%eax
je     11ba <test_BottomUpCutRod+0x9a>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
lea    0xe9b(%rip),%rdi
call   1030 <printf@plt>
movsd  0x8(%rsp),%xmm0
lea    0xea2(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x98,%rsp
ret

LLVM IR (-O0):
@__const.test_BottomUpCutRod.p = [10 x double] [double 1.000000e+00, double 5.000000e+00, double 8.000000e+00, double 9.000000e+00, double 1.000000e+01, double 1.700000e+01, double 1.700000e+01, double 2.000000e+01, double 2.400000e+01, double 3.000000e+01]
@.str = [25 x i8] c"MemoizedCutMod error %d\0A\00"
@.str.1 = [8 x i8] c"rn=%lf\0A\00"
define i32 @test_BottomUpCutRod() {
%1 = alloca i32
%2 = alloca [10 x double]
%3 = alloca double
%4 = alloca [10 x i32]
%5 = alloca i32
store i32 10, i32* %1
%6 = bitcast [10 x double]* %2 to i8*
store double 0.000000e+00, double* %3
%7 = bitcast [10 x i32]* %4 to i8*
store i32 0, i32* %5
%8 = getelementptr inbounds [10 x double], [10 x double]* %2, i64 0, i64 0
%9 = load i32, i32* %1
%10 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 0
%11 = call i32 @MemoizedCutRod(double* %8, i32 %9, double* %3, i32* %10)
store i32 %11, i32* %5
%12 = load i32, i32* %5
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %0
%15 = load i32, i32* %5
%16 = sitofp i32 %15 to double
%17 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), double %16)
br label %18
18: ; preds = %14, %0
%19 = load double, double* %3
%20 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), double %19)
ret i32 0
}

LLVM IR (-O2):
@__const.test_BottomUpCutRod.p = [10 x double] [double 1.000000e+00, double 5.000000e+00, double 8.000000e+00, double 9.000000e+00, double 1.000000e+01, double 1.700000e+01, double 1.700000e+01, double 2.000000e+01, double 2.400000e+01, double 3.000000e+01]
@.str = [25 x i8] c"MemoizedCutMod error %d\0A\00"
@.str.1 = [8 x i8] c"rn=%lf\0A\00"
define i32 @test_BottomUpCutRod() {
%1 = alloca [10 x double]
%2 = alloca double
%3 = alloca [10 x i32]
%4 = bitcast [10 x double]* %1 to i8*
%5 = bitcast double* %2 to i8*
store double 0.000000e+00, double* %2
%6 = bitcast [10 x i32]* %3 to i8*
%7 = getelementptr inbounds [10 x double], [10 x double]* %1, i64 0, i64 0
%8 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%9 = call i32 @MemoizedCutRod(double* %7, i32 10, double* %2, i32* %8)
%10 = icmp eq i32 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %0
%12 = sitofp i32 %9 to double
%13 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), double %12)
br label %14
14: ; preds = %11, %0
%15 = load double, double* %2
%16 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), double %15)
ret i32 0
}