#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*/ data;

/* Variables and functions */
int *find_maximum_subarray(int *, int, int);
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int data[] = {13, -3, -25, 20, -3,  -16, -23, 18,
                20, -7, 12,  -5, -22, 15,  -4,  7};
  int count = sizeof(data) / sizeof(int);
  int low = 0, high = count - 1;
  int *result = find_maximum_subarray(data, low, high);
  printf("The maximum subarray start index is %d, end index is %d, sum is %d",
         result[1], result[2], result[0]);
  printf("\n");
  free(result);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xea6(%rip),%rsi
mov    $0x40,%edx
call   1060 <memcpy@plt>
movl   $0x10,-0x54(%rbp)
movl   $0x0,-0x58(%rbp)
mov    -0x54(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x5c(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%esi
mov    -0x5c(%rbp),%edx
call   1040 <find_maximum_subarray@plt>
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rax
mov    0x4(%rax),%esi
mov    -0x68(%rbp),%rax
mov    0x8(%rax),%edx
mov    -0x68(%rbp),%rax
mov    (%rax),%ecx
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xecc(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x68(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
movaps 0xee4(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xec8(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xeac(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe90(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0xf,%edx
call   1050 <find_maximum_subarray@plt>
mov    %rax,%rbx
mov    (%rax),%ecx
mov    0x4(%rax),%esi
mov    0x8(%rax),%edx
lea    0xeab(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.data = [16 x i32] [i32 13, i32 -3, i32 -25, i32 20, i32 -3, i32 -16, i32 -23, i32 18, i32 20, i32 -7, i32 12, i32 -5, i32 -22, i32 15, i32 -4, i32 7]
@.str = [67 x i8] c"The maximum subarray start index is %d, end index is %d, sum is %d\00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [16 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
store i32 0, i32* %1
%7 = bitcast [16 x i32]* %2 to i8*
store i32 16, i32* %3
store i32 0, i32* %4
%8 = load i32, i32* %3
%9 = sub nsw i32 %8, 1
store i32 %9, i32* %5
%10 = getelementptr inbounds [16 x i32], [16 x i32]* %2, i64 0, i64 0
%11 = load i32, i32* %4
%12 = load i32, i32* %5
%13 = call i32* @find_maximum_subarray(i32* %10, i32 %11, i32 %12)
store i32* %13, i32** %6
%14 = load i32*, i32** %6
%15 = getelementptr inbounds i32, i32* %14, i64 1
%16 = load i32, i32* %15
%17 = load i32*, i32** %6
%18 = getelementptr inbounds i32, i32* %17, i64 2
%19 = load i32, i32* %18
%20 = load i32*, i32** %6
%21 = getelementptr inbounds i32, i32* %20, i64 0
%22 = load i32, i32* %21
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str, i64 0, i64 0), i32 %16, i32 %19, i32 %22)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%25 = load i32*, i32** %6
%26 = call i32 @free(i32* %25)
ret i32 0
}

LLVM IR (-O2):
@__const.main.data = [16 x i32] [i32 13, i32 -3, i32 -25, i32 20, i32 -3, i32 -16, i32 -23, i32 18, i32 20, i32 -7, i32 12, i32 -5, i32 -22, i32 15, i32 -4, i32 7]
@.str = [67 x i8] c"The maximum subarray start index is %d, end index is %d, sum is %d\00"
define i32 @main() {
%1 = alloca [16 x i32]
%2 = bitcast [16 x i32]* %1 to i8*
%3 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 0
%4 = call i32* @find_maximum_subarray(i32* %3, i32 0, i32 15)
%5 = getelementptr inbounds i32, i32* %4, i64 1
%6 = load i32, i32* %5
%7 = getelementptr inbounds i32, i32* %4, i64 2
%8 = load i32, i32* %7
%9 = load i32, i32* %4
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([67 x i8], [67 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %8, i32 %9)
%11 = call i32 @putchar(i32 10)
%12 = call i32 @free(i32* %4)
ret i32 0
}