#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 EOF;
char *atof(char *);
int getchar();
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  int ret = 0;
  char s[100 + 1];
  int c = 0, i = 0;
  printf("\nGive me a string to convert to float! Ex: -123.43, -234.34e-6;\n");
  while ((i < 100) && (c = getchar()) != EOF)
    s[i++] = c;
  s[i + 1] = '\0';
  printf("\n=>\tThe string i'll convert is %s", s);
  printf("\n=>\tThe converted number is %lf", atof(s));
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0x74(%rbp)
movl   $0x0,-0x78(%rbp)
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
cmpl   $0x64,-0x78(%rbp)
mov    %al,-0x79(%rbp)
jge    118d <main+0x5d>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x74(%rbp)
mov    0x2e63(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
mov    %al,-0x79(%rbp)
mov    -0x79(%rbp),%al
test   $0x1,%al
jne    119d <main+0x6d>
jmp    11b8 <main+0x88>
mov    -0x74(%rbp),%eax
mov    %al,%cl
mov    -0x78(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x78(%rbp)
cltq
mov    %cl,-0x70(%rbp,%rax,1)
jmp    1165 <main+0x35>
mov    -0x78(%rbp),%eax
add    $0x1,%eax
cltq
movb   $0x0,-0x70(%rbp,%rax,1)
lea    -0x70(%rbp),%rsi
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x70(%rbp),%rdi
call   1030 <atof@plt>
mov    %rax,%rsi
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x68,%rsp
lea    0xef4(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e8e(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax)
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    (%r14),%eax
je     117e <main+0x3e>
mov    %al,(%rsp,%rbx,1)
add    $0x1,%rbx
cmp    $0x64,%rbx
jne    1160 <main+0x20>
mov    $0x64,%ebx
add    $0x1,%ebx
movb   $0x0,(%rsp,%rbx,1)
lea    0xe74(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1040 <atof@plt>
lea    0xe7a(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [65 x i8] c"\0AGive me a string to convert to float! Ex: -123.43, -234.34e-6;\0A\00"
@EOF = global i32 0
@.str.1 = [34 x i8] c"\0A=>\09The string i'll convert is %s\00"
@.str.2 = [32 x i8] c"\0A=>\09The converted number is %lf\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [101 x i8]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %4
store i32 0, i32* %5
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %16, %0
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 100
br i1 %9, label %10, label %14
10: ; preds = %7
%11 = call i32 (...) @getchar()
store i32 %11, i32* %4
%12 = load i32, i32* @EOF
%13 = icmp ne i32 %11, %12
br label %14
14: ; preds = %10, %7
%15 = phi i1 [ false, %7 ], [ %13, %10 ]
br i1 %15, label %16, label %23
16: ; preds = %14
%17 = load i32, i32* %4
%18 = trunc i32 %17 to i8
%19 = load i32, i32* %5
%20 = add nsw i32 %19, 1
store i32 %20, i32* %5
%21 = sext i32 %19 to i64
%22 = getelementptr inbounds [101 x i8], [101 x i8]* %3, i64 0, i64 %21
store i8 %18, i8* %22
br label %7
23: ; preds = %14
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 1
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [101 x i8], [101 x i8]* %3, i64 0, i64 %26
store i8 0, i8* %27
%28 = getelementptr inbounds [101 x i8], [101 x i8]* %3, i64 0, i64 0
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* %28)
%30 = getelementptr inbounds [101 x i8], [101 x i8]* %3, i64 0, i64 0
%31 = call i8* @atof(i8* %30)
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* %31)
%33 = load i32, i32* %2
ret i32 %33
}

LLVM IR (-O2):
@EOF = global i32 0
@.str.1 = [34 x i8] c"\0A=>\09The string i'll convert is %s\00"
@.str.2 = [32 x i8] c"\0A=>\09The converted number is %lf\00"
@str = [64 x i8] c"\0AGive me a string to convert to float! Ex: -123.43, -234.34e-6;\00"
define i32 @main() {
%1 = alloca [101 x i8]
%2 = getelementptr inbounds [101 x i8], [101 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @str, i64 0, i64 0))
br label %4
4: ; preds = %0, %9
%5 = phi i64 [ 0, %0 ], [ %11, %9 ]
%6 = tail call i32 (...) @getchar()
%7 = load i32, i32* @EOF
%8 = icmp eq i32 %6, %7
br i1 %8, label %14, label %9
9: ; preds = %4
%10 = trunc i32 %6 to i8
%11 = add nuw nsw i64 %5, 1
%12 = getelementptr inbounds [101 x i8], [101 x i8]* %1, i64 0, i64 %5
store i8 %10, i8* %12
%13 = icmp eq i64 %11, 100
br i1 %13, label %14, label %4
14: ; preds = %9, %4
%15 = phi i64 [ 100, %9 ], [ %5, %4 ]
%16 = add nuw i64 %15, 1
%17 = and i64 %16, 4294967295
%18 = getelementptr inbounds [101 x i8], [101 x i8]* %1, i64 0, i64 %17
store i8 0, i8* %18
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%20 = call i8* @atof(i8* %2)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* %20)
ret i32 0
}