#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 backvalue(int, int, int, int, int, int, double, int);
void maxuv_brute(int t, int r, int f1, int f2, int e, int a, int actn,
                 double uleft, double uright, double *umax, double *vmax) {
  int i;
  double du, u, v;
  *umax = 0.0;
  *vmax = 0.0;
  if (r == 0)
    return;
  du = (uright - uleft) / ((double)1000);
  for (i = 0; i <= 1000; i++) {
    u = uleft + ((double)i) * du;
    if ((v = backvalue(t, r, f1, f2, e, a, u, actn)) > *vmax) {
      *vmax = v;
      *umax = u;
    }
  }
}


x86 assembly (clang, -O0):
<maxuv_brute>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%eax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
mov    %r9d,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
movsd  %xmm1,-0x28(%rbp)
mov    0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    0x20(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
cmpl   $0x0,-0x8(%rbp)
jne    1166 <maxuv_brute+0x56>
jmp    1215 <maxuv_brute+0x105>
movsd  -0x28(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  0xe88(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x3e8,-0x2c(%rbp)
jg     1215 <maxuv_brute+0x105>
movsd  -0x20(%rbp),%xmm1
cvtsi2sdl -0x2c(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0x14(%rbp),%r8d
mov    -0x18(%rbp),%r9d
movsd  -0x40(%rbp),%xmm0
mov    0x10(%rbp),%eax
mov    %eax,(%rsp)
call   1030 <backvalue@plt>
movsd  %xmm0,-0x48(%rbp)
mov    0x20(%rbp),%rax
ucomisd (%rax),%xmm0
jbe    1202 <maxuv_brute+0xf2>
movsd  -0x48(%rbp),%xmm0
mov    0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x40(%rbp),%xmm0
mov    0x18(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1207 <maxuv_brute+0xf7>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1188 <maxuv_brute+0x78>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<maxuv_brute>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
movsd  %xmm0,0x18(%rsp)
mov    %r9d,0x14(%rsp)
mov    %ecx,%r12d
mov    0x80(%rsp),%rax
mov    0x78(%rsp),%rcx
movq   $0x0,(%rcx)
movq   $0x0,(%rax)
test   %esi,%esi
je     11f5 <maxuv_brute+0xe5>
mov    %r8d,%r15d
mov    %edx,%r13d
mov    %esi,%ebx
mov    %edi,%ebp
subsd  0x18(%rsp),%xmm1
divsd  0xe99(%rip),%xmm1
movsd  %xmm1,0x20(%rsp)
xorpd  %xmm0,%xmm0
mov    $0x3e9,%r14d
jmp    1194 <maxuv_brute+0x84>
nopl   0x0(%rax)
movsd  0x30(%rsp),%xmm0
addsd  0xe7a(%rip),%xmm0
add    $0xffffffff,%r14d
je     11f5 <maxuv_brute+0xe5>
movsd  %xmm0,0x30(%rsp)
mulsd  0x20(%rsp),%xmm0
addsd  0x18(%rsp),%xmm0
mov    0x70(%rsp),%eax
mov    %eax,(%rsp)
mov    %ebp,%edi
mov    %ebx,%esi
mov    %r13d,%edx
mov    %r12d,%ecx
mov    %r15d,%r8d
mov    0x14(%rsp),%r9d
movsd  %xmm0,0x28(%rsp)
call   1030 <backvalue@plt>
mov    0x80(%rsp),%rax
ucomisd (%rax),%xmm0
jbe    1180 <maxuv_brute+0x70>
mov    0x80(%rsp),%rax
movsd  %xmm0,(%rax)
mov    0x78(%rsp),%rax
movsd  0x28(%rsp),%xmm0
movsd  %xmm0,(%rax)
jmp    1180 <maxuv_brute+0x70>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @maxuv_brute(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, double %7, double %8, double* %9, double* %10) {
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca double
%20 = alloca double
%21 = alloca double*
%22 = alloca double*
%23 = alloca i32
%24 = alloca double
%25 = alloca double
%26 = alloca double
store i32 %0, i32* %12
store i32 %1, i32* %13
store i32 %2, i32* %14
store i32 %3, i32* %15
store i32 %4, i32* %16
store i32 %5, i32* %17
store i32 %6, i32* %18
store double %7, double* %19
store double %8, double* %20
store double* %9, double** %21
store double* %10, double** %22
%27 = load double*, double** %21
store double 0.000000e+00, double* %27
%28 = load double*, double** %22
store double 0.000000e+00, double* %28
%29 = load i32, i32* %13
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %11
br label %67
32: ; preds = %11
%33 = load double, double* %20
%34 = load double, double* %19
%35 = fsub double %33, %34
%36 = fdiv double %35, 1.000000e+03
store double %36, double* %24
store i32 0, i32* %23
br label %37
37: ; preds = %64, %32
%38 = load i32, i32* %23
%39 = icmp sle i32 %38, 1000
br i1 %39, label %40, label %67
40: ; preds = %37
%41 = load double, double* %19
%42 = load i32, i32* %23
%43 = sitofp i32 %42 to double
%44 = load double, double* %24
%45 = call double @llvm.fmuladd.f64(double %43, double %44, double %41)
store double %45, double* %25
%46 = load i32, i32* %12
%47 = load i32, i32* %13
%48 = load i32, i32* %14
%49 = load i32, i32* %15
%50 = load i32, i32* %16
%51 = load i32, i32* %17
%52 = load double, double* %25
%53 = load i32, i32* %18
%54 = call double @backvalue(i32 %46, i32 %47, i32 %48, i32 %49, i32 %50, i32 %51, double %52, i32 %53)
store double %54, double* %26
%55 = load double*, double** %22
%56 = load double, double* %55
%57 = fcmp ogt double %54, %56
br i1 %57, label %58, label %63
58: ; preds = %40
%59 = load double, double* %26
%60 = load double*, double** %22
store double %59, double* %60
%61 = load double, double* %25
%62 = load double*, double** %21
store double %61, double* %62
br label %63
63: ; preds = %58, %40
br label %64
64: ; preds = %63
%65 = load i32, i32* %23
%66 = add nsw i32 %65, 1
store i32 %66, i32* %23
br label %37
67: ; preds = %31, %37
ret void
}

LLVM IR (-O2):
define void @maxuv_brute(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, double %7, double %8, double* nocapture writeonly %9, double* nocapture %10) {
store double 0.000000e+00, double* %9
store double 0.000000e+00, double* %10
%12 = icmp eq i32 %1, 0
br i1 %12, label %27, label %13
13: ; preds = %11
%14 = fsub double %8, %7
%15 = fdiv double %14, 1.000000e+03
br label %16
16: ; preds = %13, %24
%17 = phi i32 [ 0, %13 ], [ %25, %24 ]
%18 = sitofp i32 %17 to double
%19 = tail call double @llvm.fmuladd.f64(double %18, double %15, double %7)
%20 = tail call double @backvalue(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, double %19, i32 %6)
%21 = load double, double* %10
%22 = fcmp ogt double %20, %21
br i1 %22, label %23, label %24
23: ; preds = %16
store double %20, double* %10
store double %19, double* %9
br label %24
24: ; preds = %16, %23
%25 = add nuw nsw i32 %17, 1
%26 = icmp eq i32 %25, 1001
br i1 %26, label %27, label %16
27: ; preds = %24, %11
ret void
}