#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 cos(float);
int sin(float);
double sqrt(int);
void lambert_lb2xy(float gall, float galb, int nsgp, float scale, float *pX,
                   float *pY) {
  double rho;
  static double dradeg = 180 / 3.1415926534;
  rho = sqrt(1. - nsgp * sin(galb / dradeg));
  *pX = rho * cos((float)((double)gall / dradeg)) * scale;
  *pY = -nsgp * rho * sin((float)((double)gall / dradeg)) * scale;
}


x86 assembly (clang, -O0):
<lambert_lb2xy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
movss  %xmm2,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x3c(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
divsd  0x2ecf(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
call   1030 <sin@plt>
mov    %eax,%ecx
mov    -0x3c(%rbp),%eax
imul   %ecx,%eax
cvtsi2sd %eax,%xmm1
movsd  0xe7a(%rip),%xmm0
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1050 <sqrt@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
divsd  0x2e85(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
xor    %eax,%eax
sub    -0xc(%rbp),%eax
cvtsi2sd %eax,%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
divsd  0x2e33(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
call   1030 <sin@plt>
movsd  -0x30(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x20(%rbp),%rax
movss  %xmm0,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lambert_lb2xy>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
movss  %xmm2,0x18(%rsp)
mov    %edi,%ebp
movss  %xmm0,0xc(%rsp)
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
divsd  0xea5(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
call   1030 <sin@plt>
imul   %ebp,%eax
mov    $0x1,%edi
sub    %eax,%edi
call   1050 <sqrt@plt>
movsd  %xmm0,0x10(%rsp)
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
divsd  0xe75(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0xc(%rsp)
call   1040 <cos@plt>
movsd  0x10(%rsp),%xmm2
mulsd  %xmm2,%xmm0
movss  0x18(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  %xmm1,0x18(%rsp)
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%rbx)
neg    %ebp
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
mulsd  %xmm2,%xmm0
movsd  %xmm0,0x10(%rsp)
movss  0xc(%rsp),%xmm0
call   1030 <sin@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x10(%rsp),%xmm0
mulsd  0x18(%rsp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%r14)
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@lambert_lb2xy.dradeg = internal global double 0x404CA5DC1A6B30E6
define void @lambert_lb2xy(float %0, float %1, i32 %2, float %3, float* %4, float* %5) {
%7 = alloca float
%8 = alloca float
%9 = alloca i32
%10 = alloca float
%11 = alloca float*
%12 = alloca float*
%13 = alloca double
store float %0, float* %7
store float %1, float* %8
store i32 %2, i32* %9
store float %3, float* %10
store float* %4, float** %11
store float* %5, float** %12
%14 = load i32, i32* %9
%15 = load float, float* %8
%16 = fpext float %15 to double
%17 = load double, double* @lambert_lb2xy.dradeg
%18 = fdiv double %16, %17
%19 = fptrunc double %18 to float
%20 = call i32 @sin(float %19)
%21 = mul nsw i32 %14, %20
%22 = sitofp i32 %21 to double
%23 = fsub double 1.000000e+00, %22
%24 = fptosi double %23 to i32
%25 = call double @sqrt(i32 %24)
store double %25, double* %13
%26 = load double, double* %13
%27 = load float, float* %7
%28 = fpext float %27 to double
%29 = load double, double* @lambert_lb2xy.dradeg
%30 = fdiv double %28, %29
%31 = fptrunc double %30 to float
%32 = call double @cos(float %31)
%33 = fmul double %26, %32
%34 = load float, float* %10
%35 = fpext float %34 to double
%36 = fmul double %33, %35
%37 = fptrunc double %36 to float
%38 = load float*, float** %11
store float %37, float* %38
%39 = load i32, i32* %9
%40 = sub nsw i32 0, %39
%41 = sitofp i32 %40 to double
%42 = load double, double* %13
%43 = fmul double %41, %42
%44 = load float, float* %7
%45 = fpext float %44 to double
%46 = load double, double* @lambert_lb2xy.dradeg
%47 = fdiv double %45, %46
%48 = fptrunc double %47 to float
%49 = call i32 @sin(float %48)
%50 = sitofp i32 %49 to double
%51 = fmul double %43, %50
%52 = load float, float* %10
%53 = fpext float %52 to double
%54 = fmul double %51, %53
%55 = fptrunc double %54 to float
%56 = load float*, float** %12
store float %55, float* %56
ret void
}

LLVM IR (-O2):
define void @lambert_lb2xy(float %0, float %1, i32 %2, float %3, float* nocapture writeonly %4, float* nocapture writeonly %5) {
%7 = fpext float %1 to double
%8 = fdiv double %7, 0x404CA5DC1A6B30E6
%9 = fptrunc double %8 to float
%10 = tail call i32 @sin(float %9)
%11 = mul nsw i32 %10, %2
%12 = sub i32 1, %11
%13 = tail call double @sqrt(i32 %12)
%14 = fpext float %0 to double
%15 = fdiv double %14, 0x404CA5DC1A6B30E6
%16 = fptrunc double %15 to float
%17 = tail call double @cos(float %16)
%18 = fmul double %13, %17
%19 = fpext float %3 to double
%20 = fmul double %18, %19
%21 = fptrunc double %20 to float
store float %21, float* %4
%22 = sub nsw i32 0, %2
%23 = sitofp i32 %22 to double
%24 = fmul double %13, %23
%25 = tail call i32 @sin(float %16)
%26 = sitofp i32 %25 to double
%27 = fmul double %24, %26
%28 = fmul double %27, %19
%29 = fptrunc double %28 to float
store float %29, float* %5
ret void
}