#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 NAN;
double cosinush(double, unsigned int);
scalar_t__ isinf(double);
scalar_t__ isnan(double);
double sinush(double, unsigned int);
double tangensh(double num, unsigned int sigdig) {
  if (sigdig < 1) {
    return NAN;
  }
  if (isnan(num) || isinf(num)) {
    return num;
  }
  double s = sinush(num, sigdig);
  double c = cosinush(num, sigdig);
  return s / c;
}


x86 assembly (clang, -O0):
<tangensh>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
mov    %edi,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jae    116f <tangensh+0x2f>
mov    0x2e97(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11d9 <tangensh+0x99>
movsd  -0x10(%rbp),%xmm0
call   1040 <isnan@plt>
cmp    $0x0,%rax
jne    1197 <tangensh+0x57>
movsd  -0x10(%rbp),%xmm0
call   1060 <isinf@plt>
cmp    $0x0,%rax
je     11a6 <tangensh+0x66>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11d9 <tangensh+0x99>
movsd  -0x10(%rbp),%xmm0
mov    -0x14(%rbp),%edi
call   1030 <sinush@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    -0x14(%rbp),%edi
call   1050 <cosinush@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tangensh>:
push   %rbx
sub    $0x10,%rsp
test   %edi,%edi
je     1170 <tangensh+0x30>
mov    %edi,%ebx
movsd  %xmm0,(%rsp)
call   1040 <isnan@plt>
test   %rax,%rax
jne    1169 <tangensh+0x29>
movsd  (%rsp),%xmm0
call   1060 <isinf@plt>
test   %rax,%rax
je     117d <tangensh+0x3d>
movsd  (%rsp),%xmm0
jmp    11a9 <tangensh+0x69>
mov    0x2e81(%rip),%rax
movsd  (%rax),%xmm0
jmp    11a9 <tangensh+0x69>
movsd  (%rsp),%xmm0
mov    %ebx,%edi
call   1030 <sinush@plt>
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
mov    %ebx,%edi
call   1050 <cosinush@plt>
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@NAN = global double 0.000000e+00
define double @tangensh(double %0, i32 %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca i32
%6 = alloca double
%7 = alloca double
store double %0, double* %4
store i32 %1, i32* %5
%8 = load i32, i32* %5
%9 = icmp ult i32 %8, 1
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = load double, double* @NAN
store double %11, double* %3
br label %32
12: ; preds = %2
%13 = load double, double* %4
%14 = call i64 @isnan(double %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %20, label %16
16: ; preds = %12
%17 = load double, double* %4
%18 = call i64 @isinf(double %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %16, %12
%21 = load double, double* %4
store double %21, double* %3
br label %32
22: ; preds = %16
%23 = load double, double* %4
%24 = load i32, i32* %5
%25 = call double @sinush(double %23, i32 %24)
store double %25, double* %6
%26 = load double, double* %4
%27 = load i32, i32* %5
%28 = call double @cosinush(double %26, i32 %27)
store double %28, double* %7
%29 = load double, double* %6
%30 = load double, double* %7
%31 = fdiv double %29, %30
store double %31, double* %3
br label %32
32: ; preds = %22, %20, %10
%33 = load double, double* %3
ret double %33
}

LLVM IR (-O2):
@NAN = global double 0.000000e+00
define double @tangensh(double %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = load double, double* @NAN
br label %16
6: ; preds = %2
%7 = tail call i64 @isnan(double %0)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %16
9: ; preds = %6
%10 = tail call i64 @isinf(double %0)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %9
%13 = tail call double @sinush(double %0, i32 %1)
%14 = tail call double @cosinush(double %0, i32 %1)
%15 = fdiv double %13, %14
br label %16
16: ; preds = %6, %9, %12, %4
%17 = phi double [ %5, %4 ], [ %15, %12 ], [ %0, %9 ], [ %0, %6 ]
ret double %17
}