#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 */
double dmax(double, double);
double dmaxa(double a[], int length) {
  double max = a[0];
  int i;
  for (i = 0; i < length; i++) {
    max = dmax(max, a[i]);
  }
  return max;
}


x86 assembly (clang, -O0):
<dmaxa>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1169 <dmaxa+0x59>
movsd  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
call   1030 <dmax@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1133 <dmaxa+0x23>
movsd  -0x18(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dmaxa>:
push   %rbp
push   %r14
push   %rbx
movsd  (%rdi),%xmm0
test   %esi,%esi
jle    1154 <dmaxa+0x44>
mov    %esi,%ebp
mov    %rdi,%r14
movaps %xmm0,%xmm1
call   1030 <dmax@plt>
cmp    $0x1,%ebp
je     1154 <dmaxa+0x44>
mov    %ebp,%ebp
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
movsd  (%r14,%rbx,8),%xmm1
call   1030 <dmax@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1140 <dmaxa+0x30>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define double @dmaxa(double* %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca double
%6 = alloca i32
store double* %0, double** %3
store i32 %1, i32* %4
%7 = load double*, double** %3
%8 = getelementptr inbounds double, double* %7, i64 0
%9 = load double, double* %8
store double %9, double* %5
store i32 0, i32* %6
br label %10
10: ; preds = %22, %2
%11 = load i32, i32* %6
%12 = load i32, i32* %4
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %25
14: ; preds = %10
%15 = load double, double* %5
%16 = load double*, double** %3
%17 = load i32, i32* %6
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds double, double* %16, i64 %18
%20 = load double, double* %19
%21 = call double @dmax(double %15, double %20)
store double %21, double* %5
br label %22
22: ; preds = %14
%23 = load i32, i32* %6
%24 = add nsw i32 %23, 1
store i32 %24, i32* %6
br label %10
25: ; preds = %10
%26 = load double, double* %5
ret double %26
}

LLVM IR (-O2):
define double @dmaxa(double* nocapture %0, i32 %1) {
%3 = load double, double* %0
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %17
5: ; preds = %2
%6 = zext i32 %1 to i64
%7 = tail call double @dmax(double %3, double %3)
%8 = icmp eq i32 %1, 1
br i1 %8, label %17, label %9
9: ; preds = %5, %9
%10 = phi i64 [ %15, %9 ], [ 1, %5 ]
%11 = phi double [ %14, %9 ], [ %7, %5 ]
%12 = getelementptr inbounds double, double* %0, i64 %10
%13 = load double, double* %12
%14 = tail call double @dmax(double %11, double %13)
%15 = add nuw nsw i64 %10, 1
%16 = icmp eq i64 %15, %6
br i1 %16, label %17, label %9
17: ; preds = %9, %5, %2
%18 = phi double [ %3, %2 ], [ %7, %5 ], [ %14, %9 ]
ret double %18
}