#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 fabsf(double);
int run_saturator_zam(float *data, int length) {
  int i;
  double x;
  for (i = 0; i < length; i++) {
    x = data[i];
    data[i] = 2.f * x * (1.f - fabsf(x) * 0.5f);
  }
  return 0;
}


x86 assembly (clang, -O0):
<run_saturator_zam>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b8 <run_saturator_zam+0xa8>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xeb8(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <fabsf@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
movss  0xe7f(%rip),%xmm2
mulss  %xmm2,%xmm1
movss  0xe77(%rip),%xmm2
addss  %xmm2,%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <run_saturator_zam+0x16>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_saturator_zam>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    1221 <run_saturator_zam+0x111>
mov    %rdi,%r14
mov    %esi,%r15d
cmp    $0x1,%esi
jne    1132 <run_saturator_zam+0x22>
xor    %ebx,%ebx
jmp    11dd <run_saturator_zam+0xcd>
mov    %r15d,%r12d
and    $0xfffffffe,%r12d
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movss  (%r14,%rbx,4),%xmm0
cvtss2sd %xmm0,%xmm0
movaps %xmm0,%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
call   1030 <fabsf@plt>
movss  0xe9d(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xe95(%rip),%xmm1
subss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
mulsd  (%rsp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%r14,%rbx,4)
movss  0x4(%r14,%rbx,4),%xmm0
cvtss2sd %xmm0,%xmm0
movaps %xmm0,%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
call   1030 <fabsf@plt>
mulss  0xe53(%rip),%xmm0
movss  0xe4f(%rip),%xmm1
subss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
mulsd  (%rsp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x4(%r14,%rbx,4)
add    $0x2,%rbx
cmp    %rbx,%r12
jne    1140 <run_saturator_zam+0x30>
test   $0x1,%r15b
je     1221 <run_saturator_zam+0x111>
movss  (%r14,%rbx,4),%xmm0
cvtss2sd %xmm0,%xmm0
movaps %xmm0,%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
call   1030 <fabsf@plt>
mulss  0xe02(%rip),%xmm0
addss  0xdf6(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  (%rsp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%r14,%rbx,4)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @run_saturator_zam(float* %0, i32 %1) {
%3 = alloca float*
%4 = alloca i32
%5 = alloca i32
%6 = alloca double
store float* %0, float** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %7
7: ; preds = %31, %2
%8 = load i32, i32* %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %34
11: ; preds = %7
%12 = load float*, float** %3
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds float, float* %12, i64 %14
%16 = load float, float* %15
%17 = fpext float %16 to double
store double %17, double* %6
%18 = load double, double* %6
%19 = fmul double 2.000000e+00, %18
%20 = load double, double* %6
%21 = call float @fabsf(double %20)
%22 = fneg float %21
%23 = call float @llvm.fmuladd.f32(float %22, float 5.000000e-01, float 1.000000e+00)
%24 = fpext float %23 to double
%25 = fmul double %19, %24
%26 = fptrunc double %25 to float
%27 = load float*, float** %3
%28 = load i32, i32* %5
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds float, float* %27, i64 %29
store float %26, float* %30
br label %31
31: ; preds = %11
%32 = load i32, i32* %5
%33 = add nsw i32 %32, 1
store i32 %33, i32* %5
br label %7
34: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
define i32 @run_saturator_zam(float* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %51
4: ; preds = %2
%5 = zext i32 %1 to i64
%6 = and i64 %5, 1
%7 = icmp eq i32 %1, 1
br i1 %7, label %37, label %8
8: ; preds = %4
%9 = and i64 %5, 4294967294
br label %10
10: ; preds = %10, %8
%11 = phi i64 [ 0, %8 ], [ %34, %10 ]
%12 = phi i64 [ 0, %8 ], [ %35, %10 ]
%13 = getelementptr inbounds float, float* %0, i64 %11
%14 = load float, float* %13
%15 = fpext float %14 to double
%16 = fmul double %15, 2.000000e+00
%17 = tail call float @fabsf(double %15)
%18 = fneg float %17
%19 = tail call float @llvm.fmuladd.f32(float %18, float 5.000000e-01, float 1.000000e+00)
%20 = fpext float %19 to double
%21 = fmul double %16, %20
%22 = fptrunc double %21 to float
store float %22, float* %13
%23 = or i64 %11, 1
%24 = getelementptr inbounds float, float* %0, i64 %23
%25 = load float, float* %24
%26 = fpext float %25 to double
%27 = fmul double %26, 2.000000e+00
%28 = tail call float @fabsf(double %26)
%29 = fneg float %28
%30 = tail call float @llvm.fmuladd.f32(float %29, float 5.000000e-01, float 1.000000e+00)
%31 = fpext float %30 to double
%32 = fmul double %27, %31
%33 = fptrunc double %32 to float
store float %33, float* %24
%34 = add nuw nsw i64 %11, 2
%35 = add i64 %12, 2
%36 = icmp eq i64 %35, %9
br i1 %36, label %37, label %10
37: ; preds = %10, %4
%38 = phi i64 [ 0, %4 ], [ %34, %10 ]
%39 = icmp eq i64 %6, 0
br i1 %39, label %51, label %40
40: ; preds = %37
%41 = getelementptr inbounds float, float* %0, i64 %38
%42 = load float, float* %41
%43 = fpext float %42 to double
%44 = fmul double %43, 2.000000e+00
%45 = tail call float @fabsf(double %43)
%46 = fneg float %45
%47 = tail call float @llvm.fmuladd.f32(float %46, float 5.000000e-01, float 1.000000e+00)
%48 = fpext float %47 to double
%49 = fmul double %44, %48
%50 = fptrunc double %49 to float
store float %50, float* %41
br label %51
51: ; preds = %40, %37, %2
ret i32 0
}