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


x86 assembly (clang, -O0):
<project_box>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11a2 <project_box+0x82>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
call   1030 <fmin@plt>
movsd  -0x30(%rbp),%xmm0
mov    %eax,%edi
call   1040 <fmax@plt>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    113e <project_box+0x1e>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<project_box>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    11ed <project_box+0xcd>
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rdi,%r12
mov    %esi,%r13d
cmp    $0x1,%esi
jne    1148 <project_box+0x28>
xor    %ebx,%ebx
jmp    11b9 <project_box+0x99>
mov    %r13d,%ebp
and    $0xfffffffe,%ebp
xor    %ebx,%ebx
movsd  (%r15,%rbx,8),%xmm0
movsd  %xmm0,(%rsp)
movsd  (%r12,%rbx,8),%xmm0
movsd  (%r14,%rbx,8),%xmm1
call   1030 <fmin@plt>
movsd  (%rsp),%xmm0
mov    %eax,%edi
call   1040 <fmax@plt>
movsd  %xmm0,(%r12,%rbx,8)
movsd  0x8(%r15,%rbx,8),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x8(%r12,%rbx,8),%xmm0
movsd  0x8(%r14,%rbx,8),%xmm1
call   1030 <fmin@plt>
movsd  (%rsp),%xmm0
mov    %eax,%edi
call   1040 <fmax@plt>
movsd  %xmm0,0x8(%r12,%rbx,8)
add    $0x2,%rbx
cmp    %rbx,%rbp
jne    1150 <project_box+0x30>
test   $0x1,%r13b
je     11ed <project_box+0xcd>
movsd  (%r15,%rbx,8),%xmm0
movsd  %xmm0,(%rsp)
movsd  (%r12,%rbx,8),%xmm0
movsd  (%r14,%rbx,8),%xmm1
call   1030 <fmin@plt>
movsd  (%rsp),%xmm0
mov    %eax,%edi
call   1040 <fmax@plt>
movsd  %xmm0,(%r12,%rbx,8)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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