#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 calculate(char *, unsigned char);
scalar_t__ calculateLessThan1(char *, unsigned char);
char *strchr(char *, char);
double calculateReal(char *numb, unsigned char base) {
  char *pointPos;
  char minus;
  double result;
  if ('-' == *numb) {
    minus = -1;
    numb++;
  } else
    minus = 1;
  if (NULL == (pointPos = strchr(numb, '.')))
    return calculate(numb, base);
  *pointPos = '\0';
  result = calculate(numb, base);
  *pointPos = '.';
  result += calculateLessThan1(pointPos + 1, base);
  return minus * result;
}


x86 assembly (clang, -O0):
<calculateReal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %sil,%al
mov    %rdi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x2d,%eax
cmp    %ecx,%eax
jne    116b <calculateReal+0x3b>
movb   $0xff,-0x21(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    116f <calculateReal+0x3f>
movb   $0x1,-0x21(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2e,%esi
call   1030 <strchr@plt>
mov    %rax,%rcx
mov    %rcx,-0x20(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
jne    11a6 <calculateReal+0x76>
mov    -0x10(%rbp),%rdi
movzbl -0x11(%rbp),%esi
call   1050 <calculate@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    11f8 <calculateReal+0xc8>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
movzbl -0x11(%rbp),%esi
call   1050 <calculate@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0x20(%rbp),%rax
movb   $0x2e,(%rax)
mov    -0x20(%rbp),%rdi
add    $0x1,%rdi
movzbl -0x11(%rbp),%esi
call   1040 <calculateLessThan1@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsbl -0x21(%rbp),%eax
cvtsi2sd %eax,%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calculateReal>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r14d
mov    (%rdi),%r15b
xor    %ebx,%ebx
cmp    $0x2d,%r15b
sete   %bl
add    %rdi,%rbx
mov    %rbx,%rdi
mov    $0x2e,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     11ae <calculateReal+0x7e>
mov    %rax,%rbp
movb   $0x0,(%rax)
movzbl %r14b,%r14d
mov    %rbx,%rdi
mov    %r14d,%esi
call   1050 <calculate@plt>
movsd  %xmm0,(%rsp)
movb   $0x2e,0x0(%rbp)
add    $0x1,%rbp
mov    %rbp,%rdi
mov    %r14d,%esi
call   1040 <calculateLessThan1@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
cmp    $0x2d,%r15b
jne    11a3 <calculateReal+0x73>
xorpd  0xe5d(%rip),%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
movzbl %r14b,%esi
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <calculate@plt>

LLVM IR (-O0):
define double @calculateReal(i8* %0, i8 zeroext %1) {
%3 = alloca double
%4 = alloca i8*
%5 = alloca i8
%6 = alloca i8*
%7 = alloca i8
%8 = alloca double
store i8* %0, i8** %4
store i8 %1, i8* %5
%9 = load i8*, i8** %4
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp eq i32 45, %11
br i1 %12, label %13, label %16
13: ; preds = %2
store i8 -1, i8* %7
%14 = load i8*, i8** %4
%15 = getelementptr inbounds i8, i8* %14, i32 1
store i8* %15, i8** %4
br label %17
16: ; preds = %2
store i8 1, i8* %7
br label %17
17: ; preds = %16, %13
%18 = load i8*, i8** %4
%19 = call i8* @strchr(i8* %18, i8 signext 46)
store i8* %19, i8** %6
%20 = icmp eq i8* null, %19
br i1 %20, label %21, label %25
21: ; preds = %17
%22 = load i8*, i8** %4
%23 = load i8, i8* %5
%24 = call double @calculate(i8* %22, i8 zeroext %23)
store double %24, double* %3
br label %43
25: ; preds = %17
%26 = load i8*, i8** %6
store i8 0, i8* %26
%27 = load i8*, i8** %4
%28 = load i8, i8* %5
%29 = call double @calculate(i8* %27, i8 zeroext %28)
store double %29, double* %8
%30 = load i8*, i8** %6
store i8 46, i8* %30
%31 = load i8*, i8** %6
%32 = getelementptr inbounds i8, i8* %31, i64 1
%33 = load i8, i8* %5
%34 = call i64 @calculateLessThan1(i8* %32, i8 zeroext %33)
%35 = sitofp i64 %34 to double
%36 = load double, double* %8
%37 = fadd double %36, %35
store double %37, double* %8
%38 = load i8, i8* %7
%39 = sext i8 %38 to i32
%40 = sitofp i32 %39 to double
%41 = load double, double* %8
%42 = fmul double %40, %41
store double %42, double* %3
br label %43
43: ; preds = %25, %21
%44 = load double, double* %3
ret double %44
}

LLVM IR (-O2):
define double @calculateReal(i8* %0, i8 zeroext %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 45
%5 = zext i1 %4 to i64
%6 = getelementptr i8, i8* %0, i64 %5
%7 = tail call i8* @strchr(i8* %6, i8 signext 46)
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = tail call double @calculate(i8* %6, i8 zeroext %1)
br label %19
11: ; preds = %2
store i8 0, i8* %7
%12 = tail call double @calculate(i8* %6, i8 zeroext %1)
store i8 46, i8* %7
%13 = getelementptr inbounds i8, i8* %7, i64 1
%14 = tail call i64 @calculateLessThan1(i8* %13, i8 zeroext %1)
%15 = sitofp i64 %14 to double
%16 = fadd double %12, %15
%17 = fneg double %16
%18 = select i1 %4, double %17, double %16
br label %19
19: ; preds = %11, %9
%20 = phi double [ %10, %9 ], [ %18, %11 ]
ret double %20
}