#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__ llegeixx(double *);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char *argv[]) {
  double num;
  double suma = 0.0;
  while (llegeixx(&num) == 0) {
    suma += num;
  }
  printf("%lf\n", 1 + 2 * suma);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
lea    -0x18(%rbp),%rdi
call   1040 <llegeixx@plt>
cmp    $0x0,%rax
jne    1165 <main+0x45>
movsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    113e <main+0x1e>
movsd  -0x20(%rbp),%xmm0
addsd  %xmm0,%xmm0
movsd  0xe8a(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
lea    0xe83(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    %rsp,%rdi
call   1040 <llegeixx@plt>
xorpd  %xmm0,%xmm0
test   %rax,%rax
jne    115e <main+0x3e>
xorpd  %xmm0,%xmm0
mov    %rsp,%rbx
nopl   (%rax)
addsd  (%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %rbx,%rdi
call   1040 <llegeixx@plt>
movsd  0x8(%rsp),%xmm0
test   %rax,%rax
je     1140 <main+0x20>
addsd  %xmm0,%xmm0
addsd  0xe96(%rip),%xmm0
cvttsd2si %xmm0,%esi
lea    0xe93(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%lf\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store double 0.000000e+00, double* %7
br label %8
8: ; preds = %11, %2
%9 = call i64 @llegeixx(double* %6)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %8
%12 = load double, double* %6
%13 = load double, double* %7
%14 = fadd double %13, %12
store double %14, double* %7
br label %8
15: ; preds = %8
%16 = load double, double* %7
%17 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %16, double 1.000000e+00)
%18 = fptosi double %17 to i32
%19 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %18)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%lf\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca double
%4 = bitcast double* %3 to i8*
%5 = call i64 @llegeixx(double* %3)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %13
7: ; preds = %2, %7
%8 = phi double [ %10, %7 ], [ 0.000000e+00, %2 ]
%9 = load double, double* %3
%10 = fadd double %8, %9
%11 = call i64 @llegeixx(double* %3)
%12 = icmp eq i64 %11, 0
br i1 %12, label %7, label %13
13: ; preds = %7, %2
%14 = phi double [ 0.000000e+00, %2 ], [ %10, %7 ]
%15 = call double @llvm.fmuladd.f64(double %14, double 2.000000e+00, double 1.000000e+00)
%16 = fptosi double %15 to i32
%17 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %16)
ret i32 0
}