#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 atof(char *);
double atoll(char *);
int /*<<< orphan*/ printf(char *, ...);
double strtod(char *, char **);
int main() {
  char str[] = "10.1010";
  double d = atof(str);
  printf("%lf\n", d);
  char str2[30] = "20.30300 This is test";
  char *ptr;
  double ret;
  ret = strtod(str2, &ptr);
  printf("%lf\n", ret);
  printf("%s\n", ptr);
  printf("%g\n", atof("  -0.0000000123junk"));
  printf("%g\n", atof("0.012"));
  printf("%g\n", atof("15e16"));
  printf("%g\n", atof("-0x1afp-2"));
  printf("%g\n", atof("inF"));
  printf("%g\n", atof("Nan"));
  printf("%g\n", atof("1.0e+309"));
  printf("%g\n", atof("0.0"));
  printf("%g\n", atof("junk"));
  printf("%lld\n", atoll("junk"));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeaa(%rip),%rax
mov    %rax,-0xc(%rbp)
lea    -0xc(%rbp),%rdi
call   1040 <atof@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
lea    0xe94(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    0xede(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xedb(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xed8(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xed6(%rip),%eax
mov    %eax,-0x28(%rbp)
mov    0xed0(%rip),%ax
mov    %ax,-0x24(%rbp)
lea    -0x40(%rbp),%rdi
lea    -0x48(%rbp),%rsi
call   1030 <strtod@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
lea    0xe3a(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    -0x48(%rbp),%rsi
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe27(%rip),%rdi
call   1040 <atof@plt>
lea    0xe17(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xe21(%rip),%rdi
call   1040 <atof@plt>
lea    0xdfd(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xe0d(%rip),%rdi
call   1040 <atof@plt>
lea    0xde3(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xdf9(%rip),%rdi
call   1040 <atof@plt>
lea    0xdc9(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xde9(%rip),%rdi
call   1040 <atof@plt>
lea    0xdaf(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xdd3(%rip),%rdi
call   1040 <atof@plt>
lea    0xd95(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xdbd(%rip),%rdi
call   1040 <atof@plt>
lea    0xd7b(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xdac(%rip),%rdi
call   1040 <atof@plt>
lea    0xd61(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xd66(%rip),%rdi
call   1040 <atof@plt>
lea    0xd47(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xd4c(%rip),%rdi
call   1060 <atoll@plt>
lea    0xd70(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x38,%rsp
lea    0xea2(%rip),%rdi
call   1050 <atof@plt>
lea    0xe9e(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movups 0xef3(%rip),%xmm0
movups %xmm0,0x1e(%rsp)
movaps 0xed9(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1040 <strtod@plt>
mov    %rbx,%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    0x8(%rsp),%rdi
call   1030 <puts@plt>
lea    0xe5b(%rip),%rdi
call   1050 <atof@plt>
lea    0xe4b(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%al
call   1060 <printf@plt>
lea    0xe52(%rip),%rdi
call   1050 <atof@plt>
mov    %rbx,%rdi
mov    $0x1,%al
call   1060 <printf@plt>
lea    0xe42(%rip),%rdi
call   1050 <atof@plt>
mov    %rbx,%rdi
mov    $0x1,%al
call   1060 <printf@plt>
lea    0xe32(%rip),%rdi
call   1050 <atof@plt>
mov    %rbx,%rdi
mov    $0x1,%al
call   1060 <printf@plt>
lea    0xe26(%rip),%rdi
call   1050 <atof@plt>
mov    %rbx,%rdi
mov    $0x1,%al
call   1060 <printf@plt>
lea    0xe14(%rip),%rdi
call   1050 <atof@plt>
mov    %rbx,%rdi
mov    $0x1,%al
call   1060 <printf@plt>
lea    0xe02(%rip),%rdi
call   1050 <atof@plt>
mov    %rbx,%rdi
mov    $0x1,%al
call   1060 <printf@plt>
lea    0xdf5(%rip),%rdi
call   1050 <atof@plt>
mov    %rbx,%rdi
mov    $0x1,%al
call   1060 <printf@plt>
lea    0xdb3(%rip),%r14
mov    %r14,%rdi
call   1050 <atof@plt>
mov    %rbx,%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    %r14,%rdi
call   1070 <atoll@plt>
lea    0xdc2(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.str = [8 x i8] c"10.1010\00"
@.str = [5 x i8] c"%lf\0A\00"
@__const.main.str2 = [30 x i8] c"20.30300 This is test\00\00\00\00\00\00\00\00\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [4 x i8] c"%g\0A\00"
@.str.3 = [20 x i8] c" -0.0000000123junk\00"
@.str.4 = [6 x i8] c"0.012\00"
@.str.5 = [6 x i8] c"15e16\00"
@.str.6 = [10 x i8] c"-0x1afp-2\00"
@.str.7 = [4 x i8] c"inF\00"
@.str.8 = [4 x i8] c"Nan\00"
@.str.9 = [9 x i8] c"1.0e+309\00"
@.str.10 = [4 x i8] c"0.0\00"
@.str.11 = [5 x i8] c"junk\00"
@.str.12 = [6 x i8] c"%lld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [8 x i8]
%3 = alloca double
%4 = alloca [30 x i8]
%5 = alloca i8*
%6 = alloca double
store i32 0, i32* %1
%7 = bitcast [8 x i8]* %2 to i8*
%8 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%9 = call double @atof(i8* %8)
store double %9, double* %3
%10 = load double, double* %3
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), double %10)
%12 = bitcast [30 x i8]* %4 to i8*
%13 = getelementptr inbounds [30 x i8], [30 x i8]* %4, i64 0, i64 0
%14 = call double @strtod(i8* %13, i8** %5)
store double %14, double* %6
%15 = load double, double* %6
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), double %15)
%17 = load i8*, i8** %5
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = call double @atof(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %19)
%21 = call double @atof(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %21)
%23 = call double @atof(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %23)
%25 = call double @atof(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %25)
%27 = call double @atof(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %27)
%29 = call double @atof(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %29)
%31 = call double @atof(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0))
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %31)
%33 = call double @atof(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0))
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %33)
%35 = call double @atof(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %35)
%37 = call double @atoll(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0), double %37)
ret i32 0
}

LLVM IR (-O2):
@__const.main.str = [8 x i8] c"10.1010\00"
@.str = [5 x i8] c"%lf\0A\00"
@__const.main.str2 = [30 x i8] c"20.30300 This is test\00\00\00\00\00\00\00\00\00"
@.str.2 = [4 x i8] c"%g\0A\00"
@.str.3 = [20 x i8] c" -0.0000000123junk\00"
@.str.4 = [6 x i8] c"0.012\00"
@.str.5 = [6 x i8] c"15e16\00"
@.str.6 = [10 x i8] c"-0x1afp-2\00"
@.str.7 = [4 x i8] c"inF\00"
@.str.8 = [4 x i8] c"Nan\00"
@.str.9 = [9 x i8] c"1.0e+309\00"
@.str.10 = [4 x i8] c"0.0\00"
@.str.11 = [5 x i8] c"junk\00"
@.str.12 = [6 x i8] c"%lld\0A\00"
define i32 @main() {
%1 = alloca [30 x i8]
%2 = alloca i8*
%3 = tail call double @atof(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @__const.main.str, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), double %3)
%5 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 0
%6 = bitcast i8** %2 to i8*
%7 = call double @strtod(i8* %5, i8** %2)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), double %7)
%9 = load i8*, i8** %2
%10 = call i32 @puts(i8* dereferenceable(1) %9)
%11 = call double @atof(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %11)
%13 = call double @atof(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %13)
%15 = call double @atof(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %15)
%17 = call double @atof(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %17)
%19 = call double @atof(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %19)
%21 = call double @atof(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %21)
%23 = call double @atof(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0))
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %23)
%25 = call double @atof(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0))
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %25)
%27 = call double @atof(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %27)
%29 = call double @atoll(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0), double %29)
ret i32 0
}