#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 /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ factor(double, int *, int *);
double man_serie(int);
int /*<<< orphan*/ printf(char *, double, int, int, int, int);
int /*<<< orphan*/ puts(char *);
double sav_serie(int);
double wolf_serie(int);
double sqrt_(double z, int num) {
  int k = 1, x = 1;
  double heuristic;
  factor(z, &x, &k);
  puts("-->Input!\n");
  printf("z = %lf => k = %d | x = %d <=> z^(1/2) = %dV%d\n\n", z, k, x, k, x);
  puts("-->Processing!\n");
  switch (num) {
  case 1:
    heuristic = man_serie(x);
    break;
  case 2:
    heuristic = sav_serie(x - 1);
    break;
  case 3:
    heuristic = wolf_serie(x);
    break;
  default:
    puts("WAT'?! What you are doing with me? D:");
    exit(EXIT_FAILURE);
  }
  return k * heuristic;
}


x86 assembly (clang, -O0):
<sqrt_>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
movsd  -0x8(%rbp),%xmm0
lea    -0x14(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1080 <factor@plt>
lea    0xe59(%rip),%rdi
call   1040 <puts@plt>
movsd  -0x8(%rbp),%xmm0
mov    -0x10(%rbp),%ecx
mov    -0x14(%rbp),%r8d
lea    0xe4c(%rip),%rdi
mov    %ecx,%esi
mov    %r8d,%edx
call   1060 <printf@plt>
lea    0xe6c(%rip),%rdi
call   1040 <puts@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x1,%eax
je     120b <sqrt_+0x9b>
jmp    11e9 <sqrt_+0x79>
mov    -0x24(%rbp),%eax
sub    $0x2,%eax
je     121d <sqrt_+0xad>
jmp    11fa <sqrt_+0x8a>
mov    -0x24(%rbp),%eax
sub    $0x3,%eax
je     1232 <sqrt_+0xc2>
jmp    1244 <sqrt_+0xd4>
mov    -0x14(%rbp),%edi
call   1070 <man_serie@plt>
movsd  %xmm0,-0x20(%rbp)
jmp    125e <sqrt_+0xee>
mov    -0x14(%rbp),%edi
sub    $0x1,%edi
call   1050 <sav_serie@plt>
movsd  %xmm0,-0x20(%rbp)
jmp    125e <sqrt_+0xee>
mov    -0x14(%rbp),%edi
call   1030 <wolf_serie@plt>
movsd  %xmm0,-0x20(%rbp)
jmp    125e <sqrt_+0xee>
lea    0xe01(%rip),%rdi
call   1040 <puts@plt>
mov    0x2d89(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
cvtsi2sdl -0x10(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sqrt_>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
movsd  %xmm0,0x8(%rsp)
movl   $0x1,0x4(%rsp)
movl   $0x1,(%rsp)
mov    %rsp,%rdi
lea    0x4(%rsp),%rsi
call   1080 <factor@plt>
lea    0xe60(%rip),%rdi
call   1040 <puts@plt>
mov    0x4(%rsp),%ecx
mov    (%rsp),%edx
lea    0xe58(%rip),%rdi
movsd  0x8(%rsp),%xmm0
mov    %ecx,%esi
mov    %edx,%r8d
call   1060 <printf@plt>
lea    0xe72(%rip),%rdi
call   1040 <puts@plt>
cmp    $0x3,%ebx
je     11e8 <sqrt_+0x78>
cmp    $0x2,%ebx
je     11f2 <sqrt_+0x82>
cmp    $0x1,%ebx
jne    1211 <sqrt_+0xa1>
mov    (%rsp),%edi
call   1070 <man_serie@plt>
jmp    11fd <sqrt_+0x8d>
mov    (%rsp),%edi
call   1030 <wolf_serie@plt>
jmp    11fd <sqrt_+0x8d>
mov    (%rsp),%edi
add    $0xffffffff,%edi
call   1050 <sav_serie@plt>
cvtsi2sdl 0x4(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe34(%rip),%rdi
call   1040 <puts@plt>
mov    0x2dbc(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"-->Input!\0A\00"
@.str.1 = [49 x i8] c"z = %lf => k = %d | x = %d <=> z^(1/2) = %dV%d\0A\0A\00"
@.str.2 = [16 x i8] c"-->Processing!\0A\00"
@.str.3 = [38 x i8] c"WAT'?! What you are doing with me? D:\00"
@EXIT_FAILURE = global i32 0
define double @sqrt_(double %0, i32 %1) {
%3 = alloca double
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
store double %0, double* %3
store i32 %1, i32* %4
store i32 1, i32* %5
store i32 1, i32* %6
%8 = load double, double* %3
%9 = call i32 @factor(double %8, i32* %6, i32* %5)
%10 = call i32 @puts(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%11 = load double, double* %3
%12 = load i32, i32* %5
%13 = load i32, i32* %6
%14 = load i32, i32* %5
%15 = load i32, i32* %6
%16 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), double %11, i32 %12, i32 %13, i32 %14, i32 %15)
%17 = call i32 @puts(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%18 = load i32, i32* %4
switch i32 %18, label %29 [
i32 1, label %19
i32 2, label %22
i32 3, label %26
]
19: ; preds = %2
%20 = load i32, i32* %6
%21 = call double @man_serie(i32 %20)
store double %21, double* %7
br label %33
22: ; preds = %2
%23 = load i32, i32* %6
%24 = sub nsw i32 %23, 1
%25 = call double @sav_serie(i32 %24)
store double %25, double* %7
br label %33
26: ; preds = %2
%27 = load i32, i32* %6
%28 = call double @wolf_serie(i32 %27)
store double %28, double* %7
br label %33
29: ; preds = %2
%30 = call i32 @puts(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0))
%31 = load i32, i32* @EXIT_FAILURE
%32 = call i32 @exit(i32 %31)
unreachable
33: ; preds = %26, %22, %19
%34 = load i32, i32* %5
%35 = sitofp i32 %34 to double
%36 = load double, double* %7
%37 = fmul double %35, %36
ret double %37
}

LLVM IR (-O2):
@.str = [11 x i8] c"-->Input!\0A\00"
@.str.1 = [49 x i8] c"z = %lf => k = %d | x = %d <=> z^(1/2) = %dV%d\0A\0A\00"
@.str.2 = [16 x i8] c"-->Processing!\0A\00"
@.str.3 = [38 x i8] c"WAT'?! What you are doing with me? D:\00"
@EXIT_FAILURE = global i32 0
define double @sqrt_(double %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
store i32 1, i32* %3
%6 = bitcast i32* %4 to i8*
store i32 1, i32* %4
%7 = call i32 @factor(double %0, i32* %4, i32* %3)
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* %3
%10 = load i32, i32* %4
%11 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), double %0, i32 %9, i32 %10, i32 %9, i32 %10)
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
switch i32 %1, label %23 [
i32 1, label %13
i32 2, label %16
i32 3, label %20
]
13: ; preds = %2
%14 = load i32, i32* %4
%15 = call double @man_serie(i32 %14)
br label %27
16: ; preds = %2
%17 = load i32, i32* %4
%18 = add nsw i32 %17, -1
%19 = call double @sav_serie(i32 %18)
br label %27
20: ; preds = %2
%21 = load i32, i32* %4
%22 = call double @wolf_serie(i32 %21)
br label %27
23: ; preds = %2
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0))
%25 = load i32, i32* @EXIT_FAILURE
%26 = call i32 @exit(i32 %25)
unreachable
27: ; preds = %20, %16, %13
%28 = phi double [ %22, %20 ], [ %19, %16 ], [ %15, %13 ]
%29 = load i32, i32* %3
%30 = sitofp i32 %29 to double
%31 = fmul double %28, %30
ret double %31
}