#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 double_pow(int, int);
int str_len(char *);
double to_int(char);
double get_dec_frac(char *value, int dot) {
  double frac_part = 0.0;
  int i = 0;
  for (i = dot + 1; i < str_len(value); i++) {
    frac_part += to_int(value[i]) * double_pow(10, -i + dot);
  }
  return frac_part;
}


x86 assembly (clang, -O0):
<get_dec_frac>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <str_len@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cmp    %ecx,%eax
jge    11c3 <get_dec_frac+0x93>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <to_int@plt>
movsd  %xmm0,-0x28(%rbp)
xor    %esi,%esi
sub    -0x1c(%rbp),%esi
add    -0xc(%rbp),%esi
mov    $0xa,%edi
call   1030 <double_pow@plt>
movaps %xmm0,%xmm2
movsd  -0x28(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1157 <get_dec_frac+0x27>
movsd  -0x18(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_dec_frac>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebp
mov    %rdi,%r14
add    $0x1,%ebp
call   1050 <str_len@plt>
xorpd  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
cmp    %eax,%ebp
jge    11b6 <get_dec_frac+0x86>
movslq %ebp,%rbx
xorpd  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
mov    $0xffffffff,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl (%r14,%rbx,1),%edi
call   1040 <to_int@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0xa,%edi
mov    %ebp,%esi
call   1030 <double_pow@plt>
mulsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
add    $0x1,%rbx
mov    %r14,%rdi
call   1050 <str_len@plt>
cltq
add    $0xffffffff,%ebp
cmp    %rax,%rbx
jl     1170 <get_dec_frac+0x40>
movsd  (%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define double @get_dec_frac(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca double
%6 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store double 0.000000e+00, double* %5
store i32 0, i32* %6
%7 = load i32, i32* %4
%8 = add nsw i32 %7, 1
store i32 %8, i32* %6
br label %9
9: ; preds = %28, %2
%10 = load i32, i32* %6
%11 = load i8*, i8** %3
%12 = call i32 @str_len(i8* %11)
%13 = icmp slt i32 %10, %12
br i1 %13, label %14, label %31
14: ; preds = %9
%15 = load i8*, i8** %3
%16 = load i32, i32* %6
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = load i8, i8* %18
%20 = call double @to_int(i8 signext %19)
%21 = load i32, i32* %6
%22 = sub nsw i32 0, %21
%23 = load i32, i32* %4
%24 = add nsw i32 %22, %23
%25 = call double @double_pow(i32 10, i32 %24)
%26 = load double, double* %5
%27 = call double @llvm.fmuladd.f64(double %20, double %25, double %26)
store double %27, double* %5
br label %28
28: ; preds = %14
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 1
store i32 %30, i32* %6
br label %9
31: ; preds = %9
%32 = load double, double* %5
ret double %32
}

LLVM IR (-O2):
define double @get_dec_frac(i8* %0, i32 %1) {
%3 = add i32 %1, 1
%4 = tail call i32 @str_len(i8* %0)
%5 = icmp slt i32 %3, %4
br i1 %5, label %6, label %24
6: ; preds = %2
%7 = sext i32 %3 to i64
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ %7, %6 ], [ %19, %8 ]
%10 = phi i32 [ %1, %6 ], [ %23, %8 ]
%11 = phi double [ 0.000000e+00, %6 ], [ %18, %8 ]
%12 = getelementptr inbounds i8, i8* %0, i64 %9
%13 = load i8, i8* %12
%14 = tail call double @to_int(i8 signext %13)
%15 = xor i32 %10, -1
%16 = add nsw i32 %15, %1
%17 = tail call double @double_pow(i32 10, i32 %16)
%18 = tail call double @llvm.fmuladd.f64(double %14, double %17, double %11)
%19 = add nsw i64 %9, 1
%20 = tail call i32 @str_len(i8* %0)
%21 = sext i32 %20 to i64
%22 = icmp slt i64 %19, %21
%23 = trunc i64 %9 to i32
br i1 %22, label %8, label %24
24: ; preds = %8, %2
%25 = phi double [ 0.000000e+00, %2 ], [ %18, %8 ]
ret double %25
}