#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);
void array_maxabs_location_(double *x, int *n, int *loc) {
  int i;
  double mx;
  mx = 0;
  for (i = 0; i < *n; i++) {
    if (fabs(*(x + i)) > mx) {
      mx = fabs(*(x + i));
      *loc = i;
    }
  }
}


x86 assembly (clang, -O0):
<array_maxabs_location_>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%eax
jge    118a <array_maxabs_location_+0x8a>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movaps 0xebe(%rip),%xmm1
pand   %xmm1,%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    1177 <array_maxabs_location_+0x77>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movaps 0xe9b(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    117c <array_maxabs_location_+0x7c>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    111f <array_maxabs_location_+0x1f>
pop    %rbp
ret

x86 assembly (clang, -O2):
<array_maxabs_location_>:
mov    (%rsi),%r8d
test   %r8d,%r8d
jle    1146 <array_maxabs_location_+0x46>
xorpd  %xmm1,%xmm1
xor    %ecx,%ecx
movapd 0xeea(%rip),%xmm0
jmp    112c <array_maxabs_location_+0x2c>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rcx
movslq %r8d,%rax
cmp    %rax,%rcx
jge    1146 <array_maxabs_location_+0x46>
movsd  (%rdi,%rcx,8),%xmm2
andpd  %xmm0,%xmm2
ucomisd %xmm1,%xmm2
jbe    1120 <array_maxabs_location_+0x20>
mov    %ecx,(%rdx)
mov    (%rsi),%r8d
movapd %xmm2,%xmm1
jmp    1120 <array_maxabs_location_+0x20>
ret

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

LLVM IR (-O2):
define void @array_maxabs_location_(double* nocapture %0, i32* nocapture %1, i32* nocapture writeonly %2) {
%4 = load i32, i32* %1
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %23
6: ; preds = %3, %17
%7 = phi i32 [ %18, %17 ], [ %4, %3 ]
%8 = phi i64 [ %20, %17 ], [ 0, %3 ]
%9 = phi double [ %19, %17 ], [ 0.000000e+00, %3 ]
%10 = getelementptr inbounds double, double* %0, i64 %8
%11 = load double, double* %10
%12 = tail call double @llvm.fabs.f64(double %11)
%13 = fcmp ogt double %12, %9
br i1 %13, label %14, label %17
14: ; preds = %6
%15 = trunc i64 %8 to i32
store i32 %15, i32* %2
%16 = load i32, i32* %1
br label %17
17: ; preds = %6, %14
%18 = phi i32 [ %16, %14 ], [ %7, %6 ]
%19 = phi double [ %12, %14 ], [ %9, %6 ]
%20 = add nuw nsw i64 %8, 1
%21 = sext i32 %18 to i64
%22 = icmp slt i64 %20, %21
br i1 %22, label %6, label %23
23: ; preds = %17, %3
ret void
}