#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 M_PI;
float cosf(float);
float sinf(float);
void mysofa_s2c(float values[3]) {
  float x, r, theta, phi;
  phi = values[0] * (M_PI / 180);
  theta = values[1] * (M_PI / 180);
  r = values[2];
  x = cosf(theta) * r;
  values[2] = sinf(theta) * r;
  values[0] = cosf(phi) * x;
  values[1] = sinf(phi) * x;
}


x86 assembly (clang, -O0):
<mysofa_s2c>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
mov    0x2ead(%rip),%rax
mov    (%rax),%eax
mov    $0xb4,%ecx
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm0
mov    0x2e86(%rip),%rax
mov    (%rax),%eax
mov    $0xb4,%ecx
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x14(%rbp),%xmm0
call   1040 <cosf@plt>
mulss  -0x10(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x14(%rbp),%xmm0
call   1030 <sinf@plt>
mulss  -0x10(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x8(%rax)
movss  -0x18(%rbp),%xmm0
call   1040 <cosf@plt>
mulss  -0xc(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x18(%rbp),%xmm0
call   1030 <sinf@plt>
mulss  -0xc(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x4(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mysofa_s2c>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    0x2eb9(%rip),%rax
movslq (%rax),%rax
imul   $0xffffffffb60b60b7,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%eax
shr    $0x1f,%eax
sar    $0x7,%ecx
add    %eax,%ecx
cvtsi2ss %ecx,%xmm0
movss  (%rdi),%xmm1
mulss  %xmm0,%xmm1
movss  %xmm1,0x8(%rsp)
mulss  0x4(%rdi),%xmm0
movss  %xmm0,0xc(%rsp)
movss  0x8(%rdi),%xmm1
movss  %xmm1,(%rsp)
call   1040 <cosf@plt>
mulss  (%rsp),%xmm0
movss  %xmm0,0x4(%rsp)
movss  0xc(%rsp),%xmm0
call   1030 <sinf@plt>
mulss  (%rsp),%xmm0
movss  %xmm0,0x8(%rbx)
movss  0x8(%rsp),%xmm0
call   1040 <cosf@plt>
mulss  0x4(%rsp),%xmm0
movss  %xmm0,(%rbx)
movss  0x8(%rsp),%xmm0
call   1030 <sinf@plt>
mulss  0x4(%rsp),%xmm0
movss  %xmm0,0x4(%rbx)
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@M_PI = global i32 0
define void @mysofa_s2c(float* %0) {
%2 = alloca float*
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
store float* %0, float** %2
%7 = load float*, float** %2
%8 = getelementptr inbounds float, float* %7, i64 0
%9 = load float, float* %8
%10 = load i32, i32* @M_PI
%11 = sdiv i32 %10, 180
%12 = sitofp i32 %11 to float
%13 = fmul float %9, %12
store float %13, float* %6
%14 = load float*, float** %2
%15 = getelementptr inbounds float, float* %14, i64 1
%16 = load float, float* %15
%17 = load i32, i32* @M_PI
%18 = sdiv i32 %17, 180
%19 = sitofp i32 %18 to float
%20 = fmul float %16, %19
store float %20, float* %5
%21 = load float*, float** %2
%22 = getelementptr inbounds float, float* %21, i64 2
%23 = load float, float* %22
store float %23, float* %4
%24 = load float, float* %5
%25 = call float @cosf(float %24)
%26 = load float, float* %4
%27 = fmul float %25, %26
store float %27, float* %3
%28 = load float, float* %5
%29 = call float @sinf(float %28)
%30 = load float, float* %4
%31 = fmul float %29, %30
%32 = load float*, float** %2
%33 = getelementptr inbounds float, float* %32, i64 2
store float %31, float* %33
%34 = load float, float* %6
%35 = call float @cosf(float %34)
%36 = load float, float* %3
%37 = fmul float %35, %36
%38 = load float*, float** %2
%39 = getelementptr inbounds float, float* %38, i64 0
store float %37, float* %39
%40 = load float, float* %6
%41 = call float @sinf(float %40)
%42 = load float, float* %3
%43 = fmul float %41, %42
%44 = load float*, float** %2
%45 = getelementptr inbounds float, float* %44, i64 1
store float %43, float* %45
ret void
}

LLVM IR (-O2):
@M_PI = global i32 0
define void @mysofa_s2c(float* nocapture %0) {
%2 = load float, float* %0
%3 = load i32, i32* @M_PI
%4 = sdiv i32 %3, 180
%5 = sitofp i32 %4 to float
%6 = fmul float %2, %5
%7 = getelementptr inbounds float, float* %0, i64 1
%8 = load float, float* %7
%9 = fmul float %8, %5
%10 = getelementptr inbounds float, float* %0, i64 2
%11 = load float, float* %10
%12 = tail call float @cosf(float %9)
%13 = fmul float %11, %12
%14 = tail call float @sinf(float %9)
%15 = fmul float %11, %14
store float %15, float* %10
%16 = tail call float @cosf(float %6)
%17 = fmul float %13, %16
store float %17, float* %0
%18 = tail call float @sinf(float %6)
%19 = fmul float %13, %18
store float %19, float* %7
ret void
}