#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 BetterMaxSum(int, int *, int *, int *);
int DPMaxSum(int, int *, int *, int *);
int /*<<< orphan*/ printf(char *, int, int, int);
int /*<<< orphan*/ system(char *);
int main() {
  int besti, bestj;
  int data[] = {-9999, -2, 11, -4, 13, -5, -2};
  printf("from %-3d to %-3d, sum is %-3d\n", besti, bestj,
         BetterMaxSum(6, data, &besti, &bestj));
  printf("from %-3d to %-3d, sum is %-3d\n", besti, bestj,
         DPMaxSum(6, data, &besti, &bestj));
  system("pause");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeaa(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xea7(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xea4(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xea2(%rip),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x3c(%rbp)
lea    -0x30(%rbp),%rsi
mov    $0x6,%edi
lea    -0x8(%rbp),%rdx
lea    -0xc(%rbp),%rcx
call   1060 <BetterMaxSum@plt>
mov    -0x40(%rbp),%esi
mov    -0x3c(%rbp),%edx
mov    %eax,%ecx
lea    0xe72(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x34(%rbp)
lea    -0x30(%rbp),%rsi
mov    $0x6,%edi
lea    -0x8(%rbp),%rdx
lea    -0xc(%rbp),%rcx
call   1030 <DPMaxSum@plt>
mov    -0x38(%rbp),%esi
mov    -0x34(%rbp),%edx
mov    %eax,%ecx
lea    0xe3c(%rip),%rdi
call   1050 <printf@plt>
lea    0xe50(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
movups 0xeb7(%rip),%xmm0
movups %xmm0,0x1c(%rsp)
movaps 0xe9f(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0x10(%rsp),%r12
lea    0xc(%rsp),%r14
lea    0x8(%rsp),%r15
mov    $0x6,%edi
mov    %r12,%rsi
mov    %r14,%rdx
mov    %r15,%rcx
call   1060 <BetterMaxSum@plt>
lea    0xe8d(%rip),%r13
mov    %r13,%rdi
mov    %eax,%ecx
call   1050 <printf@plt>
mov    0xc(%rsp),%ebp
mov    0x8(%rsp),%ebx
mov    $0x6,%edi
mov    %r12,%rsi
mov    %r14,%rdx
mov    %r15,%rcx
call   1030 <DPMaxSum@plt>
mov    %r13,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
mov    %eax,%ecx
call   1050 <printf@plt>
lea    0xe73(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.data = [7 x i32] [i32 -9999, i32 -2, i32 11, i32 -4, i32 13, i32 -5, i32 -2]
@.str = [32 x i8] c"from %-3d to %-3d, sum is %-3d\0A\00"
@.str.1 = [6 x i8] c"pause\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [7 x i32]
store i32 0, i32* %1
%5 = bitcast [7 x i32]* %4 to i8*
%6 = load i32, i32* %2
%7 = load i32, i32* %3
%8 = getelementptr inbounds [7 x i32], [7 x i32]* %4, i64 0, i64 0
%9 = call i32 @BetterMaxSum(i32 6, i32* %8, i32* %2, i32* %3)
%10 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %7, i32 %9)
%11 = load i32, i32* %2
%12 = load i32, i32* %3
%13 = getelementptr inbounds [7 x i32], [7 x i32]* %4, i64 0, i64 0
%14 = call i32 @DPMaxSum(i32 6, i32* %13, i32* %2, i32* %3)
%15 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %11, i32 %12, i32 %14)
%16 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@__const.main.data = [7 x i32] [i32 -9999, i32 -2, i32 11, i32 -4, i32 13, i32 -5, i32 -2]
@.str = [32 x i8] c"from %-3d to %-3d, sum is %-3d\0A\00"
@.str.1 = [6 x i8] c"pause\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [7 x i32]
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast [7 x i32]* %3 to i8*
%7 = getelementptr inbounds [7 x i32], [7 x i32]* %3, i64 0, i64 0
%8 = call i32 @BetterMaxSum(i32 6, i32* %7, i32* %1, i32* %2)
%9 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 undef, i32 undef, i32 %8)
%10 = load i32, i32* %1
%11 = load i32, i32* %2
%12 = call i32 @DPMaxSum(i32 6, i32* %7, i32* %1, i32* %2)
%13 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %11, i32 %12)
%14 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}