#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 my_pow_10(int);
double manage_digit(double result, char c, int dot, int pow, int sign) {
  double x = c - '0';
  if (dot == 1) {
    x *= my_pow_10(pow);
    pow -= 1;
    result += x;
  } else {
    result += x;
    result *= my_pow_10(pow);
  }
  return result;
}


x86 assembly (clang, -O0):
<manage_digit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
movsd  %xmm0,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    %esi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movsbl -0x9(%rbp),%eax
sub    $0x30,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x20(%rbp)
cmpl   $0x1,-0x10(%rbp)
jne    1175 <manage_digit+0x65>
mov    -0x14(%rbp),%edi
call   1030 <my_pow_10@plt>
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
movsd  -0x20(%rbp),%xmm0
addsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1196 <manage_digit+0x86>
movsd  -0x20(%rbp),%xmm0
addsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <my_pow_10@plt>
mulsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<manage_digit>:
sub    $0x18,%rsp
add    $0xffffffd0,%edi
cvtsi2sd %edi,%xmm1
cmp    $0x1,%esi
jne    1144 <manage_digit+0x34>
mov    %edx,%edi
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,0x10(%rsp)
call   1030 <my_pow_10@plt>
mulsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
add    $0x18,%rsp
ret
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
mov    %edx,%edi
call   1030 <my_pow_10@plt>
mulsd  0x8(%rsp),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @manage_digit(double %0, i8 signext %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca double
%7 = alloca i8
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca double
store double %0, double* %6
store i8 %1, i8* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%12 = load i8, i8* %7
%13 = sext i8 %12 to i32
%14 = sub nsw i32 %13, 48
%15 = sitofp i32 %14 to double
store double %15, double* %11
%16 = load i32, i32* %8
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %28
18: ; preds = %5
%19 = load i32, i32* %9
%20 = call double @my_pow_10(i32 %19)
%21 = load double, double* %11
%22 = fmul double %21, %20
store double %22, double* %11
%23 = load i32, i32* %9
%24 = sub nsw i32 %23, 1
store i32 %24, i32* %9
%25 = load double, double* %11
%26 = load double, double* %6
%27 = fadd double %26, %25
store double %27, double* %6
br label %36
28: ; preds = %5
%29 = load double, double* %11
%30 = load double, double* %6
%31 = fadd double %30, %29
store double %31, double* %6
%32 = load i32, i32* %9
%33 = call double @my_pow_10(i32 %32)
%34 = load double, double* %6
%35 = fmul double %34, %33
store double %35, double* %6
br label %36
36: ; preds = %28, %18
%37 = load double, double* %6
ret double %37
}

LLVM IR (-O2):
define double @manage_digit(double %0, i8 signext %1, i32 %2, i32 %3, i32 %4) {
%6 = sext i8 %1 to i32
%7 = add nsw i32 %6, -48
%8 = sitofp i32 %7 to double
%9 = icmp eq i32 %2, 1
br i1 %9, label %10, label %14
10: ; preds = %5
%11 = tail call double @my_pow_10(i32 %3)
%12 = fmul double %11, %8
%13 = fadd double %12, %0
br label %18
14: ; preds = %5
%15 = fadd double %8, %0
%16 = tail call double @my_pow_10(i32 %3)
%17 = fmul double %15, %16
br label %18
18: ; preds = %14, %10
%19 = phi double [ %13, %10 ], [ %17, %14 ]
ret double %19
}