#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 compute_e_res(int, int, int, int);
double get_min_NVM_res(int type, int epos, int div, int *ppos) {
  int i;
  double val;
  double max = 0.0;
  int pos = -1;
  for (i = 0; i <= div; i++) {
    val = compute_e_res(type, epos, div, i);
    if (val < max) {
      max = val;
      pos = i;
    }
  }
  *ppos = pos;
  return (max);
}


x86 assembly (clang, -O0):
<get_min_NVM_res>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0xffffffff,-0x34(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     1194 <get_min_NVM_res+0x84>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x1c(%rbp),%ecx
call   1030 <compute_e_res@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1181 <get_min_NVM_res+0x71>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x34(%rbp)
jmp    1186 <get_min_NVM_res+0x76>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113b <get_min_NVM_res+0x2b>
mov    -0x34(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movsd  -0x30(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_min_NVM_res>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,0x8(%rsp)
test   %edx,%edx
js     1175 <get_min_NVM_res+0x65>
mov    %edx,%r13d
mov    %esi,%r15d
mov    %edi,%r12d
lea    0x1(%r13),%r14d
xor    %ebp,%ebp
xorpd  %xmm1,%xmm1
mov    $0xffffffff,%ebx
nop
movsd  %xmm1,0x10(%rsp)
mov    %r12d,%edi
mov    %r15d,%esi
mov    %r13d,%edx
mov    %ebp,%ecx
call   1030 <compute_e_res@plt>
movsd  0x10(%rsp),%xmm1
ucomisd %xmm0,%xmm1
cmova  %ebp,%ebx
minsd  %xmm1,%xmm0
add    $0x1,%ebp
movapd %xmm0,%xmm1
cmp    %ebp,%r14d
jne    1140 <get_min_NVM_res+0x30>
jmp    117e <get_min_NVM_res+0x6e>
mov    $0xffffffff,%ebx
xorpd  %xmm0,%xmm0
mov    0x8(%rsp),%rax
mov    %ebx,(%rax)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @get_min_NVM_res(i32 %0, i32 %1, i32 %2, i32* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32
%10 = alloca double
%11 = alloca double
%12 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32* %3, i32** %8
store double 0.000000e+00, double* %11
store i32 -1, i32* %12
store i32 0, i32* %9
br label %13
13: ; preds = %30, %4
%14 = load i32, i32* %9
%15 = load i32, i32* %7
%16 = icmp sle i32 %14, %15
br i1 %16, label %17, label %33
17: ; preds = %13
%18 = load i32, i32* %5
%19 = load i32, i32* %6
%20 = load i32, i32* %7
%21 = load i32, i32* %9
%22 = call double @compute_e_res(i32 %18, i32 %19, i32 %20, i32 %21)
store double %22, double* %10
%23 = load double, double* %10
%24 = load double, double* %11
%25 = fcmp olt double %23, %24
br i1 %25, label %26, label %29
26: ; preds = %17
%27 = load double, double* %10
store double %27, double* %11
%28 = load i32, i32* %9
store i32 %28, i32* %12
br label %29
29: ; preds = %26, %17
br label %30
30: ; preds = %29
%31 = load i32, i32* %9
%32 = add nsw i32 %31, 1
store i32 %32, i32* %9
br label %13
33: ; preds = %13
%34 = load i32, i32* %12
%35 = load i32*, i32** %8
store i32 %34, i32* %35
%36 = load double, double* %11
ret double %36
}

LLVM IR (-O2):
define double @get_min_NVM_res(i32 %0, i32 %1, i32 %2, i32* nocapture writeonly %3) {
%5 = icmp slt i32 %2, 0
br i1 %5, label %16, label %6
6: ; preds = %4, %6
%7 = phi i32 [ %13, %6 ], [ -1, %4 ]
%8 = phi double [ %12, %6 ], [ 0.000000e+00, %4 ]
%9 = phi i32 [ %14, %6 ], [ 0, %4 ]
%10 = tail call double @compute_e_res(i32 %0, i32 %1, i32 %2, i32 %9)
%11 = fcmp olt double %10, %8
%12 = select i1 %11, double %10, double %8
%13 = select i1 %11, i32 %9, i32 %7
%14 = add nuw i32 %9, 1
%15 = icmp eq i32 %9, %2
br i1 %15, label %16, label %6
16: ; preds = %6, %4
%17 = phi double [ 0.000000e+00, %4 ], [ %12, %6 ]
%18 = phi i32 [ -1, %4 ], [ %13, %6 ]
store i32 %18, i32* %3
ret double %17
}