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


x86 assembly (clang, -O0):
<project_pos>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1161 <project_pos+0x51>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xor    %edi,%edi
call   1030 <fmax@plt>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <project_pos+0x16>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<project_pos>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    11dc <project_pos+0xcc>
mov    %rdi,%r12
mov    %esi,%r15d
lea    -0x1(%r15),%rax
mov    %r15d,%r14d
and    $0x3,%r14d
cmp    $0x3,%rax
jae    113b <project_pos+0x2b>
xor    %ebx,%ebx
jmp    11ab <project_pos+0x9b>
and    $0xfffffffc,%r15d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  (%r12,%rbx,8),%xmm0
xor    %edi,%edi
call   1030 <fmax@plt>
movsd  %xmm0,(%r12,%rbx,8)
movsd  0x8(%r12,%rbx,8),%xmm0
xor    %edi,%edi
call   1030 <fmax@plt>
movsd  %xmm0,0x8(%r12,%rbx,8)
movsd  0x10(%r12,%rbx,8),%xmm0
xor    %edi,%edi
call   1030 <fmax@plt>
movsd  %xmm0,0x10(%r12,%rbx,8)
movsd  0x18(%r12,%rbx,8),%xmm0
xor    %edi,%edi
call   1030 <fmax@plt>
movsd  %xmm0,0x18(%r12,%rbx,8)
add    $0x4,%rbx
cmp    %rbx,%r15
jne    1150 <project_pos+0x40>
test   %r14,%r14
je     11dc <project_pos+0xcc>
lea    (%r12,%rbx,8),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
movsd  (%r15,%rbx,8),%xmm0
xor    %edi,%edi
call   1030 <fmax@plt>
movsd  %xmm0,(%r15,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r14
jne    11c0 <project_pos+0xb0>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @project_pos(double* %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca i32
store double* %0, double** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %21, %2
%7 = load i32, i32* %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %24
10: ; preds = %6
%11 = load double*, double** %3
%12 = load i32, i32* %5
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds double, double* %11, i64 %13
%15 = load double, double* %14
%16 = call double @fmax(i32 0, double %15)
%17 = load double*, double** %3
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds double, double* %17, i64 %19
store double %16, double* %20
br label %21
21: ; preds = %10
%22 = load i32, i32* %5
%23 = add nsw i32 %22, 1
store i32 %23, i32* %5
br label %6
24: ; preds = %6
ret void
}

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