#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 FindMaxSubarray(double *, int, int, double *, int *, int *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  double A[16] = {13, -3, -25, 20, -3,  -16, -23, 18,
                  20, -7, 12,  -5, -22, 15,  -4,  7};
  int low = 0;
  int high = 15;
  double MaxSum;
  int SubLow;
  int SubHigh;
  int ret = FindMaxSubarray(A, low, high, &MaxSum, &SubLow, &SubHigh);
  if (ret) {
    printf("FindMaxSubarray error %d\n", ret);
    return 0;
  }
  printf("Êý×éA£º\n");
  for (int i = low; i <= high; i++) {
    printf("%lf ", A[i]);
  }
  printf("\n");
  printf("AµÄºÍ×î´óµÄ·Ç¿ÕÁ¬Ðø×ÓÊý×é£º\n");
  for (int i = SubLow; i <= SubHigh; i++) {
    printf("A[%d]=%lf\t", i, A[i]);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x90(%rbp),%rdi
lea    0xeb0(%rip),%rsi
mov    $0x80,%edx
call   1040 <memcpy@plt>
movl   $0x0,-0x94(%rbp)
movl   $0xf,-0x98(%rbp)
lea    -0x90(%rbp),%rdi
mov    -0x94(%rbp),%esi
mov    -0x98(%rbp),%edx
lea    -0xa0(%rbp),%rcx
lea    -0xa4(%rbp),%r8
lea    -0xa8(%rbp),%r9
call   1050 <FindMaxSubarray@plt>
mov    %eax,-0xac(%rbp)
cmpl   $0x0,-0xac(%rbp)
je     11ce <main+0x9e>
mov    -0xac(%rbp),%esi
lea    0xec5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12b3 <main+0x183>
lea    0xec5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x94(%rbp),%eax
mov    %eax,-0xb0(%rbp)
mov    -0xb0(%rbp),%eax
cmp    -0x98(%rbp),%eax
jg     122c <main+0xfc>
movslq -0xb0(%rbp),%rax
movsd  -0x90(%rbp,%rax,8),%xmm0
ff ff
lea    0xe98(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0xb0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb0(%rbp)
jmp    11e8 <main+0xb8>
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xa4(%rbp),%eax
mov    %eax,-0xb4(%rbp)
mov    -0xb4(%rbp),%eax
cmp    -0xa8(%rbp),%eax
jg     129e <main+0x16e>
mov    -0xb4(%rbp),%esi
movslq -0xb4(%rbp),%rax
movsd  -0x90(%rbp,%rax,8),%xmm0
ff ff
lea    0xe62(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
jmp    1254 <main+0x124>
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0xa0,%rsp
movaps 0xf1e(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movaps 0xeff(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xee3(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xec7(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xeab(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xe8f(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xe73(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe57(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0x10(%rsp),%rdi
lea    0x98(%rsp),%rcx
lea    0xc(%rsp),%r8
lea    0x8(%rsp),%r9
xor    %esi,%esi
mov    $0xf,%edx
call   1060 <FindMaxSubarray@plt>
test   %eax,%eax
je     11ea <main+0xaa>
lea    0xea4(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    136d <main+0x22d>
lea    0xeb9(%rip),%rdi
call   1040 <puts@plt>
movsd  0x10(%rsp),%xmm0
lea    0xe97(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x18(%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x20(%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x28(%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x30(%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x38(%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x40(%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x48(%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x50(%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x58(%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x60(%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x68(%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x70(%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x78(%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x80(%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x88(%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xda4(%rip),%rdi
call   1040 <puts@plt>
mov    0xc(%rsp),%ebp
cmp    0x8(%rsp),%ebp
jg     1363 <main+0x223>
movslq %ebp,%rbx
add    $0xffffffffffffffff,%rbx
lea    0xd6e(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  0x18(%rsp,%rbx,8),%xmm0
mov    %r14,%rdi
mov    %ebp,%esi
mov    $0x1,%al
call   1050 <printf@plt>
movslq 0x8(%rsp),%rax
add    $0x1,%rbx
add    $0x1,%ebp
cmp    %rax,%rbx
jl     1340 <main+0x200>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.A = [16 x double] [double 1.300000e+01, double -3.000000e+00, double -2.500000e+01, double 2.000000e+01, double -3.000000e+00, double -1.600000e+01, double -2.300000e+01, double 1.800000e+01, double 2.000000e+01, double -7.000000e+00, double 1.200000e+01, double -5.000000e+00, double -2.200000e+01, double 1.500000e+01, double -4.000000e+00, double 7.000000e+00]
@.str = [26 x i8] c"FindMaxSubarray error %d\0A\00"
@.str.1 = [15 x i8] c"\C3\8A\C3\BD\C3\97\C3\A9A\C2\A3\C2\BA\0A\00"
@.str.2 = [5 x i8] c"%lf \00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [55 x i8] c"A\C2\B5\C3\84\C2\BA\C3\8D\C3\97\C3\AE\C2\B4\C3\B3\C2\B5\C3\84\C2\B7\C3\87\C2\BF\C3\95\C3\81\C2\AC\C3\90\C3\B8\C3\97\C3\93\C3\8A\C3\BD\C3\97\C3\A9\C2\A3\C2\BA\0A\00"
@.str.5 = [11 x i8] c"A[%d]=%lf\09\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [16 x double]
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %1
%11 = bitcast [16 x double]* %2 to i8*
store i32 0, i32* %3
store i32 15, i32* %4
%12 = getelementptr inbounds [16 x double], [16 x double]* %2, i64 0, i64 0
%13 = load i32, i32* %3
%14 = load i32, i32* %4
%15 = call i32 @FindMaxSubarray(double* %12, i32 %13, i32 %14, double* %5, i32* %6, i32* %7)
store i32 %15, i32* %8
%16 = load i32, i32* %8
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %0
%19 = load i32, i32* %8
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %19)
store i32 0, i32* %1
br label %57
21: ; preds = %0
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%23 = load i32, i32* %3
store i32 %23, i32* %9
br label %24
24: ; preds = %34, %21
%25 = load i32, i32* %9
%26 = load i32, i32* %4
%27 = icmp sle i32 %25, %26
br i1 %27, label %28, label %37
28: ; preds = %24
%29 = load i32, i32* %9
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [16 x double], [16 x double]* %2, i64 0, i64 %30
%32 = load double, double* %31
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %32)
br label %34
34: ; preds = %28
%35 = load i32, i32* %9
%36 = add nsw i32 %35, 1
store i32 %36, i32* %9
br label %24
37: ; preds = %24
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.4, i64 0, i64 0))
%40 = load i32, i32* %6
store i32 %40, i32* %10
br label %41
41: ; preds = %52, %37
%42 = load i32, i32* %10
%43 = load i32, i32* %7
%44 = icmp sle i32 %42, %43
br i1 %44, label %45, label %55
45: ; preds = %41
%46 = load i32, i32* %10
%47 = load i32, i32* %10
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [16 x double], [16 x double]* %2, i64 0, i64 %48
%50 = load double, double* %49
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i32 %46, double %50)
br label %52
52: ; preds = %45
%53 = load i32, i32* %10
%54 = add nsw i32 %53, 1
store i32 %54, i32* %10
br label %41
55: ; preds = %41
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %1
br label %57
57: ; preds = %55, %18
%58 = load i32, i32* %1
ret i32 %58
}

LLVM IR (-O2):
@__const.main.A = [16 x double] [double 1.300000e+01, double -3.000000e+00, double -2.500000e+01, double 2.000000e+01, double -3.000000e+00, double -1.600000e+01, double -2.300000e+01, double 1.800000e+01, double 2.000000e+01, double -7.000000e+00, double 1.200000e+01, double -5.000000e+00, double -2.200000e+01, double 1.500000e+01, double -4.000000e+00, double 7.000000e+00]
@.str = [26 x i8] c"FindMaxSubarray error %d\0A\00"
@.str.2 = [5 x i8] c"%lf \00"
@.str.5 = [11 x i8] c"A[%d]=%lf\09\00"
@str = [14 x i8] c"\C3\8A\C3\BD\C3\97\C3\A9A\C2\A3\C2\BA\00"
@str.6 = [54 x i8] c"A\C2\B5\C3\84\C2\BA\C3\8D\C3\97\C3\AE\C2\B4\C3\B3\C2\B5\C3\84\C2\B7\C3\87\C2\BF\C3\95\C3\81\C2\AC\C3\90\C3\B8\C3\97\C3\93\C3\8A\C3\BD\C3\97\C3\A9\C2\A3\C2\BA\00"
define i32 @main() {
%1 = alloca [16 x double]
%2 = alloca double
%3 = alloca i32
%4 = alloca i32
%5 = bitcast [16 x double]* %1 to i8*
%6 = bitcast double* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = getelementptr inbounds [16 x double], [16 x double]* %1, i64 0, i64 0
%10 = call i32 @FindMaxSubarray(double* %9, i32 0, i32 15, double* %2, i32* %3, i32* %4)
%11 = icmp eq i32 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %0
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %10)
br label %82
14: ; preds = %0
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
%16 = load double, double* %9
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %16)
%18 = getelementptr inbounds [16 x double], [16 x double]* %1, i64 0, i64 1
%19 = load double, double* %18
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %19)
%21 = getelementptr inbounds [16 x double], [16 x double]* %1, i64 0, i64 2
%22 = load double, double* %21
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %22)
%24 = getelementptr inbounds [16 x double], [16 x double]* %1, i64 0, i64 3
%25 = load double, double* %24
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %25)
%27 = getelementptr inbounds [16 x double], [16 x double]* %1, i64 0, i64 4
%28 = load double, double* %27
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %28)
%30 = getelementptr inbounds [16 x double], [16 x double]* %1, i64 0, i64 5
%31 = load double, double* %30
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %31)
%33 = getelementptr inbounds [16 x double], [16 x double]* %1, i64 0, i64 6
%34 = load double, double* %33
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %34)
%36 = getelementptr inbounds [16 x double], [16 x double]* %1, i64 0, i64 7
%37 = load double, double* %36
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %37)
%39 = getelementptr inbounds [16 x double], [16 x double]* %1, i64 0, i64 8
%40 = load double, double* %39
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %40)
%42 = getelementptr inbounds [16 x double], [16 x double]* %1, i64 0, i64 9
%43 = load double, double* %42
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %43)
%45 = getelementptr inbounds [16 x double], [16 x double]* %1, i64 0, i64 10
%46 = load double, double* %45
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %46)
%48 = getelementptr inbounds [16 x double], [16 x double]* %1, i64 0, i64 11
%49 = load double, double* %48
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %49)
%51 = getelementptr inbounds [16 x double], [16 x double]* %1, i64 0, i64 12
%52 = load double, double* %51
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %52)
%54 = getelementptr inbounds [16 x double], [16 x double]* %1, i64 0, i64 13
%55 = load double, double* %54
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %55)
%57 = getelementptr inbounds [16 x double], [16 x double]* %1, i64 0, i64 14
%58 = load double, double* %57
%59 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %58)
%60 = getelementptr inbounds [16 x double], [16 x double]* %1, i64 0, i64 15
%61 = load double, double* %60
%62 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %61)
%63 = call i32 @putchar(i32 10)
%64 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str.6, i64 0, i64 0))
%65 = load i32, i32* %3
%66 = load i32, i32* %4
%67 = icmp sgt i32 %65, %66
br i1 %67, label %70, label %68
68: ; preds = %14
%69 = sext i32 %65 to i64
br label %72
70: ; preds = %72, %14
%71 = call i32 @putchar(i32 10)
br label %82
72: ; preds = %68, %72
%73 = phi i64 [ %69, %68 ], [ %78, %72 ]
%74 = getelementptr inbounds [16 x double], [16 x double]* %1, i64 0, i64 %73
%75 = load double, double* %74
%76 = trunc i64 %73 to i32
%77 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i32 %76, double %75)
%78 = add nsw i64 %73, 1
%79 = load i32, i32* %4
%80 = sext i32 %79 to i64
%81 = icmp slt i64 %73, %80
br i1 %81, label %72, label %70
82: ; preds = %70, %12
ret i32 0
}