#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 */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ printf(char *, double, ...);
void AnalyseOptima(double *x, double *dx, int n, int *onbound, double *lb,
                   double *ub) {
  int i;
  assert(NULL != x);
  assert(NULL != dx);
  assert(n > 0);
  assert(NULL != onbound);
  assert(NULL != lb);
  assert(NULL != ub);
  for (i = 0; i < n; i++) {
    printf("%4d: ", i);
    if (onbound[i]) {
      printf("Boundary. lb: %e, ub: %e. Grad %e\n", x[i] - lb[i], ub[i] - x[i],
             dx[i]);
    } else {
      printf("Not on boundary. lb: %e, ub: %e, grad = %e\n", x[i] - lb[i],
             ub[i] - x[i], dx[i]);
    }
  }
}


x86 assembly (clang, -O0):
<AnalyseOptima>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
xor    %eax,%eax
cmp    -0x8(%rbp),%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
cmpl   $0x0,-0x14(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
xor    %eax,%eax
cmp    -0x20(%rbp),%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
xor    %eax,%eax
cmp    -0x28(%rbp),%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
xor    %eax,%eax
cmp    -0x30(%rbp),%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    129d <AnalyseOptima+0x17d>
cvtsi2sdl -0x34(%rbp),%xmm0
lea    0xe32(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
je     123b <AnalyseOptima+0x11b>
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm1
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
lea    0xdd7(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
jmp    128a <AnalyseOptima+0x16a>
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm1
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
lea    0xda6(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
jmp    128f <AnalyseOptima+0x16f>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11b6 <AnalyseOptima+0x96>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AnalyseOptima>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,0x8(%rsp)
mov    %r8,%r15
mov    %rcx,%r12
mov    %edx,%r14d
mov    %rsi,%rbp
mov    %rdi,%rax
xor    %edi,%edi
mov    %rax,0x10(%rsp)
test   %rax,%rax
setne  %dil
call   1040 <assert@plt>
xor    %edi,%edi
mov    %rbp,%rbx
test   %rbp,%rbp
setne  %dil
call   1040 <assert@plt>
xor    %edi,%edi
test   %r14d,%r14d
setg   %dil
call   1040 <assert@plt>
xor    %edi,%edi
mov    %r12,%r13
test   %r12,%r12
setne  %dil
call   1040 <assert@plt>
xor    %edi,%edi
mov    %r15,%r12
test   %r15,%r15
setne  %dil
call   1040 <assert@plt>
xor    %edi,%edi
mov    0x8(%rsp),%rax
mov    %rax,%r15
test   %rax,%rax
setne  %dil
call   1040 <assert@plt>
test   %r14d,%r14d
jle    1223 <AnalyseOptima+0x103>
mov    %r14d,%ebp
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2sd %r14d,%xmm0
lea    0xe31(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
cmpl   $0x0,0x0(%r13,%r14,4)
mov    0x10(%rsp),%rax
movsd  (%rax,%r14,8),%xmm2
movapd %xmm2,%xmm0
subsd  (%r12,%r14,8),%xmm0
movsd  (%r15,%r14,8),%xmm1
subsd  %xmm2,%xmm1
movsd  (%rbx,%r14,8),%xmm2
lea    0xdfe(%rip),%rdi
lea    0xe1a(%rip),%rax
cmove  %rax,%rdi
mov    $0x3,%al
call   1030 <printf@plt>
add    $0x1,%r14
cmp    %r14,%rbp
jne    11c0 <AnalyseOptima+0xa0>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%4d: \00"
@.str.1 = [35 x i8] c"Boundary. lb: %e, ub: %e. Grad %e\0A\00"
@.str.2 = [44 x i8] c"Not on boundary. lb: %e, ub: %e, grad = %e\0A\00"
define void @AnalyseOptima(double* %0, double* %1, i32 %2, i32* %3, double* %4, double* %5) {
%7 = alloca double*
%8 = alloca double*
%9 = alloca i32
%10 = alloca i32*
%11 = alloca double*
%12 = alloca double*
%13 = alloca i32
store double* %0, double** %7
store double* %1, double** %8
store i32 %2, i32* %9
store i32* %3, i32** %10
store double* %4, double** %11
store double* %5, double** %12
%14 = load double*, double** %7
%15 = icmp ne double* null, %14
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = load double*, double** %8
%19 = icmp ne double* null, %18
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
%22 = load i32, i32* %9
%23 = icmp sgt i32 %22, 0
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
%26 = load i32*, i32** %10
%27 = icmp ne i32* null, %26
%28 = zext i1 %27 to i32
%29 = call i32 @assert(i32 %28)
%30 = load double*, double** %11
%31 = icmp ne double* null, %30
%32 = zext i1 %31 to i32
%33 = call i32 @assert(i32 %32)
%34 = load double*, double** %12
%35 = icmp ne double* null, %34
%36 = zext i1 %35 to i32
%37 = call i32 @assert(i32 %36)
store i32 0, i32* %13
br label %38
38: ; preds = %111, %6
%39 = load i32, i32* %13
%40 = load i32, i32* %9
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %114
42: ; preds = %38
%43 = load i32, i32* %13
%44 = sitofp i32 %43 to double
%45 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), double %44)
%46 = load i32*, i32** %10
%47 = load i32, i32* %13
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i32, i32* %46, i64 %48
%50 = load i32, i32* %49
%51 = icmp ne i32 %50, 0
br i1 %51, label %52, label %81
52: ; preds = %42
%53 = load double*, double** %7
%54 = load i32, i32* %13
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds double, double* %53, i64 %55
%57 = load double, double* %56
%58 = load double*, double** %11
%59 = load i32, i32* %13
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds double, double* %58, i64 %60
%62 = load double, double* %61
%63 = fsub double %57, %62
%64 = load double*, double** %12
%65 = load i32, i32* %13
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds double, double* %64, i64 %66
%68 = load double, double* %67
%69 = load double*, double** %7
%70 = load i32, i32* %13
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds double, double* %69, i64 %71
%73 = load double, double* %72
%74 = fsub double %68, %73
%75 = load double*, double** %8
%76 = load i32, i32* %13
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds double, double* %75, i64 %77
%79 = load double, double* %78
%80 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), double %63, double %74, double %79)
br label %110
81: ; preds = %42
%82 = load double*, double** %7
%83 = load i32, i32* %13
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds double, double* %82, i64 %84
%86 = load double, double* %85
%87 = load double*, double** %11
%88 = load i32, i32* %13
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds double, double* %87, i64 %89
%91 = load double, double* %90
%92 = fsub double %86, %91
%93 = load double*, double** %12
%94 = load i32, i32* %13
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds double, double* %93, i64 %95
%97 = load double, double* %96
%98 = load double*, double** %7
%99 = load i32, i32* %13
%100 = sext i32 %99 to i64
%101 = getelementptr inbounds double, double* %98, i64 %100
%102 = load double, double* %101
%103 = fsub double %97, %102
%104 = load double*, double** %8
%105 = load i32, i32* %13
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds double, double* %104, i64 %106
%108 = load double, double* %107
%109 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), double %92, double %103, double %108)
br label %110
110: ; preds = %81, %52
br label %111
111: ; preds = %110
%112 = load i32, i32* %13
%113 = add nsw i32 %112, 1
store i32 %113, i32* %13
br label %38
114: ; preds = %38
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%4d: \00"
@.str.1 = [35 x i8] c"Boundary. lb: %e, ub: %e. Grad %e\0A\00"
@.str.2 = [44 x i8] c"Not on boundary. lb: %e, ub: %e, grad = %e\0A\00"
define void @AnalyseOptima(double* %0, double* %1, i32 %2, i32* %3, double* %4, double* %5) {
%7 = icmp ne double* %0, null
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = icmp ne double* %1, null
%11 = zext i1 %10 to i32
%12 = tail call i32 @assert(i32 %11)
%13 = icmp sgt i32 %2, 0
%14 = zext i1 %13 to i32
%15 = tail call i32 @assert(i32 %14)
%16 = icmp ne i32* %3, null
%17 = zext i1 %16 to i32
%18 = tail call i32 @assert(i32 %17)
%19 = icmp ne double* %4, null
%20 = zext i1 %19 to i32
%21 = tail call i32 @assert(i32 %20)
%22 = icmp ne double* %5, null
%23 = zext i1 %22 to i32
%24 = tail call i32 @assert(i32 %23)
br i1 %13, label %25, label %49
25: ; preds = %6
%26 = zext i32 %2 to i64
br label %27
27: ; preds = %25, %27
%28 = phi i64 [ 0, %25 ], [ %47, %27 ]
%29 = trunc i64 %28 to i32
%30 = sitofp i32 %29 to double
%31 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), double %30)
%32 = getelementptr inbounds i32, i32* %3, i64 %28
%33 = load i32, i32* %32
%34 = icmp eq i32 %33, 0
%35 = getelementptr inbounds double, double* %0, i64 %28
%36 = load double, double* %35
%37 = getelementptr inbounds double, double* %4, i64 %28
%38 = load double, double* %37
%39 = fsub double %36, %38
%40 = getelementptr inbounds double, double* %5, i64 %28
%41 = load double, double* %40
%42 = fsub double %41, %36
%43 = getelementptr inbounds double, double* %1, i64 %28
%44 = load double, double* %43
%45 = select i1 %34, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0)
%46 = tail call i32 (i8*, double, ...) @printf(i8* %45, double %39, double %42, double %44)
%47 = add nuw nsw i64 %28, 1
%48 = icmp eq i64 %47, %26
br i1 %48, label %49, label %27
49: ; preds = %27, %6
ret void
}