#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 */
int /*<<< orphan*/ printf(char *, char *, float);
float simple_atof(char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main() {
  float val;
  char str[20];
  strcpy(str, "98993489");
  val = simple_atof(str);
  printf("String value = %s, Float value = %f\n", str, val);
  strcpy(str, "3.1459e-4");
  val = simple_atof(str);
  printf("String value = %s, Float value = %12.10f\n", str, val);
  strcpy(str, "3.1459E-4");
  val = simple_atof(str);
  printf("String value = %s, Float value = %12.10f\n", str, val);
  strcpy(str, " \t\n3.1459");
  val = simple_atof(str);
  printf("String value = %s, Float value = %f\n", str, val);
  strcpy(str, "3ciao.34");
  val = simple_atof(str);
  printf("String value = %s, Float value = %f\n", str, val);
  strcpy(str, "3.1459eciao");
  val = simple_atof(str);
  printf("String value = %s, Float value = %f\n", str, val);
  strcpy(str, " \t");
  val = simple_atof(str);
  printf("String value = %s, Float value = %f\n", str, val);
  strcpy(str, "sbagliato");
  val = simple_atof(str);
  printf("String value = %s, Float value = %f\n", str, val);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x20(%rbp),%rdi
lea    0xeb6(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x20(%rbp),%rdi
call   1050 <simple_atof@plt>
movss  %xmm0,-0x8(%rbp)
lea    -0x20(%rbp),%rsi
movss  -0x8(%rbp),%xmm0
lea    0xe9c(%rip),%rdi
call   1040 <printf@plt>
lea    -0x20(%rbp),%rdi
lea    0xeb1(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x20(%rbp),%rdi
call   1050 <simple_atof@plt>
movss  %xmm0,-0x8(%rbp)
lea    -0x20(%rbp),%rsi
movss  -0x8(%rbp),%xmm0
lea    0xe98(%rip),%rdi
call   1040 <printf@plt>
lea    -0x20(%rbp),%rdi
lea    0xeb2(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x20(%rbp),%rdi
call   1050 <simple_atof@plt>
movss  %xmm0,-0x8(%rbp)
lea    -0x20(%rbp),%rsi
movss  -0x8(%rbp),%xmm0
lea    0xe65(%rip),%rdi
call   1040 <printf@plt>
lea    -0x20(%rbp),%rdi
lea    0xe89(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x20(%rbp),%rdi
call   1050 <simple_atof@plt>
movss  %xmm0,-0x8(%rbp)
lea    -0x20(%rbp),%rsi
movss  -0x8(%rbp),%xmm0
lea    0xe03(%rip),%rdi
call   1040 <printf@plt>
lea    -0x20(%rbp),%rdi
lea    0xe60(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x20(%rbp),%rdi
call   1050 <simple_atof@plt>
movss  %xmm0,-0x8(%rbp)
lea    -0x20(%rbp),%rsi
movss  -0x8(%rbp),%xmm0
lea    0xdd0(%rip),%rdi
call   1040 <printf@plt>
lea    -0x20(%rbp),%rdi
lea    0xe36(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x20(%rbp),%rdi
call   1050 <simple_atof@plt>
movss  %xmm0,-0x8(%rbp)
lea    -0x20(%rbp),%rsi
movss  -0x8(%rbp),%xmm0
lea    0xd9d(%rip),%rdi
call   1040 <printf@plt>
lea    -0x20(%rbp),%rdi
lea    0xe0f(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x20(%rbp),%rdi
call   1050 <simple_atof@plt>
movss  %xmm0,-0x8(%rbp)
lea    -0x20(%rbp),%rsi
movss  -0x8(%rbp),%xmm0
lea    0xd6a(%rip),%rdi
call   1040 <printf@plt>
lea    -0x20(%rbp),%rdi
lea    0xddf(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x20(%rbp),%rdi
call   1050 <simple_atof@plt>
movss  %xmm0,-0x8(%rbp)
lea    -0x20(%rbp),%rsi
movss  -0x8(%rbp),%xmm0
lea    0xd37(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
lea    0xec0(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1050 <simple_atof@plt>
lea    0xeaf(%rip),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
lea    0xec2(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1050 <simple_atof@plt>
lea    0xeb5(%rip),%r15
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
lea    0xecd(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1050 <simple_atof@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
lea    0xeb5(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1050 <simple_atof@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
lea    0xe9d(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1050 <simple_atof@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
lea    0xe84(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1050 <simple_atof@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
lea    0xe6e(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1050 <simple_atof@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
lea    0xe4f(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1050 <simple_atof@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [9 x i8] c"98993489\00"
@.str.1 = [37 x i8] c"String value = %s, Float value = %f\0A\00"
@.str.2 = [10 x i8] c"3.1459e-4\00"
@.str.3 = [42 x i8] c"String value = %s, Float value = %12.10f\0A\00"
@.str.4 = [10 x i8] c"3.1459E-4\00"
@.str.5 = [10 x i8] c" \09\0A3.1459\00"
@.str.6 = [9 x i8] c"3ciao.34\00"
@.str.7 = [12 x i8] c"3.1459eciao\00"
@.str.8 = [3 x i8] c" \09\00"
@.str.9 = [10 x i8] c"sbagliato\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca [20 x i8]
store i32 0, i32* %1
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%5 = call i32 @strcpy(i8* %4, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%7 = call float @simple_atof(i8* %6)
store float %7, float* %2
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%9 = load float, float* %2
%10 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %8, float %9)
%11 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%12 = call i32 @strcpy(i8* %11, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%13 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%14 = call float @simple_atof(i8* %13)
store float %14, float* %2
%15 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%16 = load float, float* %2
%17 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), i8* %15, float %16)
%18 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%19 = call i32 @strcpy(i8* %18, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%20 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%21 = call float @simple_atof(i8* %20)
store float %21, float* %2
%22 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%23 = load float, float* %2
%24 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), i8* %22, float %23)
%25 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%26 = call i32 @strcpy(i8* %25, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%27 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%28 = call float @simple_atof(i8* %27)
store float %28, float* %2
%29 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%30 = load float, float* %2
%31 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %29, float %30)
%32 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%33 = call i32 @strcpy(i8* %32, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%34 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%35 = call float @simple_atof(i8* %34)
store float %35, float* %2
%36 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%37 = load float, float* %2
%38 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %36, float %37)
%39 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%40 = call i32 @strcpy(i8* %39, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
%41 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%42 = call float @simple_atof(i8* %41)
store float %42, float* %2
%43 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%44 = load float, float* %2
%45 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %43, float %44)
%46 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%47 = call i32 @strcpy(i8* %46, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%48 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%49 = call float @simple_atof(i8* %48)
store float %49, float* %2
%50 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%51 = load float, float* %2
%52 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %50, float %51)
%53 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%54 = call i32 @strcpy(i8* %53, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0))
%55 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%56 = call float @simple_atof(i8* %55)
store float %56, float* %2
%57 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%58 = load float, float* %2
%59 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %57, float %58)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"98993489\00"
@.str.1 = [37 x i8] c"String value = %s, Float value = %f\0A\00"
@.str.2 = [10 x i8] c"3.1459e-4\00"
@.str.3 = [42 x i8] c"String value = %s, Float value = %12.10f\0A\00"
@.str.4 = [10 x i8] c"3.1459E-4\00"
@.str.5 = [10 x i8] c" \09\0A3.1459\00"
@.str.6 = [9 x i8] c"3ciao.34\00"
@.str.7 = [12 x i8] c"3.1459eciao\00"
@.str.8 = [3 x i8] c" \09\00"
@.str.9 = [10 x i8] c"sbagliato\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%3 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%4 = call float @simple_atof(i8* %2)
%5 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %2, float %4)
%6 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%7 = call float @simple_atof(i8* %2)
%8 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), i8* %2, float %7)
%9 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%10 = call float @simple_atof(i8* %2)
%11 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), i8* %2, float %10)
%12 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%13 = call float @simple_atof(i8* %2)
%14 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %2, float %13)
%15 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%16 = call float @simple_atof(i8* %2)
%17 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %2, float %16)
%18 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
%19 = call float @simple_atof(i8* %2)
%20 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %2, float %19)
%21 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%22 = call float @simple_atof(i8* %2)
%23 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %2, float %22)
%24 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0))
%25 = call float @simple_atof(i8* %2)
%26 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %2, float %25)
ret i32 0
}