#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(double);
double sqrt(double);
double theta(double x1, double y1, double x2, double y2) {
  return acos(1.0 * (x1 * x2 + y1 * y2) /
              (sqrt(x1 * x1 + y1 * y1) * sqrt(x2 * x2 + y2 * y2)));
}


x86 assembly (clang, -O0):
<theta>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xea0(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm1
mulsd  -0x10(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movsd  -0x30(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
call   1030 <acos@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<theta>:
sub    $0x28,%rsp
movapd %xmm1,%xmm5
mulsd  %xmm3,%xmm5
movapd %xmm0,%xmm4
mulsd  %xmm2,%xmm4
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm6,%xmm6
ucomisd %xmm6,%xmm0
jb     1153 <theta+0x33>
xorps  %xmm1,%xmm1
sqrtsd %xmm0,%xmm1
jmp    1190 <theta+0x70>
movsd  %xmm4,0x10(%rsp)
movsd  %xmm2,0x8(%rsp)
movsd  %xmm3,0x20(%rsp)
movsd  %xmm5,0x18(%rsp)
call   1040 <sqrt@plt>
xorpd  %xmm6,%xmm6
movsd  0x18(%rsp),%xmm5
movsd  0x20(%rsp),%xmm3
movsd  0x8(%rsp),%xmm2
movsd  0x10(%rsp),%xmm4
movapd %xmm0,%xmm1
addsd  %xmm5,%xmm4
mulsd  %xmm3,%xmm3
mulsd  %xmm2,%xmm2
addsd  %xmm3,%xmm2
ucomisd %xmm6,%xmm2
jb     11af <theta+0x8f>
xorps  %xmm0,%xmm0
sqrtsd %xmm2,%xmm0
jmp    11d0 <theta+0xb0>
movapd %xmm2,%xmm0
movsd  %xmm4,0x10(%rsp)
movsd  %xmm1,0x8(%rsp)
call   1040 <sqrt@plt>
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm4
mulsd  %xmm0,%xmm1
divsd  %xmm1,%xmm4
movapd %xmm4,%xmm0
add    $0x28,%rsp
jmp    1030 <acos@plt>

LLVM IR (-O0):
define double @theta(double %0, double %1, double %2, double %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
store double %3, double* %8
%9 = load double, double* %5
%10 = load double, double* %7
%11 = load double, double* %6
%12 = load double, double* %8
%13 = fmul double %11, %12
%14 = call double @llvm.fmuladd.f64(double %9, double %10, double %13)
%15 = fmul double 1.000000e+00, %14
%16 = load double, double* %5
%17 = load double, double* %5
%18 = load double, double* %6
%19 = load double, double* %6
%20 = fmul double %18, %19
%21 = call double @llvm.fmuladd.f64(double %16, double %17, double %20)
%22 = call double @sqrt(double %21)
%23 = load double, double* %7
%24 = load double, double* %7
%25 = load double, double* %8
%26 = load double, double* %8
%27 = fmul double %25, %26
%28 = call double @llvm.fmuladd.f64(double %23, double %24, double %27)
%29 = call double @sqrt(double %28)
%30 = fmul double %22, %29
%31 = fdiv double %15, %30
%32 = call double @acos(double %31)
ret double %32
}

LLVM IR (-O2):
define double @theta(double %0, double %1, double %2, double %3) {
%5 = fmul double %1, %3
%6 = tail call double @llvm.fmuladd.f64(double %0, double %2, double %5)
%7 = fmul double %1, %1
%8 = tail call double @llvm.fmuladd.f64(double %0, double %0, double %7)
%9 = tail call double @sqrt(double %8)
%10 = fmul double %3, %3
%11 = tail call double @llvm.fmuladd.f64(double %2, double %2, double %10)
%12 = tail call double @sqrt(double %11)
%13 = fmul double %9, %12
%14 = fdiv double %6, %13
%15 = tail call double @acos(double %14)
ret double %15
}