#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 */
scalar_t__ atof(char *);
scalar_t__ feof(int /*<<< orphan*/);
int fscanf(int /*<<< orphan*/, char *, float *);
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ stdin;
int main(int argc, char *argv[]) {
  double total = 0.0;
  int count;
  if (argc > 1)
    for (count = 1; count < argc; count++)
      total += atof(argv[count]);
  else {
    float tab[1000];
    int i = 0, vals_read;
    while (feof(stdin) == 0) {
      vals_read = fscanf(stdin, "%f\n", &tab[i]);
      total += tab[i];
      i += vals_read;
    }
  }
  printf("%g\n", total);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xfd0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    11b1 <main+0x71>
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11ac <main+0x6c>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <atof@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1172 <main+0x32>
jmp    123d <main+0xfd>
movl   $0x0,-0xfc4(%rbp)
mov    0x2e26(%rip),%rax
mov    (%rax),%edi
call   1060 <feof@plt>
cmp    $0x0,%rax
jne    1238 <main+0xf8>
mov    0x2e0e(%rip),%rax
mov    (%rax),%edi
movslq -0xfc4(%rbp),%rax
lea    -0xfc0(%rbp),%rdx
shl    $0x2,%rax
add    %rax,%rdx
lea    0xe08(%rip),%rsi
call   1050 <fscanf@plt>
mov    %eax,-0xfc8(%rbp)
movslq -0xfc4(%rbp),%rax
movss  -0xfc0(%rbp,%rax,4),%xmm0
ff ff
cvtss2sd %xmm0,%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0xfc8(%rbp),%eax
add    -0xfc4(%rbp),%eax
mov    %eax,-0xfc4(%rbp)
jmp    11bb <main+0x7b>
jmp    123d <main+0xfd>
movsd  -0x18(%rbp),%xmm0
lea    0xdbb(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xfd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0xfb0,%rsp
cmp    $0x2,%edi
jl     1198 <main+0x58>
mov    %rsi,%r14
mov    %edi,%r15d
xorps  %xmm0,%xmm0
mov    $0x1,%ebx
nop
movsd  %xmm0,0x8(%rsp)
mov    (%r14,%rbx,8),%rdi
call   1030 <atof@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1160 <main+0x20>
jmp    1215 <main+0xd5>
mov    0x2e49(%rip),%r15
mov    (%r15),%edi
call   1060 <feof@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
test   %rax,%rax
jne    120f <main+0xcf>
xor    %ebx,%ebx
xorps  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
lea    0xe39(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    (%r15),%edi
movslq %ebx,%rbx
lea    (%rsp,%rbx,4),%rdx
add    $0x10,%rdx
mov    %r14,%rsi
call   1050 <fscanf@plt>
movss  0x10(%rsp,%rbx,4),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
add    %eax,%ebx
mov    (%r15),%edi
call   1060 <feof@plt>
test   %rax,%rax
je     11d0 <main+0x90>
movsd  0x8(%rsp),%xmm0
lea    0xde8(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xfb0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [4 x i8] c"%f\0A\00"
@.str.1 = [4 x i8] c"%g\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca i32
%8 = alloca [1000 x float]
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store double 0.000000e+00, double* %6
%11 = load i32, i32* %4
%12 = icmp sgt i32 %11, 1
br i1 %12, label %13, label %32
13: ; preds = %2
store i32 1, i32* %7
br label %14
14: ; preds = %28, %13
%15 = load i32, i32* %7
%16 = load i32, i32* %4
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %31
18: ; preds = %14
%19 = load i8**, i8*** %5
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %19, i64 %21
%23 = load i8*, i8** %22
%24 = call i64 @atof(i8* %23)
%25 = sitofp i64 %24 to double
%26 = load double, double* %6
%27 = fadd double %26, %25
store double %27, double* %6
br label %28
28: ; preds = %18
%29 = load i32, i32* %7
%30 = add nsw i32 %29, 1
store i32 %30, i32* %7
br label %14
31: ; preds = %14
br label %54
32: ; preds = %2
store i32 0, i32* %9
br label %33
33: ; preds = %37, %32
%34 = load i32, i32* @stdin
%35 = call i64 @feof(i32 %34)
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %53
37: ; preds = %33
%38 = load i32, i32* @stdin
%39 = load i32, i32* %9
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [1000 x float], [1000 x float]* %8, i64 0, i64 %40
%42 = call i32 @fscanf(i32 %38, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), float* %41)
store i32 %42, i32* %10
%43 = load i32, i32* %9
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [1000 x float], [1000 x float]* %8, i64 0, i64 %44
%46 = load float, float* %45
%47 = fpext float %46 to double
%48 = load double, double* %6
%49 = fadd double %48, %47
store double %49, double* %6
%50 = load i32, i32* %10
%51 = load i32, i32* %9
%52 = add nsw i32 %51, %50
store i32 %52, i32* %9
br label %33
53: ; preds = %33
br label %54
54: ; preds = %53, %31
%55 = load double, double* %6
%56 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %55)
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [4 x i8] c"%f\0A\00"
@.str.1 = [4 x i8] c"%g\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1000 x float]
%4 = icmp sgt i32 %0, 1
br i1 %4, label %5, label %17
5: ; preds = %2
%6 = zext i32 %0 to i64
br label %7
7: ; preds = %5, %7
%8 = phi i64 [ 1, %5 ], [ %15, %7 ]
%9 = phi double [ 0.000000e+00, %5 ], [ %14, %7 ]
%10 = getelementptr inbounds i8*, i8** %1, i64 %8
%11 = load i8*, i8** %10
%12 = tail call i64 @atof(i8* %11)
%13 = sitofp i64 %12 to double
%14 = fadd double %9, %13
%15 = add nuw nsw i64 %8, 1
%16 = icmp eq i64 %15, %6
br i1 %16, label %38, label %7
17: ; preds = %2
%18 = bitcast [1000 x float]* %3 to i8*
%19 = load i32, i32* @stdin
%20 = call i64 @feof(i32 %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %36
22: ; preds = %17, %22
%23 = phi double [ %31, %22 ], [ 0.000000e+00, %17 ]
%24 = phi i32 [ %32, %22 ], [ 0, %17 ]
%25 = load i32, i32* @stdin
%26 = sext i32 %24 to i64
%27 = getelementptr inbounds [1000 x float], [1000 x float]* %3, i64 0, i64 %26
%28 = call i32 @fscanf(i32 %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), float* %27)
%29 = load float, float* %27
%30 = fpext float %29 to double
%31 = fadd double %23, %30
%32 = add nsw i32 %28, %24
%33 = load i32, i32* @stdin
%34 = call i64 @feof(i32 %33)
%35 = icmp eq i64 %34, 0
br i1 %35, label %22, label %36
36: ; preds = %22, %17
%37 = phi double [ 0.000000e+00, %17 ], [ %31, %22 ]
br label %38
38: ; preds = %7, %36
%39 = phi double [ %37, %36 ], [ %14, %7 ]
%40 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %39)
ret i32 0
}