#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 */
float INFINITY;
float abs_float(float);
void maxabs1D_float(float *input, int len, float *retVals) {
  int i;
  *retVals = -1;
  *(retVals + 1) = -INFINITY;
  for (i = 0; i < len; i++) {
    if (abs_float(input[i]) > *(retVals + 1)) {
      *(retVals + 1) = abs_float(input[i]);
      *retVals = (float)i;
    }
  }
}


x86 assembly (clang, -O0):
<maxabs1D_float>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movss  0xed1(%rip),%xmm0
movss  %xmm0,(%rax)
mov    0x2eae(%rip),%rax
movss  (%rax),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,0x4(%rax)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11c2 <maxabs1D_float+0xb2>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
call   1030 <abs_float@plt>
mov    -0x18(%rbp),%rax
ucomiss 0x4(%rax),%xmm0
jbe    11af <maxabs1D_float+0x9f>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
call   1030 <abs_float@plt>
mov    -0x18(%rbp),%rax
movss  %xmm0,0x4(%rax)
cvtsi2ssl -0x1c(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
jmp    11b4 <maxabs1D_float+0xa4>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    115b <maxabs1D_float+0x4b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<maxabs1D_float>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
movl   $0xbf800000,(%rdx)
mov    0x2ec3(%rip),%rax
movss  (%rax),%xmm0
xorps  0xed0(%rip),%xmm0
movss  %xmm0,0x4(%rdx)
test   %esi,%esi
jle    118d <maxabs1D_float+0x7d>
mov    %rdx,%r12
mov    %rdi,%r14
mov    %esi,%r15d
xor    %ebx,%ebx
jmp    1159 <maxabs1D_float+0x49>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    %rbx,%r15
je     118d <maxabs1D_float+0x7d>
movss  (%r14,%rbx,4),%xmm0
call   1030 <abs_float@plt>
ucomiss 0x4(%r12),%xmm0
jbe    1150 <maxabs1D_float+0x40>
movss  (%r14,%rbx,4),%xmm0
call   1030 <abs_float@plt>
movss  %xmm0,0x4(%r12)
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
movss  %xmm0,(%r12)
jmp    1150 <maxabs1D_float+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@INFINITY = global float 0.000000e+00
define void @maxabs1D_float(float* %0, i32 %1, float* %2) {
%4 = alloca float*
%5 = alloca i32
%6 = alloca float*
%7 = alloca i32
store float* %0, float** %4
store i32 %1, i32* %5
store float* %2, float** %6
%8 = load float*, float** %6
store float -1.000000e+00, float* %8
%9 = load float, float* @INFINITY
%10 = fneg float %9
%11 = load float*, float** %6
%12 = getelementptr inbounds float, float* %11, i64 1
store float %10, float* %12
store i32 0, i32* %7
br label %13
13: ; preds = %41, %3
%14 = load i32, i32* %7
%15 = load i32, i32* %5
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %44
17: ; preds = %13
%18 = load float*, float** %4
%19 = load i32, i32* %7
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds float, float* %18, i64 %20
%22 = load float, float* %21
%23 = call float @abs_float(float %22)
%24 = load float*, float** %6
%25 = getelementptr inbounds float, float* %24, i64 1
%26 = load float, float* %25
%27 = fcmp ogt float %23, %26
br i1 %27, label %28, label %40
28: ; preds = %17
%29 = load float*, float** %4
%30 = load i32, i32* %7
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds float, float* %29, i64 %31
%33 = load float, float* %32
%34 = call float @abs_float(float %33)
%35 = load float*, float** %6
%36 = getelementptr inbounds float, float* %35, i64 1
store float %34, float* %36
%37 = load i32, i32* %7
%38 = sitofp i32 %37 to float
%39 = load float*, float** %6
store float %38, float* %39
br label %40
40: ; preds = %28, %17
br label %41
41: ; preds = %40
%42 = load i32, i32* %7
%43 = add nsw i32 %42, 1
store i32 %43, i32* %7
br label %13
44: ; preds = %13
ret void
}

LLVM IR (-O2):
@INFINITY = global float 0.000000e+00
define void @maxabs1D_float(float* nocapture %0, i32 %1, float* nocapture %2) {
store float -1.000000e+00, float* %2
%4 = load float, float* @INFINITY
%5 = fneg float %4
%6 = getelementptr inbounds float, float* %2, i64 1
store float %5, float* %6
%7 = icmp sgt i32 %1, 0
br i1 %7, label %8, label %25
8: ; preds = %3
%9 = zext i32 %1 to i64
br label %10
10: ; preds = %8, %22
%11 = phi i64 [ 0, %8 ], [ %23, %22 ]
%12 = getelementptr inbounds float, float* %0, i64 %11
%13 = load float, float* %12
%14 = tail call float @abs_float(float %13)
%15 = load float, float* %6
%16 = fcmp ogt float %14, %15
br i1 %16, label %17, label %22
17: ; preds = %10
%18 = load float, float* %12
%19 = tail call float @abs_float(float %18)
store float %19, float* %6
%20 = trunc i64 %11 to i32
%21 = sitofp i32 %20 to float
store float %21, float* %2
br label %22
22: ; preds = %10, %17
%23 = add nuw nsw i64 %11, 1
%24 = icmp eq i64 %23, %9
br i1 %24, label %25, label %10
25: ; preds = %22, %3
ret void
}