#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 *, double);
void main() {
  char line[1000];
  int i = 0;
  int getline_my(char line[], int max);
  double digit = 0.0;
  double sum = 0.0;
  double atof(char[]);
  sum = 0.0;
  while (getline_my(line, 1000) > 0)
    printf("\t%g\n", sum += atof(line));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
movl   $0x0,-0x3f4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x400(%rbp)
ff
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x408(%rbp)
ff
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x408(%rbp)
ff
lea    -0x3f0(%rbp),%rdi
mov    $0x3e8,%esi
call   1050 <getline_my@plt>
cmp    $0x0,%eax
jle    11ad <main+0x7d>
lea    -0x3f0(%rbp),%rdi
call   1030 <atof@plt>
addsd  -0x408(%rbp),%xmm0
ff
movsd  %xmm0,-0x408(%rbp)
ff
lea    0xe5d(%rip),%rdi
call   1040 <printf@plt>
jmp    1166 <main+0x36>
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x3f8,%rsp
lea    0x10(%rsp),%rdi
mov    $0x3e8,%esi
call   1050 <getline_my@plt>
test   %eax,%eax
jle    11a5 <main+0x75>
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
lea    0x10(%rsp),%rbx
lea    0xe9d(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
call   1030 <atof@plt>
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
mov    %r14,%rdi
movsd  %xmm1,0x8(%rsp)
movapd %xmm1,%xmm0
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x3e8,%esi
call   1050 <getline_my@plt>
test   %eax,%eax
jg     1170 <main+0x40>
add    $0x3f8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [5 x i8] c"\09%g\0A\00"
define void @main() {
%1 = alloca [1000 x i8]
%2 = alloca i32
%3 = alloca double
%4 = alloca double
store i32 0, i32* %2
store double 0.000000e+00, double* %3
store double 0.000000e+00, double* %4
store double 0.000000e+00, double* %4
br label %5
5: ; preds = %9, %0
%6 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%7 = call i32 @getline_my(i8* %6, i32 1000)
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %15
9: ; preds = %5
%10 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%11 = call double @atof(i8* %10)
%12 = load double, double* %4
%13 = fadd double %12, %11
store double %13, double* %4
%14 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), double %13)
br label %5
15: ; preds = %5
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"\09%g\0A\00"
define void @main() {
%1 = alloca [1000 x i8]
%2 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%3 = call i32 @getline_my(i8* %2, i32 1000)
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %12
5: ; preds = %0, %5
%6 = phi double [ %8, %5 ], [ 0.000000e+00, %0 ]
%7 = call double @atof(i8* %2)
%8 = fadd double %6, %7
%9 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), double %8)
%10 = call i32 @getline_my(i8* %2, i32 1000)
%11 = icmp sgt i32 %10, 0
br i1 %11, label %5, label %12
12: ; preds = %5, %0
ret void
}