#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 */
typedef scalar_t__ int32_t;

/* Variables and functions */
scalar_t__ abs(scalar_t__);
scalar_t__ sc_div_s32(scalar_t__, scalar_t__, int);
scalar_t__ sc_mul_s32(scalar_t__, scalar_t__, int);
scalar_t__ sc_sqr_s32(scalar_t__, int);
int32_t sc_atan2_s32(int32_t y, int32_t x, int radix) {
  int32_t tmp, c28_m_pi, one;
  int32_t arctantent = 0;
  if ((y != 0) || (x != 0)) {
    c28_m_pi =
        ((int32_t)((((0.28125 * (3.141592653590)) * ((int32_t)1 << ((28)))) < 0)
                       ? (((0.28125 * (3.141592653590)) *
                           ((int32_t)1 << ((28)))) -
                          0.5)
                       : (((0.28125 * (3.141592653590)) *
                           ((int32_t)1 << ((28)))) +
                          0.5)));
    one = (1 << (radix));
    if (abs(y) < abs(x)) {
      tmp = sc_mul_s32(
          ((int32_t)(((((3.141592653590)) * ((int32_t)1 << ((28)))) < 0)
                         ? ((((3.141592653590)) * ((int32_t)1 << ((28)))) - 0.5)
                         : ((((3.141592653590)) * ((int32_t)1 << ((28)))) +
                            0.5))),
          sc_sqr_s32(x, radix), (28));
      tmp += sc_mul_s32(c28_m_pi, sc_sqr_s32(y, radix), (28));
      if (tmp != 0) {
        arctantent = sc_div_s32(sc_mul_s32(x, y, radix), tmp, radix);
      } else {
        arctantent = 0;
      }
      if (x <= 0) {
        if (y >= 0) {
          arctantent = one + arctantent;
        } else {
          arctantent = -one + arctantent;
        }
      }
    } else {
      tmp = sc_mul_s32(
          ((int32_t)(((((3.141592653590)) * ((int32_t)1 << ((28)))) < 0)
                         ? ((((3.141592653590)) * ((int32_t)1 << ((28)))) - 0.5)
                         : ((((3.141592653590)) * ((int32_t)1 << ((28)))) +
                            0.5))),
          sc_sqr_s32(y, radix), (28));
      tmp += sc_mul_s32(c28_m_pi, sc_sqr_s32(x, radix), (28));
      if (tmp != 0) {
        arctantent = sc_div_s32(sc_mul_s32(x, y, radix), tmp, radix);
      } else {
        arctantent = 0;
      }
      if (y > 0) {
        arctantent = one / 2 - arctantent;
      } else {
        if (y < 0) {
          arctantent = -one / 2 - arctantent;
        } else {
          if (x > 0) {
            arctantent = one / 2;
          } else {
            arctantent = -one / 2;
          }
        }
      }
    }
  }
  return arctantent;
}


x86 assembly (clang, -O0):
<sc_atan2_s32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movq   $0x0,-0x38(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1171 <sc_atan2_s32+0x31>
cmpq   $0x0,-0x10(%rbp)
je     139a <sc_atan2_s32+0x25a>
movq   $0xe231d5f,-0x28(%rbp)
0e
mov    -0x14(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
cltq
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <abs@plt>
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <abs@plt>
mov    %rax,%rcx
mov    -0x40(%rbp),%rax
cmp    %rcx,%rax
jge    1278 <sc_atan2_s32+0x138>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <sc_sqr_s32@plt>
mov    %rax,%rsi
mov    $0x3243f6a9,%edi
mov    $0x1c,%edx
call   1060 <sc_mul_s32@plt>
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <sc_sqr_s32@plt>
mov    -0x48(%rbp),%rdi
mov    %rax,%rsi
mov    $0x1c,%edx
call   1060 <sc_mul_s32@plt>
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1231 <sc_atan2_s32+0xf1>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1060 <sc_mul_s32@plt>
mov    %rax,%rdi
mov    -0x20(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1050 <sc_div_s32@plt>
mov    %rax,-0x38(%rbp)
jmp    1239 <sc_atan2_s32+0xf9>
movq   $0x0,-0x38(%rbp)
cmpq   $0x0,-0x10(%rbp)
jg     1273 <sc_atan2_s32+0x133>
cmpq   $0x0,-0x8(%rbp)
jl     1260 <sc_atan2_s32+0x120>
mov    -0x30(%rbp),%rax
add    -0x38(%rbp),%rax
mov    %rax,-0x38(%rbp)
jmp    126e <sc_atan2_s32+0x12e>
xor    %eax,%eax
sub    -0x30(%rbp),%rax
add    -0x38(%rbp),%rax
mov    %rax,-0x38(%rbp)
jmp    1273 <sc_atan2_s32+0x133>
jmp    1395 <sc_atan2_s32+0x255>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <sc_sqr_s32@plt>
mov    %rax,%rsi
mov    $0x3243f6a9,%edi
mov    $0x1c,%edx
call   1060 <sc_mul_s32@plt>
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <sc_sqr_s32@plt>
mov    -0x50(%rbp),%rdi
mov    %rax,%rsi
mov    $0x1c,%edx
call   1060 <sc_mul_s32@plt>
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     12fa <sc_atan2_s32+0x1ba>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1060 <sc_mul_s32@plt>
mov    %rax,%rdi
mov    -0x20(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1050 <sc_div_s32@plt>
mov    %rax,-0x38(%rbp)
jmp    1302 <sc_atan2_s32+0x1c2>
movq   $0x0,-0x38(%rbp)
cmpq   $0x0,-0x8(%rbp)
jle    1328 <sc_atan2_s32+0x1e8>
mov    -0x30(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
sub    -0x38(%rbp),%rax
mov    %rax,-0x38(%rbp)
jmp    1390 <sc_atan2_s32+0x250>
cmpq   $0x0,-0x8(%rbp)
jge    1350 <sc_atan2_s32+0x210>
xor    %eax,%eax
sub    -0x30(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
sub    -0x38(%rbp),%rax
mov    %rax,-0x38(%rbp)
jmp    138b <sc_atan2_s32+0x24b>
cmpq   $0x0,-0x10(%rbp)
jle    1372 <sc_atan2_s32+0x232>
mov    -0x30(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,-0x38(%rbp)
jmp    1386 <sc_atan2_s32+0x246>
xor    %eax,%eax
sub    -0x30(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,-0x38(%rbp)
jmp    138b <sc_atan2_s32+0x24b>
jmp    1390 <sc_atan2_s32+0x250>
jmp    1395 <sc_atan2_s32+0x255>
jmp    139a <sc_atan2_s32+0x25a>
mov    -0x38(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sc_atan2_s32>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rax
or     %rdi,%rax
je     11e5 <sc_atan2_s32+0xb5>
mov    %edx,%r15d
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x1,%r13d
mov    %r15d,%ecx
shl    %cl,%r13d
mov    %rdi,%rax
neg    %rax
cmovs  %rdi,%rax
mov    %rsi,%rcx
neg    %rcx
cmovs  %rsi,%rcx
cmp    %rcx,%rax
jae    11ec <sc_atan2_s32+0xbc>
mov    %r14,%rdi
mov    %r15d,%esi
call   1030 <sc_sqr_s32@plt>
mov    $0x3243f6a9,%edi
mov    %rax,%rsi
mov    $0x1c,%edx
call   1050 <sc_mul_s32@plt>
mov    %rax,%r12
mov    %rbx,%rdi
mov    %r15d,%esi
call   1030 <sc_sqr_s32@plt>
mov    $0xe231d5f,%edi
mov    %rax,%rsi
mov    $0x1c,%edx
call   1050 <sc_mul_s32@plt>
mov    %rax,%rbp
add    %r12,%rbp
je     1252 <sc_atan2_s32+0x122>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1050 <sc_mul_s32@plt>
mov    %rax,%rdi
mov    %rbp,%rsi
mov    %r15d,%edx
call   1040 <sc_div_s32@plt>
test   %r14,%r14
jg     1292 <sc_atan2_s32+0x162>
jmp    1259 <sc_atan2_s32+0x129>
xor    %eax,%eax
jmp    1292 <sc_atan2_s32+0x162>
mov    %rbx,%rdi
mov    %r15d,%esi
call   1030 <sc_sqr_s32@plt>
mov    $0x3243f6a9,%edi
mov    %rax,%rsi
mov    $0x1c,%edx
call   1050 <sc_mul_s32@plt>
mov    %rax,%r12
mov    %r14,%rdi
mov    %r15d,%esi
call   1030 <sc_sqr_s32@plt>
mov    $0xe231d5f,%edi
mov    %rax,%rsi
mov    $0x1c,%edx
call   1050 <sc_mul_s32@plt>
mov    %rax,%rbp
add    %r12,%rbp
je     1266 <sc_atan2_s32+0x136>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1050 <sc_mul_s32@plt>
mov    %rax,%rdi
mov    %rbp,%rsi
mov    %r15d,%edx
call   1040 <sc_div_s32@plt>
mov    %rax,%rcx
jmp    1268 <sc_atan2_s32+0x138>
xor    %eax,%eax
test   %r14,%r14
jg     1292 <sc_atan2_s32+0x162>
movslq %r13d,%rcx
test   %rbx,%rbx
js     127a <sc_atan2_s32+0x14a>
add    %rcx,%rax
jmp    1292 <sc_atan2_s32+0x162>
xor    %ecx,%ecx
mov    %r13d,%eax
test   %rbx,%rbx
jle    127f <sc_atan2_s32+0x14f>
shr    $0x1f,%eax
add    %r13d,%eax
sar    %eax
cltq
sub    %rcx,%rax
jmp    1292 <sc_atan2_s32+0x162>
js     12a1 <sc_atan2_s32+0x171>
shr    $0x1f,%eax
add    %r13d,%eax
sar    %eax
test   %r14,%r14
jg     1290 <sc_atan2_s32+0x160>
neg    %eax
cltq
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
shr    $0x1f,%eax
add    %r13d,%eax
sar    %eax
neg    %eax
jmp    1278 <sc_atan2_s32+0x148>

LLVM IR (-O0):
define i64 @sc_atan2_s32(i64 %0, i64 %1, i32 %2) {
%4 = alloca i64
%5 = alloca i64
%6 = alloca i32
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
store i64 %0, i64* %4
store i64 %1, i64* %5
store i32 %2, i32* %6
store i64 0, i64* %10
%11 = load i64, i64* %4
%12 = icmp ne i64 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %3
%14 = load i64, i64* %5
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %119
16: ; preds = %13, %3
store i64 237182303, i64* %8
%17 = load i32, i32* %6
%18 = shl i32 1, %17
%19 = sext i32 %18 to i64
store i64 %19, i64* %9
%20 = load i64, i64* %4
%21 = call i64 @abs(i64 %20)
%22 = load i64, i64* %5
%23 = call i64 @abs(i64 %22)
%24 = icmp slt i64 %21, %23
br i1 %24, label %25, label %65
25: ; preds = %16
%26 = load i64, i64* %5
%27 = load i32, i32* %6
%28 = call i64 @sc_sqr_s32(i64 %26, i32 %27)
%29 = call i64 @sc_mul_s32(i64 843314857, i64 %28, i32 28)
store i64 %29, i64* %7
%30 = load i64, i64* %8
%31 = load i64, i64* %4
%32 = load i32, i32* %6
%33 = call i64 @sc_sqr_s32(i64 %31, i32 %32)
%34 = call i64 @sc_mul_s32(i64 %30, i64 %33, i32 28)
%35 = load i64, i64* %7
%36 = add nsw i64 %35, %34
store i64 %36, i64* %7
%37 = load i64, i64* %7
%38 = icmp ne i64 %37, 0
br i1 %38, label %39, label %47
39: ; preds = %25
%40 = load i64, i64* %5
%41 = load i64, i64* %4
%42 = load i32, i32* %6
%43 = call i64 @sc_mul_s32(i64 %40, i64 %41, i32 %42)
%44 = load i64, i64* %7
%45 = load i32, i32* %6
%46 = call i64 @sc_div_s32(i64 %43, i64 %44, i32 %45)
store i64 %46, i64* %10
br label %48
47: ; preds = %25
store i64 0, i64* %10
br label %48
48: ; preds = %47, %39
%49 = load i64, i64* %5
%50 = icmp sle i64 %49, 0
br i1 %50, label %51, label %64
51: ; preds = %48
%52 = load i64, i64* %4
%53 = icmp sge i64 %52, 0
br i1 %53, label %54, label %58
54: ; preds = %51
%55 = load i64, i64* %9
%56 = load i64, i64* %10
%57 = add nsw i64 %55, %56
store i64 %57, i64* %10
br label %63
58: ; preds = %51
%59 = load i64, i64* %9
%60 = sub nsw i64 0, %59
%61 = load i64, i64* %10
%62 = add nsw i64 %60, %61
store i64 %62, i64* %10
br label %63
63: ; preds = %58, %54
br label %64
64: ; preds = %63, %48
br label %118
65: ; preds = %16
%66 = load i64, i64* %4
%67 = load i32, i32* %6
%68 = call i64 @sc_sqr_s32(i64 %66, i32 %67)
%69 = call i64 @sc_mul_s32(i64 843314857, i64 %68, i32 28)
store i64 %69, i64* %7
%70 = load i64, i64* %8
%71 = load i64, i64* %5
%72 = load i32, i32* %6
%73 = call i64 @sc_sqr_s32(i64 %71, i32 %72)
%74 = call i64 @sc_mul_s32(i64 %70, i64 %73, i32 28)
%75 = load i64, i64* %7
%76 = add nsw i64 %75, %74
store i64 %76, i64* %7
%77 = load i64, i64* %7
%78 = icmp ne i64 %77, 0
br i1 %78, label %79, label %87
79: ; preds = %65
%80 = load i64, i64* %5
%81 = load i64, i64* %4
%82 = load i32, i32* %6
%83 = call i64 @sc_mul_s32(i64 %80, i64 %81, i32 %82)
%84 = load i64, i64* %7
%85 = load i32, i32* %6
%86 = call i64 @sc_div_s32(i64 %83, i64 %84, i32 %85)
store i64 %86, i64* %10
br label %88
87: ; preds = %65
store i64 0, i64* %10
br label %88
88: ; preds = %87, %79
%89 = load i64, i64* %4
%90 = icmp sgt i64 %89, 0
br i1 %90, label %91, label %96
91: ; preds = %88
%92 = load i64, i64* %9
%93 = sdiv i64 %92, 2
%94 = load i64, i64* %10
%95 = sub nsw i64 %93, %94
store i64 %95, i64* %10
br label %117
96: ; preds = %88
%97 = load i64, i64* %4
%98 = icmp slt i64 %97, 0
br i1 %98, label %99, label %105
99: ; preds = %96
%100 = load i64, i64* %9
%101 = sub nsw i64 0, %100
%102 = sdiv i64 %101, 2
%103 = load i64, i64* %10
%104 = sub nsw i64 %102, %103
store i64 %104, i64* %10
br label %116
105: ; preds = %96
%106 = load i64, i64* %5
%107 = icmp sgt i64 %106, 0
br i1 %107, label %108, label %111
108: ; preds = %105
%109 = load i64, i64* %9
%110 = sdiv i64 %109, 2
store i64 %110, i64* %10
br label %115
111: ; preds = %105
%112 = load i64, i64* %9
%113 = sub nsw i64 0, %112
%114 = sdiv i64 %113, 2
store i64 %114, i64* %10
br label %115
115: ; preds = %111, %108
br label %116
116: ; preds = %115, %99
br label %117
117: ; preds = %116, %91
br label %118
118: ; preds = %117, %64
br label %119
119: ; preds = %118, %13
%120 = load i64, i64* %10
ret i64 %120
}

LLVM IR (-O2):
define i64 @sc_atan2_s32(i64 %0, i64 %1, i32 %2) {
%4 = or i64 %1, %0
%5 = icmp eq i64 %4, 0
br i1 %5, label %62, label %6
6: ; preds = %3
%7 = shl nuw i32 1, %2
%8 = sext i32 %7 to i64
%9 = tail call i64 @llvm.abs.i64(i64 %0, i1 true)
%10 = tail call i64 @llvm.abs.i64(i64 %1, i1 true)
%11 = icmp ult i64 %9, %10
br i1 %11, label %12, label %31
12: ; preds = %6
%13 = tail call i64 @sc_sqr_s32(i64 %1, i32 %2)
%14 = tail call i64 @sc_mul_s32(i64 843314857, i64 %13, i32 28)
%15 = tail call i64 @sc_sqr_s32(i64 %0, i32 %2)
%16 = tail call i64 @sc_mul_s32(i64 237182303, i64 %15, i32 28)
%17 = add nsw i64 %16, %14
%18 = icmp eq i64 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %12
%20 = tail call i64 @sc_mul_s32(i64 %1, i64 %0, i32 %2)
%21 = tail call i64 @sc_div_s32(i64 %20, i64 %17, i32 %2)
br label %22
22: ; preds = %12, %19
%23 = phi i64 [ %21, %19 ], [ 0, %12 ]
%24 = icmp slt i64 %1, 1
br i1 %24, label %25, label %62
25: ; preds = %22
%26 = icmp sgt i64 %0, -1
br i1 %26, label %27, label %29
27: ; preds = %25
%28 = add nsw i64 %23, %8
br label %62
29: ; preds = %25
%30 = sub i64 %23, %8
br label %62
31: ; preds = %6
%32 = tail call i64 @sc_sqr_s32(i64 %0, i32 %2)
%33 = tail call i64 @sc_mul_s32(i64 843314857, i64 %32, i32 28)
%34 = tail call i64 @sc_sqr_s32(i64 %1, i32 %2)
%35 = tail call i64 @sc_mul_s32(i64 237182303, i64 %34, i32 28)
%36 = add nsw i64 %35, %33
%37 = icmp eq i64 %36, 0
br i1 %37, label %41, label %38
38: ; preds = %31
%39 = tail call i64 @sc_mul_s32(i64 %1, i64 %0, i32 %2)
%40 = tail call i64 @sc_div_s32(i64 %39, i64 %36, i32 %2)
br label %41
41: ; preds = %31, %38
%42 = phi i64 [ %40, %38 ], [ 0, %31 ]
%43 = icmp sgt i64 %0, 0
br i1 %43, label %44, label %48
44: ; preds = %41
%45 = sdiv i32 %7, 2
%46 = sext i32 %45 to i64
%47 = sub nsw i64 %46, %42
br label %62
48: ; preds = %41
%49 = icmp slt i64 %0, 0
br i1 %49, label %50, label %54
50: ; preds = %48
%51 = sdiv i32 %7, -2
%52 = sext i32 %51 to i64
%53 = sub nsw i64 %52, %42
br label %62
54: ; preds = %48
%55 = icmp sgt i64 %1, 0
br i1 %55, label %56, label %59
56: ; preds = %54
%57 = sdiv i32 %7, 2
%58 = sext i32 %57 to i64
br label %62
59: ; preds = %54
%60 = sdiv i32 %7, -2
%61 = sext i32 %60 to i64
br label %62
62: ; preds = %27, %29, %22, %50, %59, %56, %44, %3
%63 = phi i64 [ %28, %27 ], [ %30, %29 ], [ %23, %22 ], [ %47, %44 ], [ %53, %50 ], [ %58, %56 ], [ %61, %59 ], [ 0, %3 ]
ret i64 %63
}