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


x86 assembly (clang, -O0):
<test_MemoizedCutRod>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0xa,-0x4(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xeb6(%rip),%rsi
mov    $0x50,%edx
call   1040 <memcpy@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x68(%rbp)
movl   $0x0,-0x6c(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0x4(%rbp),%esi
lea    -0x68(%rbp),%rdx
call   1050 <MemoizedCutRod@plt>
mov    %eax,-0x6c(%rbp)
cmpl   $0x0,-0x6c(%rbp)
je     1191 <test_MemoizedCutRod+0x61>
cvtsi2sdl -0x6c(%rbp),%xmm0
lea    0xec4(%rip),%rdi
call   1030 <printf@plt>
movsd  -0x68(%rbp),%xmm0
lea    0xecc(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_MemoizedCutRod>:
sub    $0x68,%rsp
movaps 0xf15(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xef9(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xedd(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xec1(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movapd 0xea4(%rip),%xmm0
movapd %xmm0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rdx
mov    $0xa,%esi
call   1040 <MemoizedCutRod@plt>
test   %eax,%eax
je     1196 <test_MemoizedCutRod+0x76>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
lea    0xebf(%rip),%rdi
call   1030 <printf@plt>
movsd  0x8(%rsp),%xmm0
lea    0xec6(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x68,%rsp
ret

LLVM IR (-O0):
@__const.test_MemoizedCutRod.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 = [7 x i8] c"r=%lf\0A\00"
define i32 @test_MemoizedCutRod() {
%1 = alloca i32
%2 = alloca [10 x double]
%3 = alloca double
%4 = alloca i32
store i32 10, i32* %1
%5 = bitcast [10 x double]* %2 to i8*
store double 0.000000e+00, double* %3
store i32 0, i32* %4
%6 = getelementptr inbounds [10 x double], [10 x double]* %2, i64 0, i64 0
%7 = load i32, i32* %1
%8 = call i32 @MemoizedCutRod(double* %6, i32 %7, double* %3)
store i32 %8, i32* %4
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %0
%12 = load i32, i32* %4
%13 = sitofp i32 %12 to double
%14 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), double %13)
br label %15
15: ; preds = %11, %0
%16 = load double, double* %3
%17 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %16)
ret i32 0
}

LLVM IR (-O2):
@__const.test_MemoizedCutRod.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 = [7 x i8] c"r=%lf\0A\00"
define i32 @test_MemoizedCutRod() {
%1 = alloca [10 x double]
%2 = alloca double
%3 = bitcast [10 x double]* %1 to i8*
%4 = bitcast double* %2 to i8*
store double 0.000000e+00, double* %2
%5 = getelementptr inbounds [10 x double], [10 x double]* %1, i64 0, i64 0
%6 = call i32 @MemoizedCutRod(double* %5, i32 10, double* %2)
%7 = icmp eq i32 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %0
%9 = sitofp i32 %6 to double
%10 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), double %9)
br label %11
11: ; preds = %8, %0
%12 = load double, double* %2
%13 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %12)
ret i32 0
}