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


x86 assembly (clang, -O0):
<atan2f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1176 <atan2f+0x66>
jp     1176 <atan2f+0x66>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1161 <atan2f+0x51>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    12e9 <atan2f+0x1d9>
mov    0x2e80(%rip),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    12e9 <atan2f+0x1d9>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1221 <atan2f+0x111>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11bd <atan2f+0xad>
jp     11bd <atan2f+0xad>
mov    0x2e31(%rip),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    12e9 <atan2f+0x1d9>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11ec <atan2f+0xdc>
movss  -0x8(%rbp),%xmm0
divss  -0xc(%rbp),%xmm0
call   1030 <atanf@plt>
movss  %xmm0,-0x4(%rbp)
jmp    12e9 <atan2f+0x1d9>
mov    0x2df5(%rip),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x8(%rbp),%xmm0
divss  -0xc(%rbp),%xmm0
call   1030 <atanf@plt>
movaps %xmm0,%xmm1
movss  -0x10(%rbp),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    12e9 <atan2f+0x1d9>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    125d <atan2f+0x14d>
jp     125d <atan2f+0x14d>
mov    0x2da4(%rip),%rax
movss  (%rax),%xmm0
mov    0x2d91(%rip),%rax
addss  (%rax),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    12e9 <atan2f+0x1d9>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    12b9 <atan2f+0x1a9>
mov    0x2d6e(%rip),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x8(%rbp),%xmm0
divss  -0xc(%rbp),%xmm0
call   1030 <atanf@plt>
movaps %xmm0,%xmm1
movss  -0x14(%rbp),%xmm0
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
addss  %xmm0,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    12e9 <atan2f+0x1d9>
mov    0x2d28(%rip),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x8(%rbp),%xmm0
divss  -0xc(%rbp),%xmm0
call   1030 <atanf@plt>
movaps %xmm0,%xmm1
movss  -0x18(%rbp),%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<atan2f>:
push   %rax
movaps %xmm1,%xmm2
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1137 <atan2f+0x27>
jp     1137 <atan2f+0x27>
ucomiss %xmm1,%xmm2
jae    11e1 <atan2f+0xd1>
mov    0x2eba(%rip),%rax
movss  (%rax),%xmm1
jmp    11e1 <atan2f+0xd1>
xorps  %xmm1,%xmm1
jbe    1153 <atan2f+0x43>
ucomiss %xmm1,%xmm2
jne    1172 <atan2f+0x62>
jp     1172 <atan2f+0x62>
mov    0x2e96(%rip),%rax
movss  (%rax),%xmm1
jmp    11e1 <atan2f+0xd1>
mov    0x2e8e(%rip),%rax
ucomiss %xmm1,%xmm2
jne    117e <atan2f+0x6e>
jp     117e <atan2f+0x6e>
movss  (%rax),%xmm1
mov    0x2e74(%rip),%rax
addss  (%rax),%xmm1
jmp    11e1 <atan2f+0xd1>
jbe    11b4 <atan2f+0xa4>
divss  %xmm2,%xmm0
pop    %rax
jmp    1030 <atanf@plt>
movss  (%rax),%xmm1
movss  %xmm1,(%rsp)
divss  %xmm2,%xmm0
movss  %xmm2,0x4(%rsp)
call   1030 <atanf@plt>
movss  0x4(%rsp),%xmm1
ucomiss 0xe5d(%rip),%xmm1
jbe    11d8 <atan2f+0xc8>
movss  (%rsp),%xmm1
addss  %xmm1,%xmm1
subss  %xmm0,%xmm1
jmp    11e1 <atan2f+0xd1>
mov    0x2e2d(%rip),%rax
movss  (%rax),%xmm1
movss  %xmm1,(%rsp)
divss  %xmm2,%xmm0
call   1030 <atanf@plt>
movss  (%rsp),%xmm1
subss  %xmm0,%xmm1
jmp    11e1 <atan2f+0xd1>
movss  (%rsp),%xmm1
addss  %xmm0,%xmm1
movaps %xmm1,%xmm0
pop    %rax
ret

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

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