#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 exp(double);
double pow(double, double);
double gbm_simulation(double spot, double rfr, double vol, double tte,
                      double rand) {
  double drift, stoch;
  drift = (rfr - pow(vol, 2) / 2) * tte;
  stoch = vol * pow(tte, 0.5) * rand;
  return spot * exp(drift + stoch);
}


x86 assembly (clang, -O0):
<gbm_simulation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  %xmm4,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xeb0(%rip),%xmm1
call   1040 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
movsd  0xe9b(%rip),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe6a(%rip),%xmm1
call   1040 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x30(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
call   1030 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm1,%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gbm_simulation>:
sub    $0x28,%rsp
movsd  %xmm4,0x18(%rsp)
movsd  %xmm2,0x10(%rsp)
movapd %xmm1,%xmm4
movsd  %xmm0,0x20(%rsp)
movapd %xmm2,%xmm0
mulsd  %xmm2,%xmm0
movsd  0xeb6(%rip),%xmm1
mulsd  %xmm1,%xmm0
subsd  %xmm0,%xmm4
mulsd  %xmm3,%xmm4
movsd  %xmm4,0x8(%rsp)
movapd %xmm3,%xmm0
call   1040 <pow@plt>
mulsd  0x10(%rsp),%xmm0
mulsd  0x18(%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
call   1030 <exp@plt>
mulsd  0x20(%rsp),%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @gbm_simulation(double %0, double %1, double %2, double %3, double %4) {
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
store double %0, double* %6
store double %1, double* %7
store double %2, double* %8
store double %3, double* %9
store double %4, double* %10
%13 = load double, double* %7
%14 = load double, double* %8
%15 = call double @pow(double %14, double 2.000000e+00)
%16 = fdiv double %15, 2.000000e+00
%17 = fsub double %13, %16
%18 = load double, double* %9
%19 = fmul double %17, %18
store double %19, double* %11
%20 = load double, double* %8
%21 = load double, double* %9
%22 = call double @pow(double %21, double 5.000000e-01)
%23 = fmul double %20, %22
%24 = load double, double* %10
%25 = fmul double %23, %24
store double %25, double* %12
%26 = load double, double* %6
%27 = load double, double* %11
%28 = load double, double* %12
%29 = fadd double %27, %28
%30 = call double @exp(double %29)
%31 = fmul double %26, %30
ret double %31
}

LLVM IR (-O2):
define double @gbm_simulation(double %0, double %1, double %2, double %3, double %4) {
%6 = fmul double %2, %2
%7 = fmul double %6, 5.000000e-01
%8 = fsub double %1, %7
%9 = fmul double %8, %3
%10 = tail call double @pow(double %3, double 5.000000e-01)
%11 = fmul double %10, %2
%12 = fmul double %11, %4
%13 = fadd double %9, %12
%14 = tail call double @exp(double %13)
%15 = fmul double %14, %0
ret double %15
}