#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 atan2f(float, float);
float fmodf(float, int);
float radius(float *);
float sqrtf(float);
void mysofa_c2s(float values[3]) {
  float x, y, z, r, theta, phi;
  x = values[0];
  y = values[1];
  z = values[2];
  r = radius(values);
  theta = atan2f(z, sqrtf(x * x + y * y));
  phi = atan2f(y, x);
  values[0] = fmodf(phi * (180 / M_PI) + 360, 360);
  values[1] = theta * (180 / M_PI);
  values[2] = r;
}


x86 assembly (clang, -O0):
<mysofa_c2s>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm0
movss  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <radius@plt>
movss  %xmm0,-0x18(%rbp)
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0xc(%rbp),%xmm0
movss  -0xc(%rbp),%xmm2
movss  -0x10(%rbp),%xmm1
mulss  -0x10(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1050 <sqrtf@plt>
movaps %xmm0,%xmm1
movss  -0x24(%rbp),%xmm0
call   1060 <atan2f@plt>
movss  %xmm0,-0x1c(%rbp)
movss  -0x10(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
call   1060 <atan2f@plt>
movss  %xmm0,-0x20(%rbp)
movss  -0x20(%rbp),%xmm0
mov    $0xb4,%eax
mov    0x2e03(%rip),%rcx
cltd
idivl  (%rcx)
cvtsi2ss %eax,%xmm1
mulss  %xmm1,%xmm0
movss  0xe08(%rip),%xmm1
addss  %xmm1,%xmm0
mov    $0x168,%edi
call   1030 <fmodf@plt>
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x1c(%rbp),%xmm0
mov    $0xb4,%eax
mov    0x2dc9(%rip),%rcx
cltd
idivl  (%rcx)
cvtsi2ss %eax,%xmm1
mulss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x4(%rax)
movss  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x8(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mysofa_c2s>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
movss  (%rdi),%xmm0
movss  %xmm0,0x10(%rsp)
movss  0x4(%rdi),%xmm0
movss  %xmm0,0xc(%rsp)
movss  0x8(%rdi),%xmm0
movss  %xmm0,0x8(%rsp)
call   1040 <radius@plt>
movss  %xmm0,0x14(%rsp)
movss  0xc(%rsp),%xmm1
mulss  %xmm1,%xmm1
movss  0x10(%rsp),%xmm0
mulss  %xmm0,%xmm0
addss  %xmm1,%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jb     119e <mysofa_c2s+0x5e>
xorps  %xmm1,%xmm1
sqrtss %xmm0,%xmm1
jmp    11a6 <mysofa_c2s+0x66>
call   1050 <sqrtf@plt>
movaps %xmm0,%xmm1
movss  0x8(%rsp),%xmm0
call   1060 <atan2f@plt>
movss  %xmm0,0x8(%rsp)
movss  0xc(%rsp),%xmm0
movss  0x10(%rsp),%xmm1
call   1060 <atan2f@plt>
mov    0x2e19(%rip),%r14
mov    $0xb4,%eax
xor    %edx,%edx
idivl  (%r14)
xorps  %xmm1,%xmm1
cvtsi2ss %eax,%xmm1
mulss  %xmm1,%xmm0
addss  0xe14(%rip),%xmm0
mov    $0x168,%edi
call   1030 <fmodf@plt>
movss  %xmm0,(%rbx)
mov    $0xb4,%eax
xor    %edx,%edx
idivl  (%r14)
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
mulss  0x8(%rsp),%xmm0
movss  %xmm0,0x4(%rbx)
movss  0x14(%rsp),%xmm0
movss  %xmm0,0x8(%rbx)
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@M_PI = global i32 0
define void @mysofa_c2s(float* %0) {
%2 = alloca float*
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
store float* %0, float** %2
%9 = load float*, float** %2
%10 = getelementptr inbounds float, float* %9, i64 0
%11 = load float, float* %10
store float %11, float* %3
%12 = load float*, float** %2
%13 = getelementptr inbounds float, float* %12, i64 1
%14 = load float, float* %13
store float %14, float* %4
%15 = load float*, float** %2
%16 = getelementptr inbounds float, float* %15, i64 2
%17 = load float, float* %16
store float %17, float* %5
%18 = load float*, float** %2
%19 = call float @radius(float* %18)
store float %19, float* %6
%20 = load float, float* %5
%21 = load float, float* %3
%22 = load float, float* %3
%23 = load float, float* %4
%24 = load float, float* %4
%25 = fmul float %23, %24
%26 = call float @llvm.fmuladd.f32(float %21, float %22, float %25)
%27 = call float @sqrtf(float %26)
%28 = call float @atan2f(float %20, float %27)
store float %28, float* %7
%29 = load float, float* %4
%30 = load float, float* %3
%31 = call float @atan2f(float %29, float %30)
store float %31, float* %8
%32 = load float, float* %8
%33 = load i32, i32* @M_PI
%34 = sdiv i32 180, %33
%35 = sitofp i32 %34 to float
%36 = call float @llvm.fmuladd.f32(float %32, float %35, float 3.600000e+02)
%37 = call float @fmodf(float %36, i32 360)
%38 = load float*, float** %2
%39 = getelementptr inbounds float, float* %38, i64 0
store float %37, float* %39
%40 = load float, float* %7
%41 = load i32, i32* @M_PI
%42 = sdiv i32 180, %41
%43 = sitofp i32 %42 to float
%44 = fmul float %40, %43
%45 = load float*, float** %2
%46 = getelementptr inbounds float, float* %45, i64 1
store float %44, float* %46
%47 = load float, float* %6
%48 = load float*, float** %2
%49 = getelementptr inbounds float, float* %48, i64 2
store float %47, float* %49
ret void
}

LLVM IR (-O2):
@M_PI = global i32 0
define void @mysofa_c2s(float* %0) {
%2 = load float, float* %0
%3 = getelementptr inbounds float, float* %0, i64 1
%4 = load float, float* %3
%5 = getelementptr inbounds float, float* %0, i64 2
%6 = load float, float* %5
%7 = tail call float @radius(float* %0)
%8 = fmul float %4, %4
%9 = tail call float @llvm.fmuladd.f32(float %2, float %2, float %8)
%10 = tail call float @sqrtf(float %9)
%11 = tail call float @atan2f(float %6, float %10)
%12 = tail call float @atan2f(float %4, float %2)
%13 = load i32, i32* @M_PI
%14 = sdiv i32 180, %13
%15 = sitofp i32 %14 to float
%16 = tail call float @llvm.fmuladd.f32(float %12, float %15, float 3.600000e+02)
%17 = tail call float @fmodf(float %16, i32 360)
store float %17, float* %0
%18 = load i32, i32* @M_PI
%19 = sdiv i32 180, %18
%20 = sitofp i32 %19 to float
%21 = fmul float %11, %20
store float %21, float* %3
store float %7, float* %5
ret void
}