#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 /*<<< orphan*/ dot(double *, double *);
double dot2ang(int /*<<< orphan*/);
int /*<<< orphan*/ vec_norm(double *);
double veclen(double *);
double magang(double *va, double *vb) {
  double ang_deg;
  if (veclen(va) < 1.0e-7 || veclen(vb) < 1.0e-7)
    ang_deg = 0.0;
  else {
    vec_norm(va);
    vec_norm(vb);
    ang_deg = dot2ang(dot(va, vb));
  }
  return ang_deg;
}


x86 assembly (clang, -O0):
<magang>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <veclen@plt>
movaps %xmm0,%xmm1
movsd  0xe9c(%rip),%xmm0
ucomisd %xmm1,%xmm0
ja     118c <magang+0x4c>
mov    -0x10(%rbp),%rdi
call   1060 <veclen@plt>
movaps %xmm0,%xmm1
movsd  0xe7e(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1199 <magang+0x59>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    11c4 <magang+0x84>
mov    -0x8(%rbp),%rdi
call   1050 <vec_norm@plt>
mov    -0x10(%rbp),%rdi
call   1050 <vec_norm@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <dot@plt>
mov    %eax,%edi
call   1040 <dot2ang@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<magang>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1060 <veclen@plt>
movsd  0xea9(%rip),%xmm1
ucomisd %xmm0,%xmm1
ja     1173 <magang+0x33>
mov    %r14,%rdi
call   1060 <veclen@plt>
movsd  0xe93(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    117f <magang+0x3f>
xorpd  %xmm0,%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    %rbx,%rdi
call   1050 <vec_norm@plt>
mov    %r14,%rdi
call   1050 <vec_norm@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <dot@plt>
mov    %eax,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <dot2ang@plt>

LLVM IR (-O0):
define double @magang(double* %0, double* %1) {
%3 = alloca double*
%4 = alloca double*
%5 = alloca double
store double* %0, double** %3
store double* %1, double** %4
%6 = load double*, double** %3
%7 = call double @veclen(double* %6)
%8 = fcmp olt double %7, 0x3E7AD7F29ABCAF48
br i1 %8, label %13, label %9
9: ; preds = %2
%10 = load double*, double** %4
%11 = call double @veclen(double* %10)
%12 = fcmp olt double %11, 0x3E7AD7F29ABCAF48
br i1 %12, label %13, label %14
13: ; preds = %9, %2
store double 0.000000e+00, double* %5
br label %23
14: ; preds = %9
%15 = load double*, double** %3
%16 = call i32 @vec_norm(double* %15)
%17 = load double*, double** %4
%18 = call i32 @vec_norm(double* %17)
%19 = load double*, double** %3
%20 = load double*, double** %4
%21 = call i32 @dot(double* %19, double* %20)
%22 = call double @dot2ang(i32 %21)
store double %22, double* %5
br label %23
23: ; preds = %14, %13
%24 = load double, double* %5
ret double %24
}

LLVM IR (-O2):
define double @magang(double* %0, double* %1) {
%3 = tail call double @veclen(double* %0)
%4 = fcmp olt double %3, 0x3E7AD7F29ABCAF48
br i1 %4, label %13, label %5
5: ; preds = %2
%6 = tail call double @veclen(double* %1)
%7 = fcmp olt double %6, 0x3E7AD7F29ABCAF48
br i1 %7, label %13, label %8
8: ; preds = %5
%9 = tail call i32 @vec_norm(double* %0)
%10 = tail call i32 @vec_norm(double* %1)
%11 = tail call i32 @dot(double* %0, double* %1)
%12 = tail call double @dot2ang(i32 %11)
br label %13
13: ; preds = %2, %5, %8
%14 = phi double [ %12, %8 ], [ 0.000000e+00, %5 ], [ 0.000000e+00, %2 ]
ret double %14
}