#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 fabs(double);
double maxAbsVec(double a[], int n) {
  int i;
  double max = -1E100;
  for (i = n; i-- > 0;)
    if (fabs(a[i]) > max)
      max = fabs(a[i]);
  return max;
}


x86 assembly (clang, -O0):
<maxAbsVec>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movsd  0xeed(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x10(%rbp)
cmp    $0x0,%eax
jle    1177 <maxAbsVec+0x77>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movaps 0xeca(%rip),%xmm1
pand   %xmm1,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1172 <maxAbsVec+0x72>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movaps 0xea7(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    111e <maxAbsVec+0x1e>
movsd  -0x18(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<maxAbsVec>:
test   %esi,%esi
jle    1119 <maxAbsVec+0x19>
mov    %esi,%eax
test   $0x1,%al
jne    1122 <maxAbsVec+0x22>
movsd  0xeee(%rip),%xmm0
cmp    $0x1,%esi
jne    1142 <maxAbsVec+0x42>
jmp    117c <maxAbsVec+0x7c>
movsd  0xedf(%rip),%xmm0
ret
add    $0xffffffffffffffff,%rax
mov    %eax,%ecx
movsd  (%rdi,%rcx,8),%xmm0
andpd  0xedb(%rip),%xmm0
maxsd  0xec3(%rip),%xmm0
cmp    $0x1,%esi
je     117c <maxAbsVec+0x7c>
add    $0xfffffffffffffffe,%rax
movapd 0xec2(%rip),%xmm1
xchg   %ax,%ax
lea    0x1(%rax),%rcx
mov    %ecx,%edx
movsd  (%rdi,%rdx,8),%xmm2
andpd  %xmm1,%xmm2
maxsd  %xmm0,%xmm2
mov    %eax,%edx
movsd  (%rdi,%rdx,8),%xmm0
andpd  %xmm1,%xmm0
maxsd  %xmm2,%xmm0
add    $0xfffffffffffffffe,%rax
cmp    $0x1,%rcx
ja     1150 <maxAbsVec+0x50>
ret

LLVM IR (-O0):
define double @maxAbsVec(double* %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca i32
%6 = alloca double
store double* %0, double** %3
store i32 %1, i32* %4
store double -1.000000e+100, double* %6
%7 = load i32, i32* %4
store i32 %7, i32* %5
br label %8
8: ; preds = %28, %2
%9 = load i32, i32* %5
%10 = add nsw i32 %9, -1
store i32 %10, i32* %5
%11 = icmp sgt i32 %9, 0
br i1 %11, label %12, label %29
12: ; preds = %8
%13 = load double*, double** %3
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds double, double* %13, i64 %15
%17 = load double, double* %16
%18 = call double @llvm.fabs.f64(double %17)
%19 = load double, double* %6
%20 = fcmp ogt double %18, %19
br i1 %20, label %21, label %28
21: ; preds = %12
%22 = load double*, double** %3
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds double, double* %22, i64 %24
%26 = load double, double* %25
%27 = call double @llvm.fabs.f64(double %26)
store double %27, double* %6
br label %28
28: ; preds = %21, %12
br label %8
29: ; preds = %8
%30 = load double, double* %6
ret double %30
}

LLVM IR (-O2):
define double @maxAbsVec(double* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %39
4: ; preds = %2
%5 = zext i32 %1 to i64
%6 = and i64 %5, 1
%7 = icmp eq i64 %6, 0
br i1 %7, label %16, label %8
8: ; preds = %4
%9 = add nsw i64 %5, -1
%10 = and i64 %9, 4294967295
%11 = getelementptr inbounds double, double* %0, i64 %10
%12 = load double, double* %11
%13 = tail call double @llvm.fabs.f64(double %12)
%14 = fcmp ogt double %13, -1.000000e+100
%15 = select i1 %14, double %13, double -1.000000e+100
br label %16
16: ; preds = %8, %4
%17 = phi i64 [ %5, %4 ], [ %9, %8 ]
%18 = phi double [ -1.000000e+100, %4 ], [ %15, %8 ]
%19 = phi double [ undef, %4 ], [ %15, %8 ]
%20 = icmp eq i32 %1, 1
br i1 %20, label %39, label %21
21: ; preds = %16, %21
%22 = phi i64 [ %31, %21 ], [ %17, %16 ]
%23 = phi double [ %37, %21 ], [ %18, %16 ]
%24 = add nsw i64 %22, -1
%25 = and i64 %24, 4294967295
%26 = getelementptr inbounds double, double* %0, i64 %25
%27 = load double, double* %26
%28 = tail call double @llvm.fabs.f64(double %27)
%29 = fcmp ogt double %28, %23
%30 = select i1 %29, double %28, double %23
%31 = add nsw i64 %22, -2
%32 = and i64 %31, 4294967295
%33 = getelementptr inbounds double, double* %0, i64 %32
%34 = load double, double* %33
%35 = tail call double @llvm.fabs.f64(double %34)
%36 = fcmp ogt double %35, %30
%37 = select i1 %36, double %35, double %30
%38 = icmp ugt i64 %24, 1
br i1 %38, label %21, label %39
39: ; preds = %16, %21, %2
%40 = phi double [ -1.000000e+100, %2 ], [ %19, %16 ], [ %37, %21 ]
ret double %40
}