#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 */
scalar_t__ ft_atoi(char const *);
int ft_len_untill(char const *, char);
int ft_strlen(char const *);
double ft_atof(const char *str) {
  double result;
  int i;
  result = (double)ft_atoi(str);
  i = ft_len_untill(str, '.');
  if (i) {
    if (result >= 0 && str[0] != '-')
      result +=
          ((double)ft_atoi(str + i + 1)) / ((ft_strlen(str + i + 1) * 10));
    else
      result -=
          ((double)ft_atoi(str + i + 1)) / ((ft_strlen(str + i + 1) * 10));
  }
  return (result);
}


x86 assembly (clang, -O0):
<ft_atof>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <ft_atoi@plt>
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x2e,%esi
call   1040 <ft_len_untill@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1232 <ft_atof+0x102>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11dd <ft_atof+0xad>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
je     11dd <ft_atof+0xad>
mov    -0x8(%rbp),%rdi
movslq -0x14(%rbp),%rax
add    %rax,%rdi
add    $0x1,%rdi
call   1050 <ft_atoi@plt>
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0x14(%rbp),%rax
add    %rax,%rdi
add    $0x1,%rdi
call   1030 <ft_strlen@plt>
movsd  -0x20(%rbp),%xmm0
imul   $0xa,%eax,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    122d <ft_atof+0xfd>
mov    -0x8(%rbp),%rdi
movslq -0x14(%rbp),%rax
add    %rax,%rdi
add    $0x1,%rdi
call   1050 <ft_atoi@plt>
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0x14(%rbp),%rax
add    %rax,%rdi
add    $0x1,%rdi
call   1030 <ft_strlen@plt>
movsd  -0x28(%rbp),%xmm1
imul   $0xa,%eax,%eax
cvtsi2sd %eax,%xmm0
divsd  %xmm0,%xmm1
movsd  -0x10(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1232 <ft_atof+0x102>
movsd  -0x10(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_atof>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
call   1050 <ft_atoi@plt>
mov    %rax,%r14
cvtsi2sd %rax,%xmm0
movsd  %xmm0,0x10(%rsp)
mov    %rbx,%rdi
mov    $0x2e,%esi
call   1040 <ft_len_untill@plt>
test   %eax,%eax
je     11b1 <ft_atof+0x81>
test   %r14,%r14
js     1168 <ft_atof+0x38>
cmpb   $0x2d,(%rbx)
jne    11b9 <ft_atof+0x89>
cltq
add    %rax,%rbx
add    $0x1,%rbx
mov    %rbx,%rdi
call   1050 <ft_atoi@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %rbx,%rdi
call   1030 <ft_strlen@plt>
add    %eax,%eax
lea    (%rax,%rax,4),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  0x10(%rsp),%xmm0
subsd  %xmm1,%xmm0
jmp    1200 <ft_atof+0xd0>
movsd  0x10(%rsp),%xmm0
jmp    1200 <ft_atof+0xd0>
cltq
add    %rax,%rbx
add    $0x1,%rbx
mov    %rbx,%rdi
call   1050 <ft_atoi@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %rbx,%rdi
call   1030 <ft_strlen@plt>
add    %eax,%eax
lea    (%rax,%rax,4),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  0x10(%rsp),%xmm0
addsd  %xmm1,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define double @ft_atof(i8* %0) {
%2 = alloca i8*
%3 = alloca double
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i64 @ft_atoi(i8* %5)
%7 = sitofp i64 %6 to double
store double %7, double* %3
%8 = load i8*, i8** %2
%9 = call i32 @ft_len_untill(i8* %8, i8 signext 46)
store i32 %9, i32* %4
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %60
12: ; preds = %1
%13 = load double, double* %3
%14 = fcmp oge double %13, 0.000000e+00
br i1 %14, label %15, label %40
15: ; preds = %12
%16 = load i8*, i8** %2
%17 = getelementptr inbounds i8, i8* %16, i64 0
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, 45
br i1 %20, label %21, label %40
21: ; preds = %15
%22 = load i8*, i8** %2
%23 = load i32, i32* %4
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = getelementptr inbounds i8, i8* %25, i64 1
%27 = call i64 @ft_atoi(i8* %26)
%28 = sitofp i64 %27 to double
%29 = load i8*, i8** %2
%30 = load i32, i32* %4
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
%33 = getelementptr inbounds i8, i8* %32, i64 1
%34 = call i32 @ft_strlen(i8* %33)
%35 = mul nsw i32 %34, 10
%36 = sitofp i32 %35 to double
%37 = fdiv double %28, %36
%38 = load double, double* %3
%39 = fadd double %38, %37
store double %39, double* %3
br label %59
40: ; preds = %15, %12
%41 = load i8*, i8** %2
%42 = load i32, i32* %4
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %41, i64 %43
%45 = getelementptr inbounds i8, i8* %44, i64 1
%46 = call i64 @ft_atoi(i8* %45)
%47 = sitofp i64 %46 to double
%48 = load i8*, i8** %2
%49 = load i32, i32* %4
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %48, i64 %50
%52 = getelementptr inbounds i8, i8* %51, i64 1
%53 = call i32 @ft_strlen(i8* %52)
%54 = mul nsw i32 %53, 10
%55 = sitofp i32 %54 to double
%56 = fdiv double %47, %55
%57 = load double, double* %3
%58 = fsub double %57, %56
store double %58, double* %3
br label %59
59: ; preds = %40, %21
br label %60
60: ; preds = %59, %1
%61 = load double, double* %3
ret double %61
}

LLVM IR (-O2):
define double @ft_atof(i8* %0) {
%2 = tail call i64 @ft_atoi(i8* %0)
%3 = sitofp i64 %2 to double
%4 = tail call i32 @ft_len_untill(i8* %0, i8 signext 46)
%5 = icmp eq i32 %4, 0
br i1 %5, label %33, label %6
6: ; preds = %1
%7 = icmp sgt i64 %2, -1
br i1 %7, label %8, label %22
8: ; preds = %6
%9 = load i8, i8* %0
%10 = icmp eq i8 %9, 45
br i1 %10, label %22, label %11
11: ; preds = %8
%12 = sext i32 %4 to i64
%13 = getelementptr inbounds i8, i8* %0, i64 %12
%14 = getelementptr inbounds i8, i8* %13, i64 1
%15 = tail call i64 @ft_atoi(i8* %14)
%16 = sitofp i64 %15 to double
%17 = tail call i32 @ft_strlen(i8* %14)
%18 = mul nsw i32 %17, 10
%19 = sitofp i32 %18 to double
%20 = fdiv double %16, %19
%21 = fadd double %20, %3
br label %33
22: ; preds = %8, %6
%23 = sext i32 %4 to i64
%24 = getelementptr inbounds i8, i8* %0, i64 %23
%25 = getelementptr inbounds i8, i8* %24, i64 1
%26 = tail call i64 @ft_atoi(i8* %25)
%27 = sitofp i64 %26 to double
%28 = tail call i32 @ft_strlen(i8* %25)
%29 = mul nsw i32 %28, 10
%30 = sitofp i32 %29 to double
%31 = fdiv double %27, %30
%32 = fsub double %3, %31
br label %33
33: ; preds = %11, %22, %1
%34 = phi double [ %21, %11 ], [ %32, %22 ], [ %3, %1 ]
ret double %34
}