#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 acos(float);
int /*<<< orphan*/ to_unit_vector(float *, int);
float get_dip(float nhat1, float nhat2, float nhat3) {
  float dip;
  int i, j;
  float nproj[3], n[3];
  float scaling;
  float arg;
  float theta;
  nproj[0] = nhat1;
  nproj[1] = 0;
  nproj[2] = nhat3;
  to_unit_vector(nproj, 3);
  n[0] = nhat1;
  n[1] = nhat2;
  n[2] = nhat3;
  to_unit_vector(n, 3);
  arg = (n[0] * nproj[0] + n[2] * nproj[2]);
  theta = acos(arg) * 57.2957795131;
  if (nhat2 > 0) {
    dip = 90 + theta;
  } else if (nhat2 <= 0) {
    dip = 90 - theta;
  }
  return dip;
}


x86 assembly (clang, -O0):
<get_dip>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
lea    -0x24(%rbp),%rdi
mov    $0x3,%esi
call   1030 <to_unit_vector@plt>
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
lea    -0x30(%rbp),%rdi
mov    $0x3,%esi
call   1030 <to_unit_vector@plt>
movss  -0x30(%rbp),%xmm0
movss  -0x24(%rbp),%xmm2
movss  -0x28(%rbp),%xmm1
mulss  -0x1c(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x38(%rbp)
movss  -0x38(%rbp),%xmm0
call   1040 <acos@plt>
movsd  0xe40(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x3c(%rbp)
movss  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    11f5 <get_dip+0xd5>
movss  0xe22(%rip),%xmm0
addss  -0x3c(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    1219 <get_dip+0xf9>
xorps  %xmm0,%xmm0
ucomiss -0x8(%rbp),%xmm0
jb     1214 <get_dip+0xf4>
movss  0xdfe(%rip),%xmm0
subss  -0x3c(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    1219 <get_dip+0xf9>
movss  -0x10(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_dip>:
sub    $0x28,%rsp
movss  %xmm2,0xc(%rsp)
movss  %xmm1,0x4(%rsp)
movss  %xmm0,0x8(%rsp)
movss  %xmm0,0x1c(%rsp)
movl   $0x0,0x20(%rsp)
movss  %xmm2,0x24(%rsp)
lea    0x1c(%rsp),%rdi
mov    $0x3,%esi
call   1030 <to_unit_vector@plt>
movss  0x8(%rsp),%xmm0
movss  %xmm0,0x10(%rsp)
movss  0x4(%rsp),%xmm0
movss  %xmm0,0x14(%rsp)
movss  0xc(%rsp),%xmm0
movss  %xmm0,0x18(%rsp)
lea    0x10(%rsp),%rdi
mov    $0x3,%esi
call   1030 <to_unit_vector@plt>
movss  0x18(%rsp),%xmm1
mulss  0x24(%rsp),%xmm1
movss  0x10(%rsp),%xmm0
mulss  0x1c(%rsp),%xmm0
addss  %xmm1,%xmm0
call   1040 <acos@plt>
movss  0x4(%rsp),%xmm2
mulsd  0xe45(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm2
jbe    11d4 <get_dip+0xb4>
addss  0xe39(%rip),%xmm0
add    $0x28,%rsp
ret
ucomiss %xmm2,%xmm1
jb     11e8 <get_dip+0xc8>
movss  0xe27(%rip),%xmm1
subss  %xmm0,%xmm1
movaps %xmm1,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define float @get_dip(float %0, float %1, float %2) {
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca i32
%9 = alloca i32
%10 = alloca [3 x float]
%11 = alloca [3 x float]
%12 = alloca float
%13 = alloca float
%14 = alloca float
store float %0, float* %4
store float %1, float* %5
store float %2, float* %6
%15 = load float, float* %4
%16 = getelementptr inbounds [3 x float], [3 x float]* %10, i64 0, i64 0
store float %15, float* %16
%17 = getelementptr inbounds [3 x float], [3 x float]* %10, i64 0, i64 1
store float 0.000000e+00, float* %17
%18 = load float, float* %6
%19 = getelementptr inbounds [3 x float], [3 x float]* %10, i64 0, i64 2
store float %18, float* %19
%20 = getelementptr inbounds [3 x float], [3 x float]* %10, i64 0, i64 0
%21 = call i32 @to_unit_vector(float* %20, i32 3)
%22 = load float, float* %4
%23 = getelementptr inbounds [3 x float], [3 x float]* %11, i64 0, i64 0
store float %22, float* %23
%24 = load float, float* %5
%25 = getelementptr inbounds [3 x float], [3 x float]* %11, i64 0, i64 1
store float %24, float* %25
%26 = load float, float* %6
%27 = getelementptr inbounds [3 x float], [3 x float]* %11, i64 0, i64 2
store float %26, float* %27
%28 = getelementptr inbounds [3 x float], [3 x float]* %11, i64 0, i64 0
%29 = call i32 @to_unit_vector(float* %28, i32 3)
%30 = getelementptr inbounds [3 x float], [3 x float]* %11, i64 0, i64 0
%31 = load float, float* %30
%32 = getelementptr inbounds [3 x float], [3 x float]* %10, i64 0, i64 0
%33 = load float, float* %32
%34 = getelementptr inbounds [3 x float], [3 x float]* %11, i64 0, i64 2
%35 = load float, float* %34
%36 = getelementptr inbounds [3 x float], [3 x float]* %10, i64 0, i64 2
%37 = load float, float* %36
%38 = fmul float %35, %37
%39 = call float @llvm.fmuladd.f32(float %31, float %33, float %38)
store float %39, float* %13
%40 = load float, float* %13
%41 = call double @acos(float %40)
%42 = fmul double %41, 0x404CA5DC1A63CBB0
%43 = fptrunc double %42 to float
store float %43, float* %14
%44 = load float, float* %5
%45 = fcmp ogt float %44, 0.000000e+00
br i1 %45, label %46, label %49
46: ; preds = %3
%47 = load float, float* %14
%48 = fadd float 9.000000e+01, %47
store float %48, float* %7
br label %56
49: ; preds = %3
%50 = load float, float* %5
%51 = fcmp ole float %50, 0.000000e+00
br i1 %51, label %52, label %55
52: ; preds = %49
%53 = load float, float* %14
%54 = fsub float 9.000000e+01, %53
store float %54, float* %7
br label %55
55: ; preds = %52, %49
br label %56
56: ; preds = %55, %46
%57 = load float, float* %7
ret float %57
}

LLVM IR (-O2):
define float @get_dip(float %0, float %1, float %2) {
%4 = alloca [3 x float]
%5 = alloca [3 x float]
%6 = bitcast [3 x float]* %4 to i8*
%7 = bitcast [3 x float]* %5 to i8*
%8 = getelementptr inbounds [3 x float], [3 x float]* %4, i64 0, i64 0
store float %0, float* %8
%9 = getelementptr inbounds [3 x float], [3 x float]* %4, i64 0, i64 1
store float 0.000000e+00, float* %9
%10 = getelementptr inbounds [3 x float], [3 x float]* %4, i64 0, i64 2
store float %2, float* %10
%11 = call i32 @to_unit_vector(float* %8, i32 3)
%12 = getelementptr inbounds [3 x float], [3 x float]* %5, i64 0, i64 0
store float %0, float* %12
%13 = getelementptr inbounds [3 x float], [3 x float]* %5, i64 0, i64 1
store float %1, float* %13
%14 = getelementptr inbounds [3 x float], [3 x float]* %5, i64 0, i64 2
store float %2, float* %14
%15 = call i32 @to_unit_vector(float* %12, i32 3)
%16 = load float, float* %12
%17 = load float, float* %8
%18 = load float, float* %14
%19 = load float, float* %10
%20 = fmul float %18, %19
%21 = call float @llvm.fmuladd.f32(float %16, float %17, float %20)
%22 = call double @acos(float %21)
%23 = fmul double %22, 0x404CA5DC1A63CBB0
%24 = fptrunc double %23 to float
%25 = fcmp ogt float %1, 0.000000e+00
br i1 %25, label %26, label %28
26: ; preds = %3
%27 = fadd float %24, 9.000000e+01
br label %32
28: ; preds = %3
%29 = fcmp ugt float %1, 0.000000e+00
br i1 %29, label %32, label %30
30: ; preds = %28
%31 = fsub float 9.000000e+01, %24
br label %32
32: ; preds = %28, %30, %26
%33 = phi float [ %27, %26 ], [ %31, %30 ], [ undef, %28 ]
ret float %33
}