#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 */
struct timespec {
  scalar_t__ tv_nsec;
  scalar_t__ tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ CLOCK_MONOTONIC;
long atol(char *);
int bruteFindMaxSubarray(int *, int *, int *);
int /*<<< orphan*/ clock_gettime(int /*<<< orphan*/, struct timespec *);
int /*<<< orphan*/ free(int *);
int hybridFindMaxSubarray(int *, int *, int *);
int linearFindMaxSubarray(int *, int *, int *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, double, int, int, int);
int rand();
int recFindMaxSubarray(int *, int *, int *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  srand(time(NULL));
  long n;
  if (argc > 1)
    n = atol(argv[1]);
  n = n > 0 ? n : 500;
  int *arr;
  int low_bf = 0, high_bf = n - 1, sum_bf;
  int low_rec = 0, high_rec = n - 1, sum_rec;
  int low_hyb = 0, high_hyb = n - 1, sum_hyb;
  int low_lin = 0, high_lin = n - 1, sum_lin;
  struct timespec start, end;
  double time_bf, time_rec, time_hyb, time_lin;
  arr = (int *)malloc(sizeof(int) * n);
  for (int i = 0; i < n; i++) {
    arr[i] = rand() % 201 - 100;
  }
  clock_gettime(CLOCK_MONOTONIC, &start);
  sum_bf = bruteFindMaxSubarray(arr, &low_bf, &high_bf);
  clock_gettime(CLOCK_MONOTONIC, &end);
  time_bf = (double)(end.tv_sec - start.tv_sec) * 1.0e9 +
            (double)(end.tv_nsec - start.tv_nsec);
  clock_gettime(CLOCK_MONOTONIC, &start);
  sum_rec = recFindMaxSubarray(arr, &low_rec, &high_rec);
  clock_gettime(CLOCK_MONOTONIC, &end);
  time_rec = (double)(end.tv_sec - start.tv_sec) * 1.0e9 +
             (double)(end.tv_nsec - start.tv_nsec);
  clock_gettime(CLOCK_MONOTONIC, &start);
  sum_hyb = hybridFindMaxSubarray(arr, &low_hyb, &high_hyb);
  clock_gettime(CLOCK_MONOTONIC, &end);
  time_hyb = (double)(end.tv_sec - start.tv_sec) * 1.0e9 +
             (double)(end.tv_nsec - start.tv_nsec);
  clock_gettime(CLOCK_MONOTONIC, &start);
  sum_lin = linearFindMaxSubarray(arr, &low_lin, &high_lin);
  clock_gettime(CLOCK_MONOTONIC, &end);
  time_lin = (double)(end.tv_sec - start.tv_sec) * 1.0e9 +
             (double)(end.tv_nsec - start.tv_nsec);
  printf("Linear Algorithm :      "
         "\x1B[32m"
         "%10.0lfns"
         "\x1B[0m"
         ", max-subarray=[%d, %d], sum = %d\n",
         time_lin, low_lin + 1, high_lin + 1, sum_lin);
  printf("Hybrid Algorithm :      "
         "\x1B[32m"
         "%10.0lfns"
         "\x1B[0m"
         ", max-subarray=[%d, %d], sum = %d\n",
         time_hyb, low_hyb + 1, high_hyb + 1, sum_hyb);
  printf("Recursive Algorithm :   "
         "\x1B[33m"
         "%10.0lfns"
         "\x1B[0m"
         ", max-subarray=[%d, %d], sum = %d\n",
         time_rec, low_rec + 1, high_rec + 1, sum_rec);
  printf("Brute-force Algorithm : "
         "\x1B[31m"
         "%10.0lfns"
         "\x1B[0m"
         ", max-subarray=[%d, %d], sum = %d\n",
         time_bf, low_bf + 1, high_bf + 1, sum_bf);
  free(arr);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1090 <time@plt>
mov    %eax,%edi
call   1070 <srand@plt>
cmpl   $0x1,-0x8(%rbp)
jle    1204 <main+0x44>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10c0 <atol@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jle    121f <main+0x5f>
mov    -0x18(%rbp),%rax
mov    %rax,-0xa0(%rbp)
jmp    1230 <main+0x70>
mov    $0x1f4,%eax
mov    %rax,-0xa0(%rbp)
jmp    1230 <main+0x70>
mov    -0xa0(%rbp),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x18(%rbp),%rax
sub    $0x1,%rax
mov    %eax,-0x28(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x18(%rbp),%rax
sub    $0x1,%rax
mov    %eax,-0x34(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x18(%rbp),%rax
sub    $0x1,%rax
mov    %eax,-0x40(%rbp)
movl   $0x0,-0x48(%rbp)
mov    -0x18(%rbp),%rax
sub    $0x1,%rax
mov    %eax,-0x4c(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x94(%rbp)
movslq -0x94(%rbp),%rax
cmp    -0x18(%rbp),%rax
jge    12e5 <main+0x125>
mov    $0x0,%al
call   10e0 <rand@plt>
mov    $0xc9,%ecx
cltd
idiv   %ecx
sub    $0x64,%edx
mov    -0x20(%rbp),%rax
movslq -0x94(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    12a0 <main+0xe0>
mov    0x2cfc(%rip),%rax
mov    (%rax),%edi
lea    -0x60(%rbp),%rsi
call   1040 <clock_gettime@plt>
mov    -0x20(%rbp),%rdi
lea    -0x24(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   10d0 <bruteFindMaxSubarray@plt>
mov    %eax,-0x2c(%rbp)
mov    0x2cd6(%rip),%rax
mov    (%rax),%edi
lea    -0x70(%rbp),%rsi
call   1040 <clock_gettime@plt>
mov    -0x68(%rbp),%rax
sub    -0x58(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    -0x70(%rbp),%rax
sub    -0x60(%rbp),%rax
cvtsi2sd %rax,%xmm1
movsd  0xcc1(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
mov    0x2c95(%rip),%rax
mov    (%rax),%edi
lea    -0x60(%rbp),%rsi
call   1040 <clock_gettime@plt>
mov    -0x20(%rbp),%rdi
lea    -0x30(%rbp),%rsi
lea    -0x34(%rbp),%rdx
call   10b0 <recFindMaxSubarray@plt>
mov    %eax,-0x38(%rbp)
mov    0x2c6f(%rip),%rax
mov    (%rax),%edi
lea    -0x70(%rbp),%rsi
call   1040 <clock_gettime@plt>
mov    -0x68(%rbp),%rax
sub    -0x58(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    -0x70(%rbp),%rax
sub    -0x60(%rbp),%rax
cvtsi2sd %rax,%xmm1
movsd  0xc5a(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
mov    0x2c2e(%rip),%rax
mov    (%rax),%edi
lea    -0x60(%rbp),%rsi
call   1040 <clock_gettime@plt>
mov    -0x20(%rbp),%rdi
lea    -0x3c(%rbp),%rsi
lea    -0x40(%rbp),%rdx
call   1080 <hybridFindMaxSubarray@plt>
mov    %eax,-0x44(%rbp)
mov    0x2c08(%rip),%rax
mov    (%rax),%edi
lea    -0x70(%rbp),%rsi
call   1040 <clock_gettime@plt>
mov    -0x68(%rbp),%rax
sub    -0x58(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    -0x70(%rbp),%rax
sub    -0x60(%rbp),%rax
cvtsi2sd %rax,%xmm1
movsd  0xbf3(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
mov    0x2bc4(%rip),%rax
mov    (%rax),%edi
lea    -0x60(%rbp),%rsi
call   1040 <clock_gettime@plt>
mov    -0x20(%rbp),%rdi
lea    -0x48(%rbp),%rsi
lea    -0x4c(%rbp),%rdx
call   1060 <linearFindMaxSubarray@plt>
mov    %eax,-0x50(%rbp)
mov    0x2b9e(%rip),%rax
mov    (%rax),%edi
lea    -0x70(%rbp),%rsi
call   1040 <clock_gettime@plt>
mov    -0x68(%rbp),%rax
sub    -0x58(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    -0x70(%rbp),%rax
sub    -0x60(%rbp),%rax
cvtsi2sd %rax,%xmm1
movsd  0xb89(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x90(%rbp),%xmm0
ff
mov    -0x48(%rbp),%esi
add    $0x1,%esi
mov    -0x4c(%rbp),%edx
add    $0x1,%edx
mov    -0x50(%rbp),%ecx
lea    0xb63(%rip),%rdi
call   1050 <printf@plt>
movsd  -0x88(%rbp),%xmm0
ff
mov    -0x3c(%rbp),%esi
add    $0x1,%esi
mov    -0x40(%rbp),%edx
add    $0x1,%edx
mov    -0x44(%rbp),%ecx
lea    0xb8d(%rip),%rdi
call   1050 <printf@plt>
movsd  -0x80(%rbp),%xmm0
mov    -0x30(%rbp),%esi
add    $0x1,%esi
mov    -0x34(%rbp),%edx
add    $0x1,%edx
mov    -0x38(%rbp),%ecx
lea    0xbba(%rip),%rdi
call   1050 <printf@plt>
movsd  -0x78(%rbp),%xmm0
mov    -0x24(%rbp),%esi
add    $0x1,%esi
mov    -0x28(%rbp),%edx
add    $0x1,%edx
mov    -0x2c(%rbp),%ecx
lea    0xbe7(%rip),%rdi
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %edi,%edi
call   1090 <time@plt>
mov    %eax,%edi
call   1070 <srand@plt>
cmp    $0x2,%ebp
jl     11ef <main+0x2f>
mov    0x8(%rbx),%rdi
call   10c0 <atol@plt>
test   %rax,%rax
mov    $0x1f4,%ebp
cmovg  %rax,%rbp
movl   $0x0,0x24(%rsp)
lea    -0x1(%rbp),%eax
mov    %eax,0x20(%rsp)
movl   $0x0,0x1c(%rsp)
mov    %eax,0x18(%rsp)
movl   $0x0,0x14(%rsp)
mov    %eax,0x10(%rsp)
movl   $0x0,0xc(%rsp)
mov    %eax,0x8(%rsp)
lea    0x0(,%rbp,4),%edi
call   10a0 <malloc@plt>
mov    %rax,%r13
xor    %ebx,%ebx
nop
xor    %eax,%eax
call   10e0 <rand@plt>
cltq
imul   $0x28c1979,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x21,%rcx
add    %edx,%ecx
imul   $0xc9,%ecx,%ecx
neg    %ecx
add    %ecx,%eax
add    $0xffffff9c,%eax
mov    %eax,0x0(%r13,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1240 <main+0x80>
mov    0x2d69(%rip),%r15
mov    (%r15),%edi
lea    0x38(%rsp),%r12
mov    %r12,%rsi
call   1040 <clock_gettime@plt>
lea    0x24(%rsp),%rsi
lea    0x20(%rsp),%rdx
mov    %r13,%rdi
call   10d0 <bruteFindMaxSubarray@plt>
mov    %eax,0x4c(%rsp)
mov    (%r15),%edi
lea    0x28(%rsp),%r14
mov    %r14,%rsi
call   1040 <clock_gettime@plt>
mov    0x28(%rsp),%rax
mov    0x30(%rsp),%rcx
sub    0x40(%rsp),%rcx
cvtsi2sd %rcx,%xmm1
sub    0x38(%rsp),%rax
cvtsi2sd %rax,%xmm0
mulsd  0xd25(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x60(%rsp)
mov    (%r15),%edi
mov    %r12,%rsi
call   1040 <clock_gettime@plt>
lea    0x1c(%rsp),%rsi
lea    0x18(%rsp),%rdx
mov    %r13,%rdi
call   10b0 <recFindMaxSubarray@plt>
mov    %eax,0x48(%rsp)
mov    (%r15),%edi
mov    %r14,%rsi
call   1040 <clock_gettime@plt>
mov    0x28(%rsp),%rax
mov    0x30(%rsp),%rcx
sub    0x40(%rsp),%rcx
xorps  %xmm1,%xmm1
cvtsi2sd %rcx,%xmm1
sub    0x38(%rsp),%rax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
mulsd  0xcc3(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x58(%rsp)
mov    (%r15),%edi
mov    %r12,%rsi
call   1040 <clock_gettime@plt>
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
mov    %r13,%rdi
call   1080 <hybridFindMaxSubarray@plt>
mov    %eax,%ebx
mov    (%r15),%edi
mov    %r14,%rsi
call   1040 <clock_gettime@plt>
mov    0x28(%rsp),%rax
mov    0x30(%rsp),%rcx
sub    0x40(%rsp),%rcx
xorps  %xmm1,%xmm1
cvtsi2sd %rcx,%xmm1
sub    0x38(%rsp),%rax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
mulsd  0xc63(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x50(%rsp)
mov    (%r15),%edi
mov    %r12,%rsi
call   1040 <clock_gettime@plt>
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    %r13,%rdi
call   1060 <linearFindMaxSubarray@plt>
mov    %eax,%ebp
mov    (%r15),%edi
mov    %r14,%rsi
call   1040 <clock_gettime@plt>
mov    0x28(%rsp),%rax
mov    0x30(%rsp),%rcx
sub    0x40(%rsp),%rcx
xorps  %xmm0,%xmm0
cvtsi2sd %rcx,%xmm0
sub    0x38(%rsp),%rax
xorps  %xmm1,%xmm1
cvtsi2sd %rax,%xmm1
mulsd  0xc03(%rip),%xmm0
addsd  %xmm1,%xmm0
mov    0xc(%rsp),%esi
add    $0x1,%esi
mov    0x8(%rsp),%edx
add    $0x1,%edx
lea    0xbf2(%rip),%rdi
mov    %ebp,%ecx
call   1050 <printf@plt>
mov    0x14(%rsp),%esi
add    $0x1,%esi
mov    0x10(%rsp),%edx
add    $0x1,%edx
lea    0xc23(%rip),%rdi
movsd  0x50(%rsp),%xmm0
mov    %ebx,%ecx
call   1050 <printf@plt>
mov    0x1c(%rsp),%esi
add    $0x1,%esi
mov    0x18(%rsp),%edx
add    $0x1,%edx
lea    0xc4e(%rip),%rdi
movsd  0x58(%rsp),%xmm0
mov    0x48(%rsp),%ecx
call   1050 <printf@plt>
mov    0x24(%rsp),%esi
add    $0x1,%esi
mov    0x20(%rsp),%edx
add    $0x1,%edx
lea    0xc77(%rip),%rdi
movsd  0x60(%rsp),%xmm0
mov    0x4c(%rsp),%ecx
call   1050 <printf@plt>
mov    %r13,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timespec = type { i64, i64 }
@CLOCK_MONOTONIC = global i32 0
@.str = [77 x i8] c"Linear Algorithm : \1B[32m%10.0lfns\1B[0m, max-subarray=[%d, %d], sum = %d\0A\00"
@.str.1 = [77 x i8] c"Hybrid Algorithm : \1B[32m%10.0lfns\1B[0m, max-subarray=[%d, %d], sum = %d\0A\00"
@.str.2 = [77 x i8] c"Recursive Algorithm : \1B[33m%10.0lfns\1B[0m, max-subarray=[%d, %d], sum = %d\0A\00"
@.str.3 = [77 x i8] c"Brute-force Algorithm : \1B[31m%10.0lfns\1B[0m, max-subarray=[%d, %d], sum = %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca %struct.timespec
%21 = alloca %struct.timespec
%22 = alloca double
%23 = alloca double
%24 = alloca double
%25 = alloca double
%26 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%27 = call i32 @time(i32* null)
%28 = call i32 @srand(i32 %27)
%29 = load i32, i32* %4
%30 = icmp sgt i32 %29, 1
br i1 %30, label %31, label %36
31: ; preds = %2
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = call i64 @atol(i8* %34)
store i64 %35, i64* %6
br label %36
36: ; preds = %31, %2
%37 = load i64, i64* %6
%38 = icmp sgt i64 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %36
%40 = load i64, i64* %6
br label %42
41: ; preds = %36
br label %42
42: ; preds = %41, %39
%43 = phi i64 [ %40, %39 ], [ 500, %41 ]
store i64 %43, i64* %6
store i32 0, i32* %8
%44 = load i64, i64* %6
%45 = sub nsw i64 %44, 1
%46 = trunc i64 %45 to i32
store i32 %46, i32* %9
store i32 0, i32* %11
%47 = load i64, i64* %6
%48 = sub nsw i64 %47, 1
%49 = trunc i64 %48 to i32
store i32 %49, i32* %12
store i32 0, i32* %14
%50 = load i64, i64* %6
%51 = sub nsw i64 %50, 1
%52 = trunc i64 %51 to i32
store i32 %52, i32* %15
store i32 0, i32* %17
%53 = load i64, i64* %6
%54 = sub nsw i64 %53, 1
%55 = trunc i64 %54 to i32
store i32 %55, i32* %18
%56 = load i64, i64* %6
%57 = mul i64 4, %56
%58 = trunc i64 %57 to i32
%59 = call i64 @malloc(i32 %58)
%60 = inttoptr i64 %59 to i32*
store i32* %60, i32** %7
store i32 0, i32* %26
br label %61
61: ; preds = %74, %42
%62 = load i32, i32* %26
%63 = sext i32 %62 to i64
%64 = load i64, i64* %6
%65 = icmp slt i64 %63, %64
br i1 %65, label %66, label %77
66: ; preds = %61
%67 = call i32 (...) @rand()
%68 = srem i32 %67, 201
%69 = sub nsw i32 %68, 100
%70 = load i32*, i32** %7
%71 = load i32, i32* %26
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds i32, i32* %70, i64 %72
store i32 %69, i32* %73
br label %74
74: ; preds = %66
%75 = load i32, i32* %26
%76 = add nsw i32 %75, 1
store i32 %76, i32* %26
br label %61
77: ; preds = %61
%78 = load i32, i32* @CLOCK_MONOTONIC
%79 = call i32 @clock_gettime(i32 %78, %struct.timespec* %20)
%80 = load i32*, i32** %7
%81 = call i32 @bruteFindMaxSubarray(i32* %80, i32* %8, i32* %9)
store i32 %81, i32* %10
%82 = load i32, i32* @CLOCK_MONOTONIC
%83 = call i32 @clock_gettime(i32 %82, %struct.timespec* %21)
%84 = getelementptr inbounds %struct.timespec, %struct.timespec* %21, i32 0, i32 1
%85 = load i64, i64* %84
%86 = getelementptr inbounds %struct.timespec, %struct.timespec* %20, i32 0, i32 1
%87 = load i64, i64* %86
%88 = sub nsw i64 %85, %87
%89 = sitofp i64 %88 to double
%90 = getelementptr inbounds %struct.timespec, %struct.timespec* %21, i32 0, i32 0
%91 = load i64, i64* %90
%92 = getelementptr inbounds %struct.timespec, %struct.timespec* %20, i32 0, i32 0
%93 = load i64, i64* %92
%94 = sub nsw i64 %91, %93
%95 = sitofp i64 %94 to double
%96 = call double @llvm.fmuladd.f64(double %89, double 1.000000e+09, double %95)
store double %96, double* %22
%97 = load i32, i32* @CLOCK_MONOTONIC
%98 = call i32 @clock_gettime(i32 %97, %struct.timespec* %20)
%99 = load i32*, i32** %7
%100 = call i32 @recFindMaxSubarray(i32* %99, i32* %11, i32* %12)
store i32 %100, i32* %13
%101 = load i32, i32* @CLOCK_MONOTONIC
%102 = call i32 @clock_gettime(i32 %101, %struct.timespec* %21)
%103 = getelementptr inbounds %struct.timespec, %struct.timespec* %21, i32 0, i32 1
%104 = load i64, i64* %103
%105 = getelementptr inbounds %struct.timespec, %struct.timespec* %20, i32 0, i32 1
%106 = load i64, i64* %105
%107 = sub nsw i64 %104, %106
%108 = sitofp i64 %107 to double
%109 = getelementptr inbounds %struct.timespec, %struct.timespec* %21, i32 0, i32 0
%110 = load i64, i64* %109
%111 = getelementptr inbounds %struct.timespec, %struct.timespec* %20, i32 0, i32 0
%112 = load i64, i64* %111
%113 = sub nsw i64 %110, %112
%114 = sitofp i64 %113 to double
%115 = call double @llvm.fmuladd.f64(double %108, double 1.000000e+09, double %114)
store double %115, double* %23
%116 = load i32, i32* @CLOCK_MONOTONIC
%117 = call i32 @clock_gettime(i32 %116, %struct.timespec* %20)
%118 = load i32*, i32** %7
%119 = call i32 @hybridFindMaxSubarray(i32* %118, i32* %14, i32* %15)
store i32 %119, i32* %16
%120 = load i32, i32* @CLOCK_MONOTONIC
%121 = call i32 @clock_gettime(i32 %120, %struct.timespec* %21)
%122 = getelementptr inbounds %struct.timespec, %struct.timespec* %21, i32 0, i32 1
%123 = load i64, i64* %122
%124 = getelementptr inbounds %struct.timespec, %struct.timespec* %20, i32 0, i32 1
%125 = load i64, i64* %124
%126 = sub nsw i64 %123, %125
%127 = sitofp i64 %126 to double
%128 = getelementptr inbounds %struct.timespec, %struct.timespec* %21, i32 0, i32 0
%129 = load i64, i64* %128
%130 = getelementptr inbounds %struct.timespec, %struct.timespec* %20, i32 0, i32 0
%131 = load i64, i64* %130
%132 = sub nsw i64 %129, %131
%133 = sitofp i64 %132 to double
%134 = call double @llvm.fmuladd.f64(double %127, double 1.000000e+09, double %133)
store double %134, double* %24
%135 = load i32, i32* @CLOCK_MONOTONIC
%136 = call i32 @clock_gettime(i32 %135, %struct.timespec* %20)
%137 = load i32*, i32** %7
%138 = call i32 @linearFindMaxSubarray(i32* %137, i32* %17, i32* %18)
store i32 %138, i32* %19
%139 = load i32, i32* @CLOCK_MONOTONIC
%140 = call i32 @clock_gettime(i32 %139, %struct.timespec* %21)
%141 = getelementptr inbounds %struct.timespec, %struct.timespec* %21, i32 0, i32 1
%142 = load i64, i64* %141
%143 = getelementptr inbounds %struct.timespec, %struct.timespec* %20, i32 0, i32 1
%144 = load i64, i64* %143
%145 = sub nsw i64 %142, %144
%146 = sitofp i64 %145 to double
%147 = getelementptr inbounds %struct.timespec, %struct.timespec* %21, i32 0, i32 0
%148 = load i64, i64* %147
%149 = getelementptr inbounds %struct.timespec, %struct.timespec* %20, i32 0, i32 0
%150 = load i64, i64* %149
%151 = sub nsw i64 %148, %150
%152 = sitofp i64 %151 to double
%153 = call double @llvm.fmuladd.f64(double %146, double 1.000000e+09, double %152)
store double %153, double* %25
%154 = load double, double* %25
%155 = load i32, i32* %17
%156 = add nsw i32 %155, 1
%157 = load i32, i32* %18
%158 = add nsw i32 %157, 1
%159 = load i32, i32* %19
%160 = call i32 @printf(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str, i64 0, i64 0), double %154, i32 %156, i32 %158, i32 %159)
%161 = load double, double* %24
%162 = load i32, i32* %14
%163 = add nsw i32 %162, 1
%164 = load i32, i32* %15
%165 = add nsw i32 %164, 1
%166 = load i32, i32* %16
%167 = call i32 @printf(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.1, i64 0, i64 0), double %161, i32 %163, i32 %165, i32 %166)
%168 = load double, double* %23
%169 = load i32, i32* %11
%170 = add nsw i32 %169, 1
%171 = load i32, i32* %12
%172 = add nsw i32 %171, 1
%173 = load i32, i32* %13
%174 = call i32 @printf(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.2, i64 0, i64 0), double %168, i32 %170, i32 %172, i32 %173)
%175 = load double, double* %22
%176 = load i32, i32* %8
%177 = add nsw i32 %176, 1
%178 = load i32, i32* %9
%179 = add nsw i32 %178, 1
%180 = load i32, i32* %10
%181 = call i32 @printf(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.3, i64 0, i64 0), double %175, i32 %177, i32 %179, i32 %180)
%182 = load i32*, i32** %7
%183 = call i32 @free(i32* %182)
ret i32 0
}

LLVM IR (-O2):
%struct.timespec = type { i64, i64 }
@CLOCK_MONOTONIC = global i32 0
@.str = [77 x i8] c"Linear Algorithm : \1B[32m%10.0lfns\1B[0m, max-subarray=[%d, %d], sum = %d\0A\00"
@.str.1 = [77 x i8] c"Hybrid Algorithm : \1B[32m%10.0lfns\1B[0m, max-subarray=[%d, %d], sum = %d\0A\00"
@.str.2 = [77 x i8] c"Recursive Algorithm : \1B[33m%10.0lfns\1B[0m, max-subarray=[%d, %d], sum = %d\0A\00"
@.str.3 = [77 x i8] c"Brute-force Algorithm : \1B[31m%10.0lfns\1B[0m, max-subarray=[%d, %d], sum = %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca %struct.timespec
%12 = alloca %struct.timespec
%13 = tail call i32 @time(i32* null)
%14 = tail call i32 @srand(i32 %13)
%15 = icmp sgt i32 %0, 1
br i1 %15, label %16, label %20
16: ; preds = %2
%17 = getelementptr inbounds i8*, i8** %1, i64 1
%18 = load i8*, i8** %17
%19 = tail call i64 @atol(i8* %18)
br label %20
20: ; preds = %16, %2
%21 = phi i64 [ %19, %16 ], [ undef, %2 ]
%22 = icmp sgt i64 %21, 0
%23 = select i1 %22, i64 %21, i64 500
%24 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%25 = bitcast i32* %4 to i8*
%26 = trunc i64 %23 to i32
%27 = add i32 %26, -1
store i32 %27, i32* %4
%28 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%29 = bitcast i32* %6 to i8*
store i32 %27, i32* %6
%30 = bitcast i32* %7 to i8*
store i32 0, i32* %7
%31 = bitcast i32* %8 to i8*
store i32 %27, i32* %8
%32 = bitcast i32* %9 to i8*
store i32 0, i32* %9
%33 = bitcast i32* %10 to i8*
store i32 %27, i32* %10
%34 = bitcast %struct.timespec* %11 to i8*
%35 = bitcast %struct.timespec* %12 to i8*
%36 = shl i32 %26, 2
%37 = tail call i64 @malloc(i32 %36)
%38 = inttoptr i64 %37 to i32*
br label %121
39: ; preds = %121
%40 = load i32, i32* @CLOCK_MONOTONIC
%41 = call i32 @clock_gettime(i32 %40, %struct.timespec* %11)
%42 = call i32 @bruteFindMaxSubarray(i32* %38, i32* %3, i32* %4)
%43 = load i32, i32* @CLOCK_MONOTONIC
%44 = call i32 @clock_gettime(i32 %43, %struct.timespec* %12)
%45 = getelementptr inbounds %struct.timespec, %struct.timespec* %12, i64 0, i32 1
%46 = load i64, i64* %45
%47 = getelementptr inbounds %struct.timespec, %struct.timespec* %11, i64 0, i32 1
%48 = load i64, i64* %47
%49 = sub nsw i64 %46, %48
%50 = sitofp i64 %49 to double
%51 = getelementptr inbounds %struct.timespec, %struct.timespec* %12, i64 0, i32 0
%52 = load i64, i64* %51
%53 = getelementptr inbounds %struct.timespec, %struct.timespec* %11, i64 0, i32 0
%54 = load i64, i64* %53
%55 = sub nsw i64 %52, %54
%56 = sitofp i64 %55 to double
%57 = call double @llvm.fmuladd.f64(double %50, double 1.000000e+09, double %56)
%58 = load i32, i32* @CLOCK_MONOTONIC
%59 = call i32 @clock_gettime(i32 %58, %struct.timespec* %11)
%60 = call i32 @recFindMaxSubarray(i32* %38, i32* %5, i32* %6)
%61 = load i32, i32* @CLOCK_MONOTONIC
%62 = call i32 @clock_gettime(i32 %61, %struct.timespec* %12)
%63 = load i64, i64* %45
%64 = load i64, i64* %47
%65 = sub nsw i64 %63, %64
%66 = sitofp i64 %65 to double
%67 = load i64, i64* %51
%68 = load i64, i64* %53
%69 = sub nsw i64 %67, %68
%70 = sitofp i64 %69 to double
%71 = call double @llvm.fmuladd.f64(double %66, double 1.000000e+09, double %70)
%72 = load i32, i32* @CLOCK_MONOTONIC
%73 = call i32 @clock_gettime(i32 %72, %struct.timespec* %11)
%74 = call i32 @hybridFindMaxSubarray(i32* %38, i32* %7, i32* %8)
%75 = load i32, i32* @CLOCK_MONOTONIC
%76 = call i32 @clock_gettime(i32 %75, %struct.timespec* %12)
%77 = load i64, i64* %45
%78 = load i64, i64* %47
%79 = sub nsw i64 %77, %78
%80 = sitofp i64 %79 to double
%81 = load i64, i64* %51
%82 = load i64, i64* %53
%83 = sub nsw i64 %81, %82
%84 = sitofp i64 %83 to double
%85 = call double @llvm.fmuladd.f64(double %80, double 1.000000e+09, double %84)
%86 = load i32, i32* @CLOCK_MONOTONIC
%87 = call i32 @clock_gettime(i32 %86, %struct.timespec* %11)
%88 = call i32 @linearFindMaxSubarray(i32* %38, i32* %9, i32* %10)
%89 = load i32, i32* @CLOCK_MONOTONIC
%90 = call i32 @clock_gettime(i32 %89, %struct.timespec* %12)
%91 = load i64, i64* %45
%92 = load i64, i64* %47
%93 = sub nsw i64 %91, %92
%94 = sitofp i64 %93 to double
%95 = load i64, i64* %51
%96 = load i64, i64* %53
%97 = sub nsw i64 %95, %96
%98 = sitofp i64 %97 to double
%99 = call double @llvm.fmuladd.f64(double %94, double 1.000000e+09, double %98)
%100 = load i32, i32* %9
%101 = add nsw i32 %100, 1
%102 = load i32, i32* %10
%103 = add nsw i32 %102, 1
%104 = call i32 @printf(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str, i64 0, i64 0), double %99, i32 %101, i32 %103, i32 %88)
%105 = load i32, i32* %7
%106 = add nsw i32 %105, 1
%107 = load i32, i32* %8
%108 = add nsw i32 %107, 1
%109 = call i32 @printf(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.1, i64 0, i64 0), double %85, i32 %106, i32 %108, i32 %74)
%110 = load i32, i32* %5
%111 = add nsw i32 %110, 1
%112 = load i32, i32* %6
%113 = add nsw i32 %112, 1
%114 = call i32 @printf(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.2, i64 0, i64 0), double %71, i32 %111, i32 %113, i32 %60)
%115 = load i32, i32* %3
%116 = add nsw i32 %115, 1
%117 = load i32, i32* %4
%118 = add nsw i32 %117, 1
%119 = call i32 @printf(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.3, i64 0, i64 0), double %57, i32 %116, i32 %118, i32 %42)
%120 = call i32 @free(i32* %38)
ret i32 0
121: ; preds = %20, %121
%122 = phi i64 [ 0, %20 ], [ %127, %121 ]
%123 = tail call i32 (...) @rand()
%124 = srem i32 %123, 201
%125 = add nsw i32 %124, -100
%126 = getelementptr inbounds i32, i32* %38, i64 %122
store i32 %125, i32* %126
%127 = add nuw nsw i64 %122, 1
%128 = icmp eq i64 %127, %23
br i1 %128, label %39, label %121
}