#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;
double atof(char *);
int getchar();
int /*<<< orphan*/ printf(char *, double);
void main() {
  char s[50];
  int c, i;
  double value;
  i = 0;
  while ((c = getchar()) != EOF && c != '\n')
    s[i++] = c;
  if (c == '\n')
    s[i++] = '\n';
  s[i] = '\0';
  value = atof(s);
  printf("\nValue:%f\n\n", value);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x48(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,%ecx
mov    %ecx,-0x44(%rbp)
xor    %eax,%eax
mov    0x2e94(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0x51(%rbp)
je     1169 <main+0x39>
cmpl   $0xa,-0x44(%rbp)
setne  %al
mov    %al,-0x51(%rbp)
mov    -0x51(%rbp),%al
test   $0x1,%al
jne    1179 <main+0x49>
jmp    1194 <main+0x64>
mov    -0x44(%rbp),%eax
mov    %al,%cl
mov    -0x48(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x48(%rbp)
cltq
mov    %cl,-0x40(%rbp,%rax,1)
jmp    113f <main+0xf>
cmpl   $0xa,-0x44(%rbp)
jne    11b0 <main+0x80>
mov    -0x48(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x48(%rbp)
cltq
movb   $0xa,-0x40(%rbp,%rax,1)
movslq -0x48(%rbp),%rax
movb   $0x0,-0x40(%rbp,%rax,1)
lea    -0x40(%rbp),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
lea    0xe2d(%rip),%rdi
call   1040 <printf@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x38,%rsp
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%eax
je     1178 <main+0x48>
mov    0x2e9c(%rip),%r14
cmp    (%r14),%eax
je     1178 <main+0x48>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %al,(%rsp,%rbx,1)
add    $0x1,%rbx
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%eax
je     1178 <main+0x48>
cmp    (%r14),%eax
jne    1160 <main+0x30>
cmp    $0xa,%eax
jne    1186 <main+0x56>
mov    %ebx,%eax
add    $0x1,%ebx
movb   $0xa,(%rsp,%rax,1)
movslq %ebx,%rax
movb   $0x0,(%rsp,%rax,1)
mov    %rsp,%rdi
call   1030 <atof@plt>
lea    0xe64(%rip),%rdi
add    $0x38,%rsp
pop    %rbx
pop    %r14
jmp    1040 <printf@plt>

LLVM IR (-O0):
@EOF = global i32 0
@.str = [12 x i8] c"\0AValue:%f\0A\0A\00"
define void @main() {
%1 = alloca [50 x i8]
%2 = alloca i32
%3 = alloca i32
%4 = alloca double
store i32 0, i32* %3
br label %5
5: ; preds = %14, %0
%6 = call i32 (...) @getchar()
store i32 %6, i32* %2
%7 = load i32, i32* @EOF
%8 = icmp ne i32 %6, %7
br i1 %8, label %9, label %12
9: ; preds = %5
%10 = load i32, i32* %2
%11 = icmp ne i32 %10, 10
br label %12
12: ; preds = %9, %5
%13 = phi i1 [ false, %5 ], [ %11, %9 ]
br i1 %13, label %14, label %21
14: ; preds = %12
%15 = load i32, i32* %2
%16 = trunc i32 %15 to i8
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 1
store i32 %18, i32* %3
%19 = sext i32 %17 to i64
%20 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %19
store i8 %16, i8* %20
br label %5
21: ; preds = %12
%22 = load i32, i32* %2
%23 = icmp eq i32 %22, 10
br i1 %23, label %24, label %29
24: ; preds = %21
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
store i32 %26, i32* %3
%27 = sext i32 %25 to i64
%28 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %27
store i8 10, i8* %28
br label %29
29: ; preds = %24, %21
%30 = load i32, i32* %3
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %31
store i8 0, i8* %32
%33 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%34 = call double @atof(i8* %33)
store double %34, double* %4
%35 = load double, double* %4
%36 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), double %35)
ret void
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [12 x i8] c"\0AValue:%f\0A\0A\00"
define void @main() {
%1 = alloca [50 x i8]
%2 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (...) @getchar()
%4 = load i32, i32* @EOF
%5 = icmp ne i32 %3, %4
%6 = icmp ne i32 %3, 10
%7 = and i1 %6, %5
br i1 %7, label %8, label %21
8: ; preds = %0, %8
%9 = phi i64 [ %12, %8 ], [ 0, %0 ]
%10 = phi i32 [ %14, %8 ], [ %3, %0 ]
%11 = trunc i32 %10 to i8
%12 = add nuw i64 %9, 1
%13 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %9
store i8 %11, i8* %13
%14 = tail call i32 (...) @getchar()
%15 = load i32, i32* @EOF
%16 = icmp ne i32 %14, %15
%17 = icmp ne i32 %14, 10
%18 = and i1 %17, %16
br i1 %18, label %8, label %19
19: ; preds = %8
%20 = trunc i64 %12 to i32
br label %21
21: ; preds = %19, %0
%22 = phi i32 [ 0, %0 ], [ %20, %19 ]
%23 = phi i32 [ %3, %0 ], [ %14, %19 ]
%24 = icmp eq i32 %23, 10
br i1 %24, label %25, label %29
25: ; preds = %21
%26 = add nuw nsw i32 %22, 1
%27 = zext i32 %22 to i64
%28 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %27
store i8 10, i8* %28
br label %29
29: ; preds = %25, %21
%30 = phi i32 [ %26, %25 ], [ %22, %21 ]
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %31
store i8 0, i8* %32
%33 = call double @atof(i8* %2)
%34 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), double %33)
ret void
}