#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 maxSubsequenceMul(int *, int);
int maxSubsequenceMul2(int *, int);
int maxSubsequenceSum(int *, int);
int maxSubsequenceSum2(int *, int);
int maxSubsequenceSum3(int *, int);
int maxSubsequenceSum4(int *, int);
int minPosSubsequenceSum(int *, int);
int minPosSubsequenceSum2(int *, int);
int minSubsequenceSum(int *, int);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char *argv[]) {
  int seq[] = {5, 6, 4, -5, 7, -3, 12, -5, 8, 5}, LEN = 10;
  printf("MAX SUM=%d\n", maxSubsequenceSum(seq, LEN));
  printf("MAX SUM=%d\n", maxSubsequenceSum2(seq, LEN));
  printf("MAX SUM=%d\n", maxSubsequenceSum3(seq, LEN));
  printf("MAX SUM=%d\n", maxSubsequenceSum4(seq, LEN));
  printf("MIN SUM=%d\n", minSubsequenceSum(seq, LEN));
  printf("MIN PSUM=%d\n", minPosSubsequenceSum(seq, LEN));
  printf("MIN PSUM=%d\n", minPosSubsequenceSum2(seq, LEN));
  printf("MAX MUL=%d\n", maxSubsequenceMul(seq, LEN));
  printf("MAX MUL=%d\n", maxSubsequenceMul2(seq, LEN));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xe2f(%rip),%rsi
mov    $0x28,%edx
call   1070 <memcpy@plt>
movl   $0xa,-0x44(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x44(%rbp),%esi
call   1090 <maxSubsequenceSum@plt>
mov    %eax,%esi
lea    0xe31(%rip),%rdi
call   1050 <printf@plt>
lea    -0x40(%rbp),%rdi
mov    -0x44(%rbp),%esi
call   10a0 <maxSubsequenceSum2@plt>
mov    %eax,%esi
lea    0xe17(%rip),%rdi
call   1050 <printf@plt>
lea    -0x40(%rbp),%rdi
mov    -0x44(%rbp),%esi
call   1060 <maxSubsequenceSum3@plt>
mov    %eax,%esi
lea    0xdfd(%rip),%rdi
call   1050 <printf@plt>
lea    -0x40(%rbp),%rdi
mov    -0x44(%rbp),%esi
call   10b0 <maxSubsequenceSum4@plt>
mov    %eax,%esi
lea    0xde3(%rip),%rdi
call   1050 <printf@plt>
lea    -0x40(%rbp),%rdi
mov    -0x44(%rbp),%esi
call   1040 <minSubsequenceSum@plt>
mov    %eax,%esi
lea    0xdd5(%rip),%rdi
call   1050 <printf@plt>
lea    -0x40(%rbp),%rdi
mov    -0x44(%rbp),%esi
call   1030 <minPosSubsequenceSum@plt>
mov    %eax,%esi
lea    0xdc7(%rip),%rdi
call   1050 <printf@plt>
lea    -0x40(%rbp),%rdi
mov    -0x44(%rbp),%esi
call   10d0 <minPosSubsequenceSum2@plt>
mov    %eax,%esi
lea    0xdad(%rip),%rdi
call   1050 <printf@plt>
lea    -0x40(%rbp),%rdi
mov    -0x44(%rbp),%esi
call   10c0 <maxSubsequenceMul@plt>
mov    %eax,%esi
lea    0xda0(%rip),%rdi
call   1050 <printf@plt>
lea    -0x40(%rbp),%rdi
mov    -0x44(%rbp),%esi
call   1080 <maxSubsequenceMul2@plt>
mov    %eax,%esi
lea    0xd86(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    0xe72(%rip),%rax
mov    %rax,0x20(%rsp)
movaps 0xe56(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe3a(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0xa,%esi
call   1080 <maxSubsequenceSum@plt>
lea    0xe47(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    %r14,%rdi
mov    $0xa,%esi
call   1090 <maxSubsequenceSum2@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    %r14,%rdi
mov    $0xa,%esi
call   1060 <maxSubsequenceSum3@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    %r14,%rdi
mov    $0xa,%esi
call   10a0 <maxSubsequenceSum4@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    %r14,%rdi
mov    $0xa,%esi
call   1040 <minSubsequenceSum@plt>
lea    0xdf0(%rip),%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    %r14,%rdi
mov    $0xa,%esi
call   1030 <minPosSubsequenceSum@plt>
lea    0xde1(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    %r14,%rdi
mov    $0xa,%esi
call   10c0 <minPosSubsequenceSum2@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    %r14,%rdi
mov    $0xa,%esi
call   10b0 <maxSubsequenceMul@plt>
lea    0xdb9(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    %r14,%rdi
mov    $0xa,%esi
call   1070 <maxSubsequenceMul2@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.seq = [10 x i32] [i32 5, i32 6, i32 4, i32 -5, i32 7, i32 -3, i32 12, i32 -5, i32 8, i32 5]
@.str = [12 x i8] c"MAX SUM=%d\0A\00"
@.str.1 = [12 x i8] c"MIN SUM=%d\0A\00"
@.str.2 = [13 x i8] c"MIN PSUM=%d\0A\00"
@.str.3 = [12 x i8] c"MAX MUL=%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [10 x i32]
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = bitcast [10 x i32]* %6 to i8*
store i32 10, i32* %7
%9 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 0
%10 = load i32, i32* %7
%11 = call i32 @maxSubsequenceSum(i32* %9, i32 %10)
%12 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 0
%14 = load i32, i32* %7
%15 = call i32 @maxSubsequenceSum2(i32* %13, i32 %14)
%16 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 0
%18 = load i32, i32* %7
%19 = call i32 @maxSubsequenceSum3(i32* %17, i32 %18)
%20 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 0
%22 = load i32, i32* %7
%23 = call i32 @maxSubsequenceSum4(i32* %21, i32 %22)
%24 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 0
%26 = load i32, i32* %7
%27 = call i32 @minSubsequenceSum(i32* %25, i32 %26)
%28 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %27)
%29 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 0
%30 = load i32, i32* %7
%31 = call i32 @minPosSubsequenceSum(i32* %29, i32 %30)
%32 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %31)
%33 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 0
%34 = load i32, i32* %7
%35 = call i32 @minPosSubsequenceSum2(i32* %33, i32 %34)
%36 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %35)
%37 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 0
%38 = load i32, i32* %7
%39 = call i32 @maxSubsequenceMul(i32* %37, i32 %38)
%40 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %39)
%41 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 0
%42 = load i32, i32* %7
%43 = call i32 @maxSubsequenceMul2(i32* %41, i32 %42)
%44 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %43)
ret i32 0
}

LLVM IR (-O2):
@__const.main.seq = [10 x i32] [i32 5, i32 6, i32 4, i32 -5, i32 7, i32 -3, i32 12, i32 -5, i32 8, i32 5]
@.str = [12 x i8] c"MAX SUM=%d\0A\00"
@.str.1 = [12 x i8] c"MIN SUM=%d\0A\00"
@.str.2 = [13 x i8] c"MIN PSUM=%d\0A\00"
@.str.3 = [12 x i8] c"MAX MUL=%d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [10 x i32]
%4 = bitcast [10 x i32]* %3 to i8*
%5 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%6 = call i32 @maxSubsequenceSum(i32* %5, i32 10)
%7 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = call i32 @maxSubsequenceSum2(i32* %5, i32 10)
%9 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = call i32 @maxSubsequenceSum3(i32* %5, i32 10)
%11 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = call i32 @maxSubsequenceSum4(i32* %5, i32 10)
%13 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = call i32 @minSubsequenceSum(i32* %5, i32 10)
%15 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = call i32 @minPosSubsequenceSum(i32* %5, i32 10)
%17 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%18 = call i32 @minPosSubsequenceSum2(i32* %5, i32 10)
%19 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %18)
%20 = call i32 @maxSubsequenceMul(i32* %5, i32 10)
%21 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %20)
%22 = call i32 @maxSubsequenceMul2(i32* %5, i32 10)
%23 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %22)
ret i32 0
}