#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 atan2(float, float);
float sqrt(float);
int dihf(float x, float y, float z, float *d, float *i, float *h, float *f) {
  float h2;
  float sn, hpx;
  sn = (float)1e-4;
  h2 = x * x + y * y;
  *h = sqrt(h2);
  *f = sqrt(h2 + z * z);
  if (*f < sn) {
    *d = (float)999.;
    *i = (float)999.;
  } else {
    *i = atan2(z, *h) * 180.0 / 3.14159265358979323846;
    if (*h < sn) {
      *d = (float)999.;
    } else {
      hpx = *h + x;
      if (hpx < sn) {
        *d = (float)180.;
      } else {
        *d = atan2(y, hpx) * 180.0 / 3.14159265358979323846 * (float)2.;
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<dihf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
mov    %rcx,-0x30(%rbp)
movss  0xeb1(%rip),%xmm0
movss  %xmm0,-0x38(%rbp)
movss  -0x4(%rbp),%xmm0
movss  -0x4(%rbp),%xmm2
movss  -0x8(%rbp),%xmm1
mulss  -0x8(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x34(%rbp),%xmm0
call   1040 <sqrt@plt>
mov    -0x28(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x34(%rbp),%xmm1
movss  -0xc(%rbp),%xmm0
movss  -0xc(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1040 <sqrt@plt>
mov    -0x30(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x30(%rbp),%rax
movss  (%rax),%xmm1
movss  -0x38(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    11e6 <dihf+0xc6>
mov    -0x18(%rbp),%rax
movss  0xe3b(%rip),%xmm0
movss  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
movss  0xe2b(%rip),%xmm0
movss  %xmm0,(%rax)
jmp    12ca <dihf+0x1aa>
movss  -0xc(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movss  (%rax),%xmm1
call   1030 <atan2@plt>
movsd  0xe18(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe04(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x20(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
movss  (%rax),%xmm1
movss  -0x38(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    1247 <dihf+0x127>
mov    -0x18(%rbp),%rax
movss  0xdca(%rip),%xmm0
movss  %xmm0,(%rax)
jmp    12c5 <dihf+0x1a5>
mov    -0x28(%rbp),%rax
movss  (%rax),%xmm0
addss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x3c(%rbp)
movss  -0x3c(%rbp),%xmm1
movss  -0x38(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    1281 <dihf+0x161>
mov    -0x18(%rbp),%rax
movss  0xd8c(%rip),%xmm0
movss  %xmm0,(%rax)
jmp    12c0 <dihf+0x1a0>
movss  -0x8(%rbp),%xmm0
movss  -0x3c(%rbp),%xmm1
call   1030 <atan2@plt>
movsd  0xd80(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd6c(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xd70(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
jmp    12c5 <dihf+0x1a5>
jmp    12ca <dihf+0x1aa>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dihf>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%r12
mov    %rdx,%rbx
mov    %rsi,%r15
mov    %rdi,%r14
movaps %xmm0,%xmm3
movss  %xmm1,0x10(%rsp)
mulss  %xmm1,%xmm1
movss  %xmm0,0x14(%rsp)
mulss  %xmm0,%xmm3
addss  %xmm1,%xmm3
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm3
movss  %xmm2,0x8(%rsp)
jb     1169 <dihf+0x49>
xorps  %xmm0,%xmm0
sqrtss %xmm3,%xmm0
jmp    1186 <dihf+0x66>
movaps %xmm3,%xmm0
movss  %xmm3,0xc(%rsp)
call   1040 <sqrt@plt>
xorps  %xmm1,%xmm1
movss  0xc(%rsp),%xmm3
movss  0x8(%rsp),%xmm2
movss  %xmm0,(%rbx)
movaps %xmm2,%xmm0
mulss  %xmm2,%xmm0
addss  %xmm3,%xmm0
ucomiss %xmm1,%xmm0
jb     11a0 <dihf+0x80>
sqrtss %xmm0,%xmm0
jmp    11ab <dihf+0x8b>
call   1040 <sqrt@plt>
movss  0x8(%rsp),%xmm2
movss  %xmm0,(%r12)
movss  0xe47(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    11ce <dihf+0xae>
movl   $0x4479c000,(%r14)
movl   $0x4479c000,(%r15)
jmp    1249 <dihf+0x129>
movss  (%rbx),%xmm1
movaps %xmm2,%xmm0
call   1030 <atan2@plt>
movss  0xe1e(%rip),%xmm2
mulsd  0xe1e(%rip),%xmm0
divsd  0xe1e(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%r15)
movss  (%rbx),%xmm1
ucomiss %xmm1,%xmm2
jbe    120d <dihf+0xed>
movl   $0x4479c000,(%r14)
jmp    1249 <dihf+0x129>
addss  0x14(%rsp),%xmm1
ucomiss %xmm1,%xmm2
jbe    1221 <dihf+0x101>
movl   $0x43340000,(%r14)
jmp    1249 <dihf+0x129>
movss  0x10(%rsp),%xmm0
call   1030 <atan2@plt>
mulsd  0xdd4(%rip),%xmm0
divsd  0xdd4(%rip),%xmm0
addsd  %xmm0,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%r14)
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @dihf(float %0, float %1, float %2, float* %3, float* %4, float* %5, float* %6) {
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca float*
%12 = alloca float*
%13 = alloca float*
%14 = alloca float*
%15 = alloca float
%16 = alloca float
%17 = alloca float
store float %0, float* %8
store float %1, float* %9
store float %2, float* %10
store float* %3, float** %11
store float* %4, float** %12
store float* %5, float** %13
store float* %6, float** %14
store float 0x3F1A36E2E0000000, float* %16
%18 = load float, float* %8
%19 = load float, float* %8
%20 = load float, float* %9
%21 = load float, float* %9
%22 = fmul float %20, %21
%23 = call float @llvm.fmuladd.f32(float %18, float %19, float %22)
store float %23, float* %15
%24 = load float, float* %15
%25 = call float @sqrt(float %24)
%26 = load float*, float** %13
store float %25, float* %26
%27 = load float, float* %15
%28 = load float, float* %10
%29 = load float, float* %10
%30 = call float @llvm.fmuladd.f32(float %28, float %29, float %27)
%31 = call float @sqrt(float %30)
%32 = load float*, float** %14
store float %31, float* %32
%33 = load float*, float** %14
%34 = load float, float* %33
%35 = load float, float* %16
%36 = fcmp olt float %34, %35
br i1 %36, label %37, label %40
37: ; preds = %7
%38 = load float*, float** %11
store float 9.990000e+02, float* %38
%39 = load float*, float** %12
store float 9.990000e+02, float* %39
br label %76
40: ; preds = %7
%41 = load float, float* %10
%42 = load float*, float** %13
%43 = load float, float* %42
%44 = call double @atan2(float %41, float %43)
%45 = fmul double %44, 1.800000e+02
%46 = fdiv double %45, 0x400921FB54442D18
%47 = fptrunc double %46 to float
%48 = load float*, float** %12
store float %47, float* %48
%49 = load float*, float** %13
%50 = load float, float* %49
%51 = load float, float* %16
%52 = fcmp olt float %50, %51
br i1 %52, label %53, label %55
53: ; preds = %40
%54 = load float*, float** %11
store float 9.990000e+02, float* %54
br label %75
55: ; preds = %40
%56 = load float*, float** %13
%57 = load float, float* %56
%58 = load float, float* %8
%59 = fadd float %57, %58
store float %59, float* %17
%60 = load float, float* %17
%61 = load float, float* %16
%62 = fcmp olt float %60, %61
br i1 %62, label %63, label %65
63: ; preds = %55
%64 = load float*, float** %11
store float 1.800000e+02, float* %64
br label %74
65: ; preds = %55
%66 = load float, float* %9
%67 = load float, float* %17
%68 = call double @atan2(float %66, float %67)
%69 = fmul double %68, 1.800000e+02
%70 = fdiv double %69, 0x400921FB54442D18
%71 = fmul double %70, 2.000000e+00
%72 = fptrunc double %71 to float
%73 = load float*, float** %11
store float %72, float* %73
br label %74
74: ; preds = %65, %63
br label %75
75: ; preds = %74, %53
br label %76
76: ; preds = %75, %37
ret i32 0
}

LLVM IR (-O2):
define i32 @dihf(float %0, float %1, float %2, float* nocapture writeonly %3, float* nocapture writeonly %4, float* nocapture %5, float* nocapture writeonly %6) {
%8 = fmul float %1, %1
%9 = tail call float @llvm.fmuladd.f32(float %0, float %0, float %8)
%10 = tail call float @sqrt(float %9)
store float %10, float* %5
%11 = tail call float @llvm.fmuladd.f32(float %2, float %2, float %9)
%12 = tail call float @sqrt(float %11)
store float %12, float* %6
%13 = fcmp olt float %12, 0x3F1A36E2E0000000
br i1 %13, label %14, label %15
14: ; preds = %7
store float 9.990000e+02, float* %3
store float 9.990000e+02, float* %4
br label %34
15: ; preds = %7
%16 = load float, float* %5
%17 = tail call double @atan2(float %2, float %16)
%18 = fmul double %17, 1.800000e+02
%19 = fdiv double %18, 0x400921FB54442D18
%20 = fptrunc double %19 to float
store float %20, float* %4
%21 = load float, float* %5
%22 = fcmp olt float %21, 0x3F1A36E2E0000000
br i1 %22, label %23, label %24
23: ; preds = %15
store float 9.990000e+02, float* %3
br label %34
24: ; preds = %15
%25 = fadd float %21, %0
%26 = fcmp olt float %25, 0x3F1A36E2E0000000
br i1 %26, label %27, label %28
27: ; preds = %24
store float 1.800000e+02, float* %3
br label %34
28: ; preds = %24
%29 = tail call double @atan2(float %1, float %25)
%30 = fmul double %29, 1.800000e+02
%31 = fdiv double %30, 0x400921FB54442D18
%32 = fmul double %31, 2.000000e+00
%33 = fptrunc double %32 to float
store float %33, float* %3
br label %34
34: ; preds = %23, %28, %27, %14
ret i32 0
}