#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 atan(double);
int /*<<< orphan*/ eset(int);
int Marctan(int nargs, int *argsv) {
  if (nargs < 1) {
    eset(21);
    return -1;
  }
  double x = (double)argsv[0];
  x = x / 1000.0;
  return (int)(atan(x) * 180 / 3.14159 + (x > 0 ? 0.5 : -0.5));
}


x86 assembly (clang, -O0):
<Marctan>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jge    114f <Marctan+0x2f>
mov    $0x15,%edi
call   1030 <eset@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c9 <Marctan+0xa9>
mov    -0x10(%rbp),%rax
cvtsi2sdl (%rax),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xeaf(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <atan@plt>
imul   $0xb4,%eax,%eax
cvtsi2sd %eax,%xmm0
movsd  0xe82(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  -0x18(%rbp),%xmm2
movsd  0xe61(%rip),%xmm4
movsd  0xe61(%rip),%xmm3
xorps  %xmm1,%xmm1
cmpltsd %xmm2,%xmm1
movaps %xmm1,%xmm2
andpd  %xmm4,%xmm2
andnpd %xmm3,%xmm1
orpd   %xmm2,%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Marctan>:
push   %rbx
test   %edi,%edi
jle    116a <Marctan+0x4a>
cvtsi2sdl (%rsi),%xmm0
divsd  0xecf(%rip),%xmm0
xorpd  %xmm1,%xmm1
xor    %ebx,%ebx
ucomisd %xmm1,%xmm0
seta   %bl
call   1040 <atan@plt>
imul   $0xb4,%eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  0xeb0(%rip),%xmm0
lea    0xeb1(%rip),%rax
addsd  (%rax,%rbx,8),%xmm0
cvttsd2si %xmm0,%eax
pop    %rbx
ret
mov    $0x15,%edi
call   1030 <eset@plt>
mov    $0xffffffff,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @Marctan(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
%6 = alloca double
store i32 %0, i32* %4
store i32* %1, i32** %5
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 1
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 @eset(i32 21)
store i32 -1, i32* %3
br label %29
11: ; preds = %2
%12 = load i32*, i32** %5
%13 = getelementptr inbounds i32, i32* %12, i64 0
%14 = load i32, i32* %13
%15 = sitofp i32 %14 to double
store double %15, double* %6
%16 = load double, double* %6
%17 = fdiv double %16, 1.000000e+03
store double %17, double* %6
%18 = load double, double* %6
%19 = call i32 @atan(double %18)
%20 = mul nsw i32 %19, 180
%21 = sitofp i32 %20 to double
%22 = fdiv double %21, 3.141590e+00
%23 = load double, double* %6
%24 = fcmp ogt double %23, 0.000000e+00
%25 = zext i1 %24 to i64
%26 = select i1 %24, double 5.000000e-01, double -5.000000e-01
%27 = fadd double %22, %26
%28 = fptosi double %27 to i32
store i32 %28, i32* %3
br label %29
29: ; preds = %11, %9
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
define i32 @Marctan(i32 %0, i32* nocapture %1) {
%3 = icmp slt i32 %0, 1
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @eset(i32 21)
br label %18
6: ; preds = %2
%7 = load i32, i32* %1
%8 = sitofp i32 %7 to double
%9 = fdiv double %8, 1.000000e+03
%10 = tail call i32 @atan(double %9)
%11 = mul nsw i32 %10, 180
%12 = sitofp i32 %11 to double
%13 = fdiv double %12, 3.141590e+00
%14 = fcmp ogt double %9, 0.000000e+00
%15 = select i1 %14, double 5.000000e-01, double -5.000000e-01
%16 = fadd double %13, %15
%17 = fptosi double %16 to i32
br label %18
18: ; preds = %6, %4
%19 = phi i32 [ -1, %4 ], [ %17, %6 ]
ret i32 %19
}