#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 */
long double M_PI;
long double M_PI_2;
long double atanl(long double);
long double atan2l(long double y, long double x) {
  if (y == 0.0) {
    if (x >= 0.0) {
      return 0.0;
    } else {
      return M_PI;
    }
  } else if (y > 0.0) {
    if (x == 0.0) {
      return M_PI_2;
    } else if (x > 0.0) {
      return atanl(y / x);
    } else {
      return M_PI - atanl(y / x);
    }
  } else {
    if (x == 0.0) {
      return M_PI + M_PI_2;
    } else if (x > 0.0) {
      return 2 * M_PI - atanl(y / x);
    } else {
      return M_PI + atanl(y / x);
    }
  }
}


x86 assembly (clang, -O0):
<atan2l>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
fldt   0x20(%rbp)
fldt   0x10(%rbp)
fstpt  -0x20(%rbp)
fstpt  -0x30(%rbp)
fldt   -0x20(%rbp)
fldz
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jne    1171 <atan2l+0x61>
jp     1171 <atan2l+0x61>
jmp    1140 <atan2l+0x30>
fldt   -0x30(%rbp)
fldz
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jb     1160 <atan2l+0x50>
jmp    1156 <atan2l+0x46>
fldz
fstpt  -0x10(%rbp)
jmp    12b0 <atan2l+0x1a0>
mov    0x2e81(%rip),%rax
fldt   (%rax)
fstpt  -0x10(%rbp)
jmp    12b0 <atan2l+0x1a0>
fldt   -0x20(%rbp)
fldz
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jbe    120f <atan2l+0xff>
jmp    1187 <atan2l+0x77>
fldt   -0x30(%rbp)
fldz
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jne    11b4 <atan2l+0xa4>
jp     11b4 <atan2l+0xa4>
jmp    11a3 <atan2l+0x93>
mov    0x2e36(%rip),%rax
fldt   (%rax)
fstpt  -0x10(%rbp)
jmp    12b0 <atan2l+0x1a0>
fldt   -0x30(%rbp)
fldz
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jbe    11e4 <atan2l+0xd4>
jmp    11ca <atan2l+0xba>
fldt   -0x20(%rbp)
fldt   -0x30(%rbp)
fdivrp %st,%st(1)
mov    %rsp,%rax
fstpt  (%rax)
call   1030 <atanl@plt>
fstpt  -0x10(%rbp)
jmp    12b0 <atan2l+0x1a0>
mov    0x2dfd(%rip),%rax
fldt   (%rax)
fstpt  -0x3c(%rbp)
fldt   -0x20(%rbp)
fldt   -0x30(%rbp)
fdivrp %st,%st(1)
mov    %rsp,%rax
fstpt  (%rax)
call   1030 <atanl@plt>
fldt   -0x3c(%rbp)
fsubp  %st,%st(1)
fstpt  -0x10(%rbp)
jmp    12b0 <atan2l+0x1a0>
fldt   -0x30(%rbp)
fldz
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jne    1247 <atan2l+0x137>
jp     1247 <atan2l+0x137>
jmp    122b <atan2l+0x11b>
mov    0x2db6(%rip),%rax
fldt   (%rax)
mov    0x2da5(%rip),%rax
fldt   (%rax)
faddp  %st,%st(1)
fstpt  -0x10(%rbp)
jmp    12b0 <atan2l+0x1a0>
fldt   -0x30(%rbp)
fldz
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jbe    128a <atan2l+0x17a>
jmp    125d <atan2l+0x14d>
mov    0x2d84(%rip),%rax
fldt   (%rax)
fstpt  -0x48(%rbp)
fldt   -0x20(%rbp)
fldt   -0x30(%rbp)
fdivrp %st,%st(1)
mov    %rsp,%rax
fstpt  (%rax)
call   1030 <atanl@plt>
fldt   -0x48(%rbp)
fadd   %st,%st(0)
fsubp  %st,%st(1)
fstpt  -0x10(%rbp)
jmp    12b0 <atan2l+0x1a0>
mov    0x2d57(%rip),%rax
fldt   (%rax)
fstpt  -0x54(%rbp)
fldt   -0x20(%rbp)
fldt   -0x30(%rbp)
fdivrp %st,%st(1)
mov    %rsp,%rax
fstpt  (%rax)
call   1030 <atanl@plt>
fldt   -0x54(%rbp)
faddp  %st,%st(1)
fstpt  -0x10(%rbp)
fldt   -0x10(%rbp)
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<atan2l>:
sub    $0x38,%rsp
fldt   0x50(%rsp)
fldt   0x40(%rsp)
fldz
fxch   %st(1)
fucomi %st(1),%st
jne    113d <atan2l+0x2d>
jp     113d <atan2l+0x2d>
fstp   %st(0)
fxch   %st(1)
fucomip %st(1),%st
jae    11ed <atan2l+0xdd>
fstp   %st(0)
mov    0x2ead(%rip),%rax
jmp    1154 <atan2l+0x44>
jbe    115b <atan2l+0x4b>
fxch   %st(2)
fucomi %st(1),%st
fstp   %st(1)
jne    117d <atan2l+0x6d>
jp     117d <atan2l+0x6d>
fstp   %st(1)
fstp   %st(0)
mov    0x2e8c(%rip),%rax
fldt   (%rax)
add    $0x38,%rsp
ret
fxch   %st(2)
fucomi %st(1),%st
jne    118e <atan2l+0x7e>
jp     118e <atan2l+0x7e>
fstp   %st(2)
fstp   %st(0)
fstp   %st(0)
mov    0x2e78(%rip),%rax
fldt   (%rax)
mov    0x2e67(%rip),%rax
fldt   (%rax)
jmp    11eb <atan2l+0xdb>
jbe    11c5 <atan2l+0xb5>
fdivrp %st,%st(1)
fstpt  (%rsp)
call   1030 <atanl@plt>
add    $0x38,%rsp
ret
mov    0x2e53(%rip),%rax
fldt   (%rax)
fstpt  0x14(%rsp)
fdivr  %st,%st(2)
fxch   %st(2)
fstpt  (%rsp)
fstpt  0x2c(%rsp)
fstpt  0x20(%rsp)
call   1030 <atanl@plt>
fldt   0x2c(%rsp)
fldt   0x20(%rsp)
fucomip %st(1),%st
fstp   %st(0)
jbe    11e7 <atan2l+0xd7>
fldt   0x14(%rsp)
fadd   %st,%st(0)
jmp    11e0 <atan2l+0xd0>
mov    0x2e1c(%rip),%rax
fldt   (%rax)
fstpt  0x14(%rsp)
fdivrp %st,%st(1)
fstpt  (%rsp)
call   1030 <atanl@plt>
fldt   0x14(%rsp)
fsubp  %st,%st(1)
add    $0x38,%rsp
ret
fldt   0x14(%rsp)
faddp  %st,%st(1)
add    $0x38,%rsp
ret

LLVM IR (-O0):
@M_PI = global x86_fp80 0xK00000000000000000000
@M_PI_2 = global x86_fp80 0xK00000000000000000000
define x86_fp80 @atan2l(x86_fp80 %0, x86_fp80 %1) {
%3 = alloca x86_fp80
%4 = alloca x86_fp80
%5 = alloca x86_fp80
store x86_fp80 %0, x86_fp80* %4
store x86_fp80 %1, x86_fp80* %5
%6 = load x86_fp80, x86_fp80* %4
%7 = fcmp oeq x86_fp80 %6, 0xK00000000000000000000
br i1 %7, label %8, label %14
8: ; preds = %2
%9 = load x86_fp80, x86_fp80* %5
%10 = fcmp oge x86_fp80 %9, 0xK00000000000000000000
br i1 %10, label %11, label %12
11: ; preds = %8
store x86_fp80 0xK00000000000000000000, x86_fp80* %3
br label %62
12: ; preds = %8
%13 = load x86_fp80, x86_fp80* @M_PI
store x86_fp80 %13, x86_fp80* %3
br label %62
14: ; preds = %2
%15 = load x86_fp80, x86_fp80* %4
%16 = fcmp ogt x86_fp80 %15, 0xK00000000000000000000
br i1 %16, label %17, label %37
17: ; preds = %14
%18 = load x86_fp80, x86_fp80* %5
%19 = fcmp oeq x86_fp80 %18, 0xK00000000000000000000
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = load x86_fp80, x86_fp80* @M_PI_2
store x86_fp80 %21, x86_fp80* %3
br label %62
22: ; preds = %17
%23 = load x86_fp80, x86_fp80* %5
%24 = fcmp ogt x86_fp80 %23, 0xK00000000000000000000
br i1 %24, label %25, label %30
25: ; preds = %22
%26 = load x86_fp80, x86_fp80* %4
%27 = load x86_fp80, x86_fp80* %5
%28 = fdiv x86_fp80 %26, %27
%29 = call x86_fp80 @atanl(x86_fp80 %28)
store x86_fp80 %29, x86_fp80* %3
br label %62
30: ; preds = %22
%31 = load x86_fp80, x86_fp80* @M_PI
%32 = load x86_fp80, x86_fp80* %4
%33 = load x86_fp80, x86_fp80* %5
%34 = fdiv x86_fp80 %32, %33
%35 = call x86_fp80 @atanl(x86_fp80 %34)
%36 = fsub x86_fp80 %31, %35
store x86_fp80 %36, x86_fp80* %3
br label %62
37: ; preds = %14
%38 = load x86_fp80, x86_fp80* %5
%39 = fcmp oeq x86_fp80 %38, 0xK00000000000000000000
br i1 %39, label %40, label %44
40: ; preds = %37
%41 = load x86_fp80, x86_fp80* @M_PI
%42 = load x86_fp80, x86_fp80* @M_PI_2
%43 = fadd x86_fp80 %41, %42
store x86_fp80 %43, x86_fp80* %3
br label %62
44: ; preds = %37
%45 = load x86_fp80, x86_fp80* %5
%46 = fcmp ogt x86_fp80 %45, 0xK00000000000000000000
br i1 %46, label %47, label %55
47: ; preds = %44
%48 = load x86_fp80, x86_fp80* @M_PI
%49 = load x86_fp80, x86_fp80* %4
%50 = load x86_fp80, x86_fp80* %5
%51 = fdiv x86_fp80 %49, %50
%52 = call x86_fp80 @atanl(x86_fp80 %51)
%53 = fneg x86_fp80 %52
%54 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 0xK40008000000000000000, x86_fp80 %48, x86_fp80 %53)
store x86_fp80 %54, x86_fp80* %3
br label %62
55: ; preds = %44
%56 = load x86_fp80, x86_fp80* @M_PI
%57 = load x86_fp80, x86_fp80* %4
%58 = load x86_fp80, x86_fp80* %5
%59 = fdiv x86_fp80 %57, %58
%60 = call x86_fp80 @atanl(x86_fp80 %59)
%61 = fadd x86_fp80 %56, %60
store x86_fp80 %61, x86_fp80* %3
br label %62
62: ; preds = %55, %47, %40, %30, %25, %20, %12, %11
%63 = load x86_fp80, x86_fp80* %3
ret x86_fp80 %63
}

LLVM IR (-O2):
@M_PI = global x86_fp80 0xK00000000000000000000
@M_PI_2 = global x86_fp80 0xK00000000000000000000
define x86_fp80 @atan2l(x86_fp80 %0, x86_fp80 %1) {
%3 = fcmp oeq x86_fp80 %0, 0xK00000000000000000000
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = fcmp ult x86_fp80 %1, 0xK00000000000000000000
br i1 %5, label %6, label %39
6: ; preds = %4
%7 = load x86_fp80, x86_fp80* @M_PI
br label %39
8: ; preds = %2
%9 = fcmp ogt x86_fp80 %0, 0xK00000000000000000000
%10 = fcmp oeq x86_fp80 %1, 0xK00000000000000000000
br i1 %9, label %11, label %24
11: ; preds = %8
br i1 %10, label %12, label %14
12: ; preds = %11
%13 = load x86_fp80, x86_fp80* @M_PI_2
br label %39
14: ; preds = %11
%15 = fcmp ogt x86_fp80 %1, 0xK00000000000000000000
br i1 %15, label %16, label %19
16: ; preds = %14
%17 = fdiv x86_fp80 %0, %1
%18 = tail call x86_fp80 @atanl(x86_fp80 %17)
br label %39
19: ; preds = %14
%20 = load x86_fp80, x86_fp80* @M_PI
%21 = fdiv x86_fp80 %0, %1
%22 = tail call x86_fp80 @atanl(x86_fp80 %21)
%23 = fsub x86_fp80 %20, %22
br label %39
24: ; preds = %8
br i1 %10, label %25, label %29
25: ; preds = %24
%26 = load x86_fp80, x86_fp80* @M_PI
%27 = load x86_fp80, x86_fp80* @M_PI_2
%28 = fadd x86_fp80 %26, %27
br label %39
29: ; preds = %24
%30 = fcmp ogt x86_fp80 %1, 0xK00000000000000000000
%31 = load x86_fp80, x86_fp80* @M_PI
%32 = fdiv x86_fp80 %0, %1
%33 = tail call x86_fp80 @atanl(x86_fp80 %32)
br i1 %30, label %34, label %37
34: ; preds = %29
%35 = fneg x86_fp80 %33
%36 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %31, x86_fp80 0xK40008000000000000000, x86_fp80 %35)
br label %39
37: ; preds = %29
%38 = fadd x86_fp80 %31, %33
br label %39
39: ; preds = %4, %37, %34, %25, %19, %16, %12, %6
%40 = phi x86_fp80 [ %7, %6 ], [ %13, %12 ], [ %18, %16 ], [ %23, %19 ], [ %28, %25 ], [ %36, %34 ], [ %38, %37 ], [ 0xK00000000000000000000, %4 ]
ret x86_fp80 %40
}