#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 g3_max(int, int);
int log(int);
double sqrt(int);
double g3_UCB(int w_i, int n_i, int t) {
  w_i = g3_max(w_i, 1);
  n_i = g3_max(n_i, 1);
  t = g3_max(t, 1);
  return (double)w_i / n_i + sqrt(1.5) * sqrt(log(t) / n_i);
}


x86 assembly (clang, -O0):
<g3_UCB>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x1,%esi
call   1030 <g3_max@plt>
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x1,%esi
call   1030 <g3_max@plt>
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%edi
mov    $0x1,%esi
call   1030 <g3_max@plt>
mov    %eax,-0xc(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm0
cvtsi2sdl -0x8(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    $0x1,%edi
call   1050 <sqrt@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0xc(%rbp),%edi
call   1040 <log@plt>
cltd
idivl  -0x8(%rbp)
mov    %eax,%edi
call   1050 <sqrt@plt>
movsd  -0x20(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x18(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<g3_UCB>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edx,%r14d
mov    %esi,%ebp
mov    $0x1,%esi
call   1030 <g3_max@plt>
mov    %eax,%ebx
mov    %ebp,%edi
mov    $0x1,%esi
call   1030 <g3_max@plt>
mov    %eax,%ebp
mov    %r14d,%edi
mov    $0x1,%esi
call   1030 <g3_max@plt>
cvtsi2sd %ebx,%xmm1
mov    %eax,%ebx
cvtsi2sd %ebp,%xmm0
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
mov    $0x1,%edi
call   1050 <sqrt@plt>
movsd  %xmm0,(%rsp)
mov    %ebx,%edi
call   1040 <log@plt>
cltd
idiv   %ebp
mov    %eax,%edi
call   1050 <sqrt@plt>
mulsd  (%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define double @g3_UCB(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i32, i32* %4
%8 = call i32 @g3_max(i32 %7, i32 1)
store i32 %8, i32* %4
%9 = load i32, i32* %5
%10 = call i32 @g3_max(i32 %9, i32 1)
store i32 %10, i32* %5
%11 = load i32, i32* %6
%12 = call i32 @g3_max(i32 %11, i32 1)
store i32 %12, i32* %6
%13 = load i32, i32* %4
%14 = sitofp i32 %13 to double
%15 = load i32, i32* %5
%16 = sitofp i32 %15 to double
%17 = fdiv double %14, %16
%18 = call double @sqrt(i32 1)
%19 = load i32, i32* %6
%20 = call i32 @log(i32 %19)
%21 = load i32, i32* %5
%22 = sdiv i32 %20, %21
%23 = call double @sqrt(i32 %22)
%24 = call double @llvm.fmuladd.f64(double %18, double %23, double %17)
ret double %24
}

LLVM IR (-O2):
define double @g3_UCB(i32 %0, i32 %1, i32 %2) {
%4 = tail call i32 @g3_max(i32 %0, i32 1)
%5 = tail call i32 @g3_max(i32 %1, i32 1)
%6 = tail call i32 @g3_max(i32 %2, i32 1)
%7 = sitofp i32 %4 to double
%8 = sitofp i32 %5 to double
%9 = fdiv double %7, %8
%10 = tail call double @sqrt(i32 1)
%11 = tail call i32 @log(i32 %6)
%12 = sdiv i32 %11, %5
%13 = tail call double @sqrt(i32 %12)
%14 = tail call double @llvm.fmuladd.f64(double %10, double %13, double %9)
ret double %14
}