#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 sqrt(double);
void prox_log_barrier(double *x, const int n, const double rho) {
  int i;
#pragma omp parallel for
  for (i = 0; i < n; i++) {
    x[i] = 0.5 * (x[i] + sqrt(x[i] * x[i] + 4. / rho));
  }
}


x86 assembly (clang, -O0):
<prox_log_barrier>:
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    11ad <prox_log_barrier+0x9d>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  0xe9d(%rip),%xmm1
divsd  -0x18(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
movsd  -0x28(%rbp),%xmm1
addsd  %xmm0,%xmm1
movsd  0xe72(%rip),%xmm0
mulsd  %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_log_barrier+0x1b>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prox_log_barrier>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %esi,%esi
jle    126a <prox_log_barrier+0x15a>
mov    %rdi,%r14
movsd  0xed2(%rip),%xmm1
divsd  %xmm0,%xmm1
mov    %esi,%r15d
cmp    $0x1,%esi
jne    116f <prox_log_barrier+0x5f>
xor    %ebx,%ebx
test   $0x1,%r15b
je     126a <prox_log_barrier+0x15a>
movsd  (%r14,%rbx,8),%xmm2
movapd %xmm2,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1247 <prox_log_barrier+0x137>
sqrtsd %xmm0,%xmm0
jmp    1258 <prox_log_barrier+0x148>
mov    %r15d,%r12d
and    $0xfffffffe,%r12d
xor    %ebx,%ebx
xorpd  %xmm2,%xmm2
movsd  0xe84(%rip),%xmm3
movsd  %xmm1,0x8(%rsp)
jmp    11cf <prox_log_barrier+0xbf>
nopl   0x0(%rax)
movsd  %xmm4,0x10(%rsp)
call   1030 <sqrt@plt>
movsd  0x10(%rsp),%xmm4
movsd  0xe5f(%rip),%xmm3
xorpd  %xmm2,%xmm2
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm4
mulsd  %xmm3,%xmm4
movsd  %xmm4,0x8(%r14,%rbx,8)
add    $0x2,%rbx
cmp    %rbx,%r12
je     113c <prox_log_barrier+0x2c>
movsd  (%r14,%rbx,8),%xmm4
movapd %xmm4,%xmm0
mulsd  %xmm4,%xmm0
addsd  %xmm1,%xmm0
ucomisd %xmm2,%xmm0
jb     11f0 <prox_log_barrier+0xe0>
sqrtsd %xmm0,%xmm0
jmp    1213 <prox_log_barrier+0x103>
nopl   (%rax)
movsd  %xmm4,0x10(%rsp)
call   1030 <sqrt@plt>
movsd  0x10(%rsp),%xmm4
movsd  0xdff(%rip),%xmm3
xorpd  %xmm2,%xmm2
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm4
mulsd  %xmm3,%xmm4
movsd  %xmm4,(%r14,%rbx,8)
movsd  0x8(%r14,%rbx,8),%xmm4
movapd %xmm4,%xmm0
mulsd  %xmm4,%xmm0
addsd  %xmm1,%xmm0
ucomisd %xmm2,%xmm0
jb     1190 <prox_log_barrier+0x80>
sqrtsd %xmm0,%xmm0
jmp    11b3 <prox_log_barrier+0xa3>
movsd  %xmm2,0x8(%rsp)
call   1030 <sqrt@plt>
movsd  0x8(%rsp),%xmm2
addsd  %xmm0,%xmm2
mulsd  0xda4(%rip),%xmm2
movsd  %xmm2,(%r14,%rbx,8)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @prox_log_barrier(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 = %38, %3
%9 = load i32, i32* %7
%10 = load i32, i32* %5
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %41
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** %4
%19 = load i32, i32* %7
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds double, double* %18, i64 %20
%22 = load double, double* %21
%23 = load double*, double** %4
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double, double* %23, i64 %25
%27 = load double, double* %26
%28 = load double, double* %6
%29 = fdiv double 4.000000e+00, %28
%30 = call double @llvm.fmuladd.f64(double %22, double %27, double %29)
%31 = call double @sqrt(double %30)
%32 = fadd double %17, %31
%33 = fmul double 5.000000e-01, %32
%34 = load double*, double** %4
%35 = load i32, i32* %7
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds double, double* %34, i64 %36
store double %33, double* %37
br label %38
38: ; preds = %12
%39 = load i32, i32* %7
%40 = add nsw i32 %39, 1
store i32 %40, i32* %7
br label %8
41: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @prox_log_barrier(double* nocapture %0, i32 %1, double %2) {
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %41
5: ; preds = %3
%6 = fdiv double 4.000000e+00, %2
%7 = zext i32 %1 to i64
%8 = and i64 %7, 1
%9 = icmp eq i32 %1, 1
br i1 %9, label %31, label %10
10: ; preds = %5
%11 = and i64 %7, 4294967294
br label %12
12: ; preds = %12, %10
%13 = phi i64 [ 0, %10 ], [ %28, %12 ]
%14 = phi i64 [ 0, %10 ], [ %29, %12 ]
%15 = getelementptr inbounds double, double* %0, i64 %13
%16 = load double, double* %15
%17 = tail call double @llvm.fmuladd.f64(double %16, double %16, double %6)
%18 = tail call double @sqrt(double %17)
%19 = fadd double %16, %18
%20 = fmul double %19, 5.000000e-01
store double %20, double* %15
%21 = or i64 %13, 1
%22 = getelementptr inbounds double, double* %0, i64 %21
%23 = load double, double* %22
%24 = tail call double @llvm.fmuladd.f64(double %23, double %23, double %6)
%25 = tail call double @sqrt(double %24)
%26 = fadd double %23, %25
%27 = fmul double %26, 5.000000e-01
store double %27, double* %22
%28 = add nuw nsw i64 %13, 2
%29 = add i64 %14, 2
%30 = icmp eq i64 %29, %11
br i1 %30, label %31, label %12
31: ; preds = %12, %5
%32 = phi i64 [ 0, %5 ], [ %28, %12 ]
%33 = icmp eq i64 %8, 0
br i1 %33, label %41, label %34
34: ; preds = %31
%35 = getelementptr inbounds double, double* %0, i64 %32
%36 = load double, double* %35
%37 = tail call double @llvm.fmuladd.f64(double %36, double %36, double %6)
%38 = tail call double @sqrt(double %37)
%39 = fadd double %36, %38
%40 = fmul double %39, 5.000000e-01
store double %40, double* %35
br label %41
41: ; preds = %34, %31, %3
ret void
}