#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 fmax(int /*<<< orphan*/, double);
void prox_l1(double *x, const int n, const double rho) {
  int i;
#pragma omp parallel for
  for (i = 0; i < n; i++) {
    x[i] = fmax(0, x[i] - 1.0 / rho) - fmax(0, -x[i] - 1.0 / rho);
  }
}


x86 assembly (clang, -O0):
<prox_l1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11c4 <prox_l1+0xb4>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  0xeb4(%rip),%xmm1
divsd  -0x18(%rbp),%xmm1
subsd  %xmm1,%xmm0
xor    %edi,%edi
call   1030 <fmax@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe73(%rip),%xmm1
divsd  -0x18(%rbp),%xmm1
subsd  %xmm1,%xmm0
xor    %edi,%edi
call   1030 <fmax@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
subsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112b <prox_l1+0x1b>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prox_l1>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %esi,%esi
jle    1238 <prox_l1+0x128>
mov    %rdi,%r14
movsd  0xed2(%rip),%xmm1
divsd  %xmm0,%xmm1
mov    %esi,%r15d
cmp    $0x1,%esi
movsd  %xmm1,0x10(%rsp)
jne    1147 <prox_l1+0x37>
xor    %ebx,%ebx
jmp    11f0 <prox_l1+0xe0>
mov    %r15d,%r12d
and    $0xfffffffe,%r12d
xor    %ebx,%ebx
movsd  (%r14,%rbx,8),%xmm0
subsd  %xmm1,%xmm0
xor    %edi,%edi
call   1030 <fmax@plt>
movsd  %xmm0,0x8(%rsp)
movsd  (%r14,%rbx,8),%xmm0
movapd 0xe9b(%rip),%xmm1
xorpd  %xmm1,%xmm0
subsd  0x10(%rsp),%xmm0
xor    %edi,%edi
call   1030 <fmax@plt>
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%r14,%rbx,8)
movsd  0x8(%r14,%rbx,8),%xmm0
subsd  0x10(%rsp),%xmm0
xor    %edi,%edi
call   1030 <fmax@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%r14,%rbx,8),%xmm0
xorpd  0xe51(%rip),%xmm0
subsd  0x10(%rsp),%xmm0
xor    %edi,%edi
call   1030 <fmax@plt>
movsd  0x10(%rsp),%xmm1
movsd  0x8(%rsp),%xmm2
subsd  %xmm0,%xmm2
movsd  %xmm2,0x8(%r14,%rbx,8)
add    $0x2,%rbx
cmp    %rbx,%r12
jne    1150 <prox_l1+0x40>
test   $0x1,%r15b
je     1238 <prox_l1+0x128>
movsd  (%r14,%rbx,8),%xmm0
subsd  %xmm1,%xmm0
xor    %edi,%edi
call   1030 <fmax@plt>
movsd  %xmm0,0x8(%rsp)
movsd  (%r14,%rbx,8),%xmm0
xorpd  0xdf5(%rip),%xmm0
subsd  0x10(%rsp),%xmm0
xor    %edi,%edi
call   1030 <fmax@plt>
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%r14,%rbx,8)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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