#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 atan(double);
double atof(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
double log(double);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
double tan(double);
int main(int argc, char **argv) {
  if (argc != 2) {
    fprintf(stderr, "usage: %s cot(theta) \n", argv[0]);
    return 1;
  }
  double theta = atan(1.0e0 / atof(argv[1]));
  double etaorig = 0.0e0;
  double tantheta2 = tan(theta / 2.0e0);
  if (tantheta2 < 0.0)
    etaorig = 1.0e0 * log(-1.0e0 * tantheta2);
  else
    etaorig = -1.0e0 * log(tantheta2);
  fprintf(stdout, "eta: %f \n", etaorig);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     119a <main+0x4a>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe91(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    125d <main+0x10d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <atof@plt>
movaps %xmm0,%xmm1
movsd  0xe56(%rip),%xmm0
divsd  %xmm1,%xmm0
call   1050 <atan@plt>
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe2b(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1060 <tan@plt>
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    121c <main+0xcc>
movsd  0xe17(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
call   1070 <log@plt>
movaps %xmm0,%xmm1
movsd  0xdfa(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    123a <main+0xea>
movsd  -0x28(%rbp),%xmm0
call   1070 <log@plt>
movaps %xmm0,%xmm1
movsd  0xddf(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    0x2d97(%rip),%rax
mov    (%rax),%edi
movsd  -0x20(%rbp),%xmm0
lea    0xde0(%rip),%rsi
mov    $0x1,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
cmp    $0x2,%edi
jne    11a2 <main+0x52>
mov    0x8(%rsi),%rdi
call   1030 <atof@plt>
movsd  0xe99(%rip),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
call   1050 <atan@plt>
mulsd  0xe8c(%rip),%xmm0
call   1060 <tan@plt>
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jbe    11c3 <main+0x73>
movapd 0xe7d(%rip),%xmm1
xorpd  %xmm0,%xmm1
movapd %xmm1,%xmm0
call   1070 <log@plt>
jmp    11d0 <main+0x80>
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xe6b(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%eax
pop    %rcx
ret
call   1070 <log@plt>
xorpd  0xe40(%rip),%xmm0
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
lea    0xe57(%rip),%rsi
mov    $0x1,%al
call   1040 <fprintf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [23 x i8] c"usage: %s cot(theta) \0A\00"
@stdout = global i32 0
@.str.1 = [10 x i8] c"eta: %f \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca double
%8 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %17
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %15)
store i32 1, i32* %3
br label %42
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call double @atof(i8* %20)
%22 = fdiv double 1.000000e+00, %21
%23 = call double @atan(double %22)
store double %23, double* %6
store double 0.000000e+00, double* %7
%24 = load double, double* %6
%25 = fdiv double %24, 2.000000e+00
%26 = call double @tan(double %25)
store double %26, double* %8
%27 = load double, double* %8
%28 = fcmp olt double %27, 0.000000e+00
br i1 %28, label %29, label %34
29: ; preds = %17
%30 = load double, double* %8
%31 = fmul double -1.000000e+00, %30
%32 = call double @log(double %31)
%33 = fmul double 1.000000e+00, %32
store double %33, double* %7
br label %38
34: ; preds = %17
%35 = load double, double* %8
%36 = call double @log(double %35)
%37 = fmul double -1.000000e+00, %36
store double %37, double* %7
br label %38
38: ; preds = %34, %29
%39 = load i32, i32* @stdout
%40 = load double, double* %7
%41 = call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), double %40)
store i32 0, i32* %3
br label %42
42: ; preds = %38, %11
%43 = load i32, i32* %3
ret i32 %43
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [23 x i8] c"usage: %s cot(theta) \0A\00"
@stdout = global i32 0
@.str.1 = [10 x i8] c"eta: %f \0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %27
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call double @atof(i8* %10)
%12 = fdiv double 1.000000e+00, %11
%13 = tail call double @atan(double %12)
%14 = fmul double %13, 5.000000e-01
%15 = tail call double @tan(double %14)
%16 = fcmp olt double %15, 0.000000e+00
br i1 %16, label %17, label %20
17: ; preds = %8
%18 = fneg double %15
%19 = tail call double @log(double %18)
br label %23
20: ; preds = %8
%21 = tail call double @log(double %15)
%22 = fneg double %21
br label %23
23: ; preds = %20, %17
%24 = phi double [ %19, %17 ], [ %22, %20 ]
%25 = load i32, i32* @stdout
%26 = tail call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), double %24)
br label %27
27: ; preds = %23, %4
%28 = phi i32 [ 1, %4 ], [ 0, %23 ]
ret i32 %28
}