#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 pow(float, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, float *, int *);
int main() {
  int n = 0;
  float x = 0, arctanh = 0;
  int done = 0;
  do {
    printf("Enter x and the number of terms of series: ");
    scanf("%f %d", &x, &n);
    if (x <= 1.0 && x >= -1.0 && n > 5 && n < 100)
      done = !done;
  } while (!done);
  int cnt = 1;
  int i = 0;
  for (i = 0; i < n; i++) {
    arctanh += pow(x, cnt) / (double)(cnt);
    cnt += 2;
  }
  printf("tanh-1(%.6f) = %.9f", x, arctanh);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeca(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x8(%rbp),%rdx
call   1040 <scanf@plt>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe70(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     11da <main+0xaa>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe5d(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11da <main+0xaa>
cmpl   $0x5,-0x8(%rbp)
jle    11da <main+0xaa>
cmpl   $0x64,-0x8(%rbp)
jge    11da <main+0xaa>
cmpl   $0x0,-0x14(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x14(%rbp)
jmp    11df <main+0xaf>
cmpl   $0x0,-0x14(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    115d <main+0x2d>
movl   $0x1,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1257 <main+0x127>
movss  -0xc(%rbp),%xmm0
mov    -0x18(%rbp),%edi
call   1050 <pow@plt>
movaps %xmm0,%xmm1
cvtsi2sdl -0x18(%rbp),%xmm0
divsd  %xmm0,%xmm1
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
mov    -0x18(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1205 <main+0xd5>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xdd2(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
movl   $0x0,(%rsp)
movl   $0x0,0x4(%rsp)
lea    0xeb6(%rip),%r14
lea    0xedb(%rip),%r15
lea    0x4(%rsp),%r12
mov    %rsp,%rbx
jmp    1174 <main+0x44>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
test   %ebp,%ebp
jne    11c3 <main+0x93>
xor    %ebp,%ebp
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1040 <scanf@plt>
movss  0x4(%rsp),%xmm0
movss  0xe64(%rip),%xmm1
ucomiss %xmm0,%xmm1
jb     1170 <main+0x40>
ucomiss 0xe5c(%rip),%xmm0
setae  %al
mov    (%rsp),%ecx
cmp    $0x6,%ecx
setge  %dl
cmp    $0x64,%ecx
setl   %cl
and    %dl,%cl
and    %al,%cl
movzbl %cl,%ebp
jmp    1170 <main+0x40>
cmpl   $0x0,(%rsp)
jle    1242 <main+0x112>
mov    $0x1,%ebp
mov    $0x1,%edi
call   1050 <pow@plt>
xorps  %xmm1,%xmm1
addsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
cmpl   $0x2,(%rsp)
jl     123a <main+0x10a>
mov    $0x3,%ebx
nopl   0x0(%rax,%rax,1)
movsd  %xmm1,0x8(%rsp)
movss  0x4(%rsp),%xmm0
mov    %ebx,%edi
call   1050 <pow@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
divsd  %xmm1,%xmm0
addsd  0x8(%rsp),%xmm0
cvtsd2ss %xmm0,%xmm0
add    $0x1,%ebp
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
add    $0x2,%ebx
cmp    (%rsp),%ebp
jl     1200 <main+0xd0>
movss  0x4(%rsp),%xmm0
jmp    1245 <main+0x115>
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm0
lea    0xdea(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [44 x i8] c"Enter x and the number of terms of series: \00"
@.str.1 = [6 x i8] c"%f %d\00"
@.str.2 = [20 x i8] c"tanh-1(%.6f) = %.9f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float
%4 = alloca float
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store float 0.000000e+00, float* %3
store float 0.000000e+00, float* %4
store i32 0, i32* %5
br label %8
8: ; preds = %30, %0
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), float* %3, i32* %2)
%11 = load float, float* %3
%12 = fpext float %11 to double
%13 = fcmp ole double %12, 1.000000e+00
br i1 %13, label %14, label %29
14: ; preds = %8
%15 = load float, float* %3
%16 = fpext float %15 to double
%17 = fcmp oge double %16, -1.000000e+00
br i1 %17, label %18, label %29
18: ; preds = %14
%19 = load i32, i32* %2
%20 = icmp sgt i32 %19, 5
br i1 %20, label %21, label %29
21: ; preds = %18
%22 = load i32, i32* %2
%23 = icmp slt i32 %22, 100
br i1 %23, label %24, label %29
24: ; preds = %21
%25 = load i32, i32* %5
%26 = icmp ne i32 %25, 0
%27 = xor i1 %26, true
%28 = zext i1 %27 to i32
store i32 %28, i32* %5
br label %29
29: ; preds = %24, %21, %18, %14, %8
br label %30
30: ; preds = %29
%31 = load i32, i32* %5
%32 = icmp ne i32 %31, 0
%33 = xor i1 %32, true
br i1 %33, label %8, label %34
34: ; preds = %30
store i32 1, i32* %6
store i32 0, i32* %7
store i32 0, i32* %7
br label %35
35: ; preds = %52, %34
%36 = load i32, i32* %7
%37 = load i32, i32* %2
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %55
39: ; preds = %35
%40 = load float, float* %3
%41 = load i32, i32* %6
%42 = call double @pow(float %40, i32 %41)
%43 = load i32, i32* %6
%44 = sitofp i32 %43 to double
%45 = fdiv double %42, %44
%46 = load float, float* %4
%47 = fpext float %46 to double
%48 = fadd double %47, %45
%49 = fptrunc double %48 to float
store float %49, float* %4
%50 = load i32, i32* %6
%51 = add nsw i32 %50, 2
store i32 %51, i32* %6
br label %52
52: ; preds = %39
%53 = load i32, i32* %7
%54 = add nsw i32 %53, 1
store i32 %54, i32* %7
br label %35
55: ; preds = %35
%56 = load float, float* %3
%57 = fpext float %56 to double
%58 = load float, float* %4
%59 = fpext float %58 to double
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), double %57, double %59)
ret i32 0
}

LLVM IR (-O2):
@.str = [44 x i8] c"Enter x and the number of terms of series: \00"
@.str.1 = [6 x i8] c"%f %d\00"
@.str.2 = [20 x i8] c"tanh-1(%.6f) = %.9f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%4 = bitcast float* %2 to i8*
store float 0.000000e+00, float* %2
br label %5
5: ; preds = %18, %0
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), float* %2, i32* %1)
%8 = load float, float* %2
%9 = fcmp ugt float %8, 1.000000e+00
br i1 %9, label %18, label %10
10: ; preds = %5
%11 = fcmp oge float %8, -1.000000e+00
%12 = load i32, i32* %1
%13 = icmp sgt i32 %12, 5
%14 = select i1 %11, i1 %13, i1 false
%15 = icmp slt i32 %12, 100
%16 = select i1 %14, i1 %15, i1 false
%17 = zext i1 %16 to i32
br label %18
18: ; preds = %10, %5
%19 = phi i32 [ 0, %5 ], [ %17, %10 ]
%20 = icmp eq i32 %19, 0
br i1 %20, label %5, label %21
21: ; preds = %18
%22 = load i32, i32* %1
%23 = icmp sgt i32 %22, 0
br i1 %23, label %24, label %49
24: ; preds = %21
%25 = call double @pow(float %8, i32 1)
%26 = fadd double %25, 0.000000e+00
%27 = fptrunc double %26 to float
%28 = fpext float %27 to double
%29 = load i32, i32* %1
%30 = icmp sgt i32 %29, 1
br i1 %30, label %31, label %46
31: ; preds = %24, %31
%32 = phi double [ %43, %31 ], [ %28, %24 ]
%33 = phi i32 [ %42, %31 ], [ 1, %24 ]
%34 = phi i32 [ %35, %31 ], [ 1, %24 ]
%35 = add nuw nsw i32 %34, 2
%36 = load float, float* %2
%37 = call double @pow(float %36, i32 %35)
%38 = sitofp i32 %35 to double
%39 = fdiv double %37, %38
%40 = fadd double %32, %39
%41 = fptrunc double %40 to float
%42 = add nuw nsw i32 %33, 1
%43 = fpext float %41 to double
%44 = load i32, i32* %1
%45 = icmp slt i32 %42, %44
br i1 %45, label %31, label %46
46: ; preds = %31, %24
%47 = phi double [ %28, %24 ], [ %43, %31 ]
%48 = load float, float* %2
br label %49
49: ; preds = %46, %21
%50 = phi float [ %8, %21 ], [ %48, %46 ]
%51 = phi double [ 0.000000e+00, %21 ], [ %47, %46 ]
%52 = fpext float %50 to double
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), double %52, double %51)
ret i32 0
}