#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ *Fopen(char *, char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, double);
int fscanf(int /*<<< orphan*/ *, char *, double *);
int /*<<< orphan*/ stdout;
double SumFile(char *f) {
  FILE *F = Fopen(f, "r");
  double sum = 0, v = 0;
  while (fscanf(F, "%lf", &v) == 1)
    sum += v;
  fprintf(stdout, "%lf\n", sum);
  if (F)
    fclose(F);
  return 0;
}


x86 assembly (clang, -O0):
<SumFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea9(%rip),%rsi
call   1060 <Fopen@plt>
mov    %rax,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe87(%rip),%rsi
lea    -0x20(%rbp),%rdx
call   1040 <fscanf@plt>
cmp    $0x1,%eax
jne    11a1 <SumFile+0x61>
movsd  -0x20(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    1170 <SumFile+0x30>
mov    0x2e38(%rip),%rax
mov    (%rax),%edi
movsd  -0x18(%rbp),%xmm0
lea    0xe50(%rip),%rsi
call   1050 <fprintf@plt>
cmpq   $0x0,-0x10(%rbp)
je     11cf <SumFile+0x8f>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
xorps  %xmm0,%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SumFile>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xeb0(%rip),%rsi
call   1060 <Fopen@plt>
mov    %rax,%rbx
movq   $0x0,(%rsp)
lea    0xe9b(%rip),%rsi
mov    %rsp,%rdx
mov    %rax,%rdi
call   1040 <fscanf@plt>
xorpd  %xmm0,%xmm0
cmp    $0x1,%eax
jne    11b4 <SumFile+0x74>
xorpd  %xmm0,%xmm0
lea    0xe7c(%rip),%r14
mov    %rsp,%r15
nopl   0x0(%rax)
addsd  (%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1040 <fscanf@plt>
movsd  0x8(%rsp),%xmm0
cmp    $0x1,%eax
je     1190 <SumFile+0x50>
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
lea    0xe42(%rip),%rsi
call   1050 <fprintf@plt>
test   %rbx,%rbx
je     11d6 <SumFile+0x96>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xorpd  %xmm0,%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [4 x i8] c"%lf\00"
@stdout = global i32 0
@.str.2 = [5 x i8] c"%lf\0A\00"
define double @SumFile(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca double
%5 = alloca double
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i32* @Fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %7, i32** %3
store double 0.000000e+00, double* %4
store double 0.000000e+00, double* %5
br label %8
8: ; preds = %12, %1
%9 = load i32*, i32** %3
%10 = call i32 @fscanf(i32* %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %5)
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %16
12: ; preds = %8
%13 = load double, double* %5
%14 = load double, double* %4
%15 = fadd double %14, %13
store double %15, double* %4
br label %8
16: ; preds = %8
%17 = load i32, i32* @stdout
%18 = load double, double* %4
%19 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %18)
%20 = load i32*, i32** %3
%21 = icmp ne i32* %20, null
br i1 %21, label %22, label %25
22: ; preds = %16
%23 = load i32*, i32** %3
%24 = call i32 @fclose(i32* %23)
br label %25
25: ; preds = %22, %16
ret double 0.000000e+00
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [4 x i8] c"%lf\00"
@stdout = global i32 0
@.str.2 = [5 x i8] c"%lf\0A\00"
define double @SumFile(i8* %0) {
%2 = alloca double
%3 = tail call i32* @Fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = bitcast double* %2 to i8*
store double 0.000000e+00, double* %2
%5 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %2)
%6 = icmp eq i32 %5, 1
br i1 %6, label %7, label %13
7: ; preds = %1, %7
%8 = phi double [ %10, %7 ], [ 0.000000e+00, %1 ]
%9 = load double, double* %2
%10 = fadd double %8, %9
%11 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %2)
%12 = icmp eq i32 %11, 1
br i1 %12, label %7, label %13
13: ; preds = %7, %1
%14 = phi double [ 0.000000e+00, %1 ], [ %10, %7 ]
%15 = load i32, i32* @stdout
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %14)
%17 = icmp eq i32* %3, null
br i1 %17, label %20, label %18
18: ; preds = %13
%19 = call i32 @fclose(i32* %3)
br label %20
20: ; preds = %18, %13
ret double 0.000000e+00
}