#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 cos(int);
double sqrt(int);
double end_velocity(int distance, int theta, double g, double start_velocity) {
  return sqrt(
      2 * g *
          cos(theta *
              3.1415926535897932384626433832795028841971693993751058209749445923 /
              180) *
          distance +
      start_velocity * start_velocity);
}


x86 assembly (clang, -O0):
<end_velocity>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  0xed0(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xeb1(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe9d(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
movsd  -0x20(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x4(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm1
mulsd  -0x18(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<end_velocity>:
push   %rbx
sub    $0x10,%rsp
movsd  %xmm1,0x8(%rsp)
mov    %edi,%ebx
addsd  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %esi,%xmm0
mulsd  0xebb(%rip),%xmm0
divsd  0xebb(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  (%rsp),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
mulsd  %xmm0,%xmm1
movsd  0x8(%rsp),%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
add    $0x10,%rsp
pop    %rbx
jmp    1040 <sqrt@plt>

LLVM IR (-O0):
define double @end_velocity(i32 %0, i32 %1, double %2, double %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
%8 = alloca double
store i32 %0, i32* %5
store i32 %1, i32* %6
store double %2, double* %7
store double %3, double* %8
%9 = load double, double* %7
%10 = fmul double 2.000000e+00, %9
%11 = load i32, i32* %6
%12 = sitofp i32 %11 to double
%13 = fmul double %12, 0x400921FB54442D18
%14 = fdiv double %13, 1.800000e+02
%15 = fptosi double %14 to i32
%16 = call i32 @cos(i32 %15)
%17 = sitofp i32 %16 to double
%18 = fmul double %10, %17
%19 = load i32, i32* %5
%20 = sitofp i32 %19 to double
%21 = load double, double* %8
%22 = load double, double* %8
%23 = fmul double %21, %22
%24 = call double @llvm.fmuladd.f64(double %18, double %20, double %23)
%25 = fptosi double %24 to i32
%26 = call double @sqrt(i32 %25)
ret double %26
}

LLVM IR (-O2):
define double @end_velocity(i32 %0, i32 %1, double %2, double %3) {
%5 = fmul double %2, 2.000000e+00
%6 = sitofp i32 %1 to double
%7 = fmul double %6, 0x400921FB54442D18
%8 = fdiv double %7, 1.800000e+02
%9 = fptosi double %8 to i32
%10 = tail call i32 @cos(i32 %9)
%11 = sitofp i32 %10 to double
%12 = fmul double %5, %11
%13 = sitofp i32 %0 to double
%14 = fmul double %3, %3
%15 = tail call double @llvm.fmuladd.f64(double %12, double %13, double %14)
%16 = fptosi double %15 to i32
%17 = tail call double @sqrt(i32 %16)
ret double %17
}