#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 */
typedef int /*<<< orphan*/ sequences;

/* Variables and functions */
int max_sub_sequence_sum(int *, int);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char *argv[]) {
  int sequences[][8] = {
      {4, -3, 5, -2, -1, 2, 6, -2}, {1, 2, 3, 4, -4, -3, -2, -1},
      {1, -1, 2, -2, 3, -3, 4, -4}, {1, -1, 1, -1, 1, -1, 1, -1},
      {1, 2, 3, 4, 5, 6, 7, -1000}, {-100, 1, 2, 3, 4, 5, -9, 1}};
  for (int i = 0; i < sizeof(sequences) / sizeof(sequences[0]); ++i) {
    int *sequence = sequences[i];
    int max_sum =
        max_sub_sequence_sum(sequence, sizeof(sequences[0]) / sizeof(int));
    printf("Max sub sequence sum: %d\n", max_sum);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0xd0(%rbp),%rdi
lea    0xea9(%rip),%rsi
mov    $0xc0,%edx
call   1040 <memcpy@plt>
movl   $0x0,-0xd4(%rbp)
movslq -0xd4(%rbp),%rax
cmp    $0x6,%rax
jae    11d5 <main+0xa5>
movslq -0xd4(%rbp),%rcx
lea    -0xd0(%rbp),%rax
shl    $0x5,%rcx
add    %rcx,%rax
mov    %rax,-0xe0(%rbp)
mov    -0xe0(%rbp),%rdi
mov    $0x8,%esi
call   1050 <max_sub_sequence_sum@plt>
mov    %eax,-0xe4(%rbp)
mov    -0xe4(%rbp),%esi
lea    0xf04(%rip),%rdi
call   1030 <printf@plt>
mov    -0xd4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd4(%rbp)
jmp    116b <main+0x3b>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0xc0,%rsp
lea    0xec1(%rip),%rsi
mov    %rsp,%rbx
mov    $0xc0,%edx
mov    %rbx,%rdi
call   1040 <memcpy@plt>
mov    %rbx,%rdi
mov    $0x8,%esi
call   1050 <max_sub_sequence_sum@plt>
lea    0xf5d(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
lea    0x20(%rsp),%rdi
mov    $0x8,%esi
call   1050 <max_sub_sequence_sum@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
lea    0x40(%rsp),%rdi
mov    $0x8,%esi
call   1050 <max_sub_sequence_sum@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
lea    0x60(%rsp),%rdi
mov    $0x8,%esi
call   1050 <max_sub_sequence_sum@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
lea    0x80(%rsp),%rdi
mov    $0x8,%esi
call   1050 <max_sub_sequence_sum@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
lea    0xa0(%rsp),%rdi
mov    $0x8,%esi
call   1050 <max_sub_sequence_sum@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xc0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.sequences = [6 x [8 x i32]] [[8 x i32] [i32 4, i32 -3, i32 5, i32 -2, i32 -1, i32 2, i32 6, i32 -2], [8 x i32] [i32 1, i32 2, i32 3, i32 4, i32 -4, i32 -3, i32 -2, i32 -1], [8 x i32] [i32 1, i32 -1, i32 2, i32 -2, i32 3, i32 -3, i32 4, i32 -4], [8 x i32] [i32 1, i32 -1, i32 1, i32 -1, i32 1, i32 -1, i32 1, i32 -1], [8 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 -1000], [8 x i32] [i32 -100, i32 1, i32 2, i32 3, i32 4, i32 5, i32 -9, i32 1]]
@.str = [26 x i8] c"Max sub sequence sum: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [6 x [8 x i32]]
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = bitcast [6 x [8 x i32]]* %6 to i8*
store i32 0, i32* %7
br label %11
11: ; preds = %24, %2
%12 = load i32, i32* %7
%13 = sext i32 %12 to i64
%14 = icmp ult i64 %13, 6
br i1 %14, label %15, label %27
15: ; preds = %11
%16 = load i32, i32* %7
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [6 x [8 x i32]], [6 x [8 x i32]]* %6, i64 0, i64 %17
%19 = getelementptr inbounds [8 x i32], [8 x i32]* %18, i64 0, i64 0
store i32* %19, i32** %8
%20 = load i32*, i32** %8
%21 = call i32 @max_sub_sequence_sum(i32* %20, i32 8)
store i32 %21, i32* %9
%22 = load i32, i32* %9
%23 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %22)
br label %24
24: ; preds = %15
%25 = load i32, i32* %7
%26 = add nsw i32 %25, 1
store i32 %26, i32* %7
br label %11
27: ; preds = %11
ret i32 0
}

LLVM IR (-O2):
@__const.main.sequences = [6 x [8 x i32]] [[8 x i32] [i32 4, i32 -3, i32 5, i32 -2, i32 -1, i32 2, i32 6, i32 -2], [8 x i32] [i32 1, i32 2, i32 3, i32 4, i32 -4, i32 -3, i32 -2, i32 -1], [8 x i32] [i32 1, i32 -1, i32 2, i32 -2, i32 3, i32 -3, i32 4, i32 -4], [8 x i32] [i32 1, i32 -1, i32 1, i32 -1, i32 1, i32 -1, i32 1, i32 -1], [8 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 -1000], [8 x i32] [i32 -100, i32 1, i32 2, i32 3, i32 4, i32 5, i32 -9, i32 1]]
@.str = [26 x i8] c"Max sub sequence sum: %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [6 x [8 x i32]]
%4 = bitcast [6 x [8 x i32]]* %3 to i8*
%5 = getelementptr inbounds [6 x [8 x i32]], [6 x [8 x i32]]* %3, i64 0, i64 0, i64 0
%6 = call i32 @max_sub_sequence_sum(i32* %5, i32 8)
%7 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = getelementptr inbounds [6 x [8 x i32]], [6 x [8 x i32]]* %3, i64 0, i64 1, i64 0
%9 = call i32 @max_sub_sequence_sum(i32* %8, i32 8)
%10 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = getelementptr inbounds [6 x [8 x i32]], [6 x [8 x i32]]* %3, i64 0, i64 2, i64 0
%12 = call i32 @max_sub_sequence_sum(i32* %11, i32 8)
%13 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = getelementptr inbounds [6 x [8 x i32]], [6 x [8 x i32]]* %3, i64 0, i64 3, i64 0
%15 = call i32 @max_sub_sequence_sum(i32* %14, i32 8)
%16 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds [6 x [8 x i32]], [6 x [8 x i32]]* %3, i64 0, i64 4, i64 0
%18 = call i32 @max_sub_sequence_sum(i32* %17, i32 8)
%19 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = getelementptr inbounds [6 x [8 x i32]], [6 x [8 x i32]]* %3, i64 0, i64 5, i64 0
%21 = call i32 @max_sub_sequence_sum(i32* %20, i32 8)
%22 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %21)
ret i32 0
}