#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 */
struct result {
  int dummy;
};

/* Variables and functions */
double rbpHalf(struct result *, int, int, double *);
double rbpMaximize(struct result *r1, int size1, struct result *r2, int size2) {
  double pre1, pre2, max1, max2;
  size1 = (size1 > 1000 ? 1000 : size1);
  size2 = (size2 > 1000 ? 1000 : size2);
  max1 = rbpHalf(r1, size1, size2, &pre1);
  max2 = rbpHalf(r2, size2, size1, &pre2);
  max1 += pre1 - pre2;
  max2 += pre2 - pre1;
  return (1.0 - 0.95) * (max1 > max2 ? max1 : max2);
}


x86 assembly (clang, -O0):
<rbpMaximize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
cmpl   $0x3e8,-0xc(%rbp)
jle    1140 <rbpMaximize+0x30>
mov    $0x3e8,%eax
mov    %eax,-0x44(%rbp)
jmp    1146 <rbpMaximize+0x36>
mov    -0xc(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x3e8,-0x1c(%rbp)
jle    1166 <rbpMaximize+0x56>
mov    $0x3e8,%eax
mov    %eax,-0x48(%rbp)
jmp    116c <rbpMaximize+0x5c>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x48(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    -0x28(%rbp),%rcx
call   1030 <rbpHalf@plt>
movsd  %xmm0,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    -0x30(%rbp),%rcx
call   1030 <rbpHalf@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
ucomisd -0x40(%rbp),%xmm0
jbe    11e9 <rbpMaximize+0xd9>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    11f3 <rbpMaximize+0xe3>
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm1
movsd  0xe00(%rip),%xmm0
mulsd  %xmm1,%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rbpMaximize>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %esi,%ebx
cmp    $0x3e8,%esi
mov    $0x3e8,%ebp
cmovge %ebp,%ebx
mov    %rdx,%r14
cmp    $0x3e8,%ecx
cmovl  %ecx,%ebp
lea    0x18(%rsp),%rcx
mov    %ebx,%esi
mov    %ebp,%edx
call   1030 <rbpHalf@plt>
movsd  %xmm0,0x8(%rsp)
lea    0x10(%rsp),%rcx
mov    %r14,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
call   1030 <rbpHalf@plt>
movsd  0x18(%rsp),%xmm2
movsd  0x10(%rsp),%xmm3
movapd %xmm2,%xmm1
subsd  %xmm3,%xmm1
addsd  0x8(%rsp),%xmm1
subsd  %xmm2,%xmm3
addsd  %xmm0,%xmm3
maxsd  %xmm3,%xmm1
mulsd  0xe79(%rip),%xmm1
movapd %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.result = type { i32 }
define double @rbpMaximize(%struct.result* %0, i32 %1, %struct.result* %2, i32 %3) {
%5 = alloca %struct.result*
%6 = alloca i32
%7 = alloca %struct.result*
%8 = alloca i32
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
store %struct.result* %0, %struct.result** %5
store i32 %1, i32* %6
store %struct.result* %2, %struct.result** %7
store i32 %3, i32* %8
%13 = load i32, i32* %6
%14 = icmp sgt i32 %13, 1000
br i1 %14, label %15, label %16
15: ; preds = %4
br label %18
16: ; preds = %4
%17 = load i32, i32* %6
br label %18
18: ; preds = %16, %15
%19 = phi i32 [ 1000, %15 ], [ %17, %16 ]
store i32 %19, i32* %6
%20 = load i32, i32* %8
%21 = icmp sgt i32 %20, 1000
br i1 %21, label %22, label %23
22: ; preds = %18
br label %25
23: ; preds = %18
%24 = load i32, i32* %8
br label %25
25: ; preds = %23, %22
%26 = phi i32 [ 1000, %22 ], [ %24, %23 ]
store i32 %26, i32* %8
%27 = load %struct.result*, %struct.result** %5
%28 = load i32, i32* %6
%29 = load i32, i32* %8
%30 = call double @rbpHalf(%struct.result* %27, i32 %28, i32 %29, double* %9)
store double %30, double* %11
%31 = load %struct.result*, %struct.result** %7
%32 = load i32, i32* %8
%33 = load i32, i32* %6
%34 = call double @rbpHalf(%struct.result* %31, i32 %32, i32 %33, double* %10)
store double %34, double* %12
%35 = load double, double* %9
%36 = load double, double* %10
%37 = fsub double %35, %36
%38 = load double, double* %11
%39 = fadd double %38, %37
store double %39, double* %11
%40 = load double, double* %10
%41 = load double, double* %9
%42 = fsub double %40, %41
%43 = load double, double* %12
%44 = fadd double %43, %42
store double %44, double* %12
%45 = load double, double* %11
%46 = load double, double* %12
%47 = fcmp ogt double %45, %46
br i1 %47, label %48, label %50
48: ; preds = %25
%49 = load double, double* %11
br label %52
50: ; preds = %25
%51 = load double, double* %12
br label %52
52: ; preds = %50, %48
%53 = phi double [ %49, %48 ], [ %51, %50 ]
%54 = fmul double 0x3FA99999999999A0, %53
ret double %54
}

LLVM IR (-O2):
%struct.result = type { i32 }
define double @rbpMaximize(%struct.result* %0, i32 %1, %struct.result* %2, i32 %3) {
%5 = alloca double
%6 = alloca double
%7 = bitcast double* %5 to i8*
%8 = bitcast double* %6 to i8*
%9 = icmp slt i32 %1, 1000
%10 = select i1 %9, i32 %1, i32 1000
%11 = icmp slt i32 %3, 1000
%12 = select i1 %11, i32 %3, i32 1000
%13 = call double @rbpHalf(%struct.result* %0, i32 %10, i32 %12, double* %5)
%14 = call double @rbpHalf(%struct.result* %2, i32 %12, i32 %10, double* %6)
%15 = load double, double* %5
%16 = load double, double* %6
%17 = fsub double %15, %16
%18 = fadd double %13, %17
%19 = fsub double %16, %15
%20 = fadd double %14, %19
%21 = fcmp ogt double %18, %20
%22 = select i1 %21, double %18, double %20
%23 = fmul double %22, 0x3FA99999999999A0
ret double %23
}