#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 didxmaxval(int const, int const, int const *, int, int const,
                  double const *);
double didxminval(int const, int const, int const *, int, int const,
                  double const *);
void bbox(const int l, const int u, const int *idx, const int nd,
          const double *xi, double *xmin, double *xmax) {
  for (int k = 0; k < nd; k++) {
    xmin[k] = didxminval(l, u, idx, k, nd, xi);
    xmax[k] = didxmaxval(l, u, idx, k, nd, xi);
  }
}


x86 assembly (clang, -O0):
<bbox>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11b0 <bbox+0x90>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    -0x2c(%rbp),%ecx
mov    -0x14(%rbp),%r8d
mov    -0x20(%rbp),%r9
call   1030 <didxminval@plt>
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    -0x2c(%rbp),%ecx
mov    -0x14(%rbp),%r8d
mov    -0x20(%rbp),%r9
call   1040 <didxmaxval@plt>
mov    0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1148 <bbox+0x28>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bbox>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,0x10(%rsp)
mov    %ecx,0xc(%rsp)
test   %ecx,%ecx
jle    119b <bbox+0x7b>
mov    %r8,%r12
mov    %rdx,%r13
mov    %esi,%ebx
mov    %edi,%ebp
mov    0xc(%rsp),%r14d
xor    %r15d,%r15d
nopl   (%rax)
mov    %ebp,%edi
mov    %ebx,%esi
mov    %r13,%rdx
mov    %r15d,%ecx
mov    %r14d,%r8d
mov    %r12,%r9
call   1030 <didxminval@plt>
mov    0x10(%rsp),%rax
movsd  %xmm0,(%rax,%r15,8)
mov    %ebp,%edi
mov    %ebx,%esi
mov    %r13,%rdx
mov    %r15d,%ecx
mov    0xc(%rsp),%r8d
mov    %r12,%r9
call   1040 <didxmaxval@plt>
mov    0x50(%rsp),%rax
movsd  %xmm0,(%rax,%r15,8)
add    $0x1,%r15
cmp    %r15,%r14
jne    1150 <bbox+0x30>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @bbox(i32 %0, i32 %1, i32* %2, i32 %3, double* %4, double* nocapture writeonly %5, double* nocapture writeonly %6) {
%8 = icmp sgt i32 %3, 0
br i1 %8, label %9, label %11
9: ; preds = %7
%10 = zext i32 %3 to i64
br label %12
11: ; preds = %12, %7
ret void
12: ; preds = %9, %12
%13 = phi i64 [ 0, %9 ], [ %19, %12 ]
%14 = trunc i64 %13 to i32
%15 = tail call double @didxminval(i32 %0, i32 %1, i32* %2, i32 %14, i32 %3, double* %4)
%16 = getelementptr inbounds double, double* %5, i64 %13
store double %15, double* %16
%17 = tail call double @didxmaxval(i32 %0, i32 %1, i32* %2, i32 %14, i32 %3, double* %4)
%18 = getelementptr inbounds double, double* %6, i64 %13
store double %17, double* %18
%19 = add nuw nsw i64 %13, 1
%20 = icmp eq i64 %19, %10
br i1 %20, label %11, label %12
}