#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*/ getLine(char *, int);
int /*<<< orphan*/ printf(char *, double);
scalar_t__ stringToDouble(char *);
int main() {
  char input[10];
  int i;
  double sum = 0.0;
  for (i = 1; i <= 4; i++) {
    printf("Enter number #%d: ", i);
    getLine(input, 10);
    sum += stringToDouble(input);
  }
  printf("The sum of the 4 values is %lf\n", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jg     119d <main+0x6d>
cvtsi2sdl -0x14(%rbp),%xmm0
lea    0xe9c(%rip),%rdi
call   1040 <printf@plt>
lea    -0xe(%rbp),%rdi
mov    $0xa,%esi
call   1050 <getLine@plt>
lea    -0xe(%rbp),%rdi
call   1030 <stringToDouble@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114e <main+0x1e>
movsd  -0x20(%rbp),%xmm0
lea    0xe6a(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xee2(%rip),%r14
movsd  0xeba(%rip),%xmm0
mov    %r14,%rdi
call   1040 <printf@plt>
lea    0xe(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xa,%esi
call   1050 <getLine@plt>
mov    %rbx,%rdi
call   1030 <stringToDouble@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  %xmm0,(%rsp)
movsd  0xe8b(%rip),%xmm0
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1050 <getLine@plt>
mov    %rbx,%rdi
call   1030 <stringToDouble@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0xe5c(%rip),%xmm0
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1050 <getLine@plt>
mov    %rbx,%rdi
call   1030 <stringToDouble@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0xe2d(%rip),%xmm0
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1050 <getLine@plt>
mov    %rbx,%rdi
call   1030 <stringToDouble@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
lea    0xe17(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Enter number #%d: \00"
@.str.1 = [32 x i8] c"The sum of the 4 values is %lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i8]
%3 = alloca i32
%4 = alloca double
store i32 0, i32* %1
store double 0.000000e+00, double* %4
store i32 1, i32* %3
br label %5
5: ; preds = %19, %0
%6 = load i32, i32* %3
%7 = icmp sle i32 %6, 4
br i1 %7, label %8, label %22
8: ; preds = %5
%9 = load i32, i32* %3
%10 = sitofp i32 %9 to double
%11 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), double %10)
%12 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%13 = call i32 @getLine(i8* %12, i32 10)
%14 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%15 = call i64 @stringToDouble(i8* %14)
%16 = sitofp i64 %15 to double
%17 = load double, double* %4
%18 = fadd double %17, %16
store double %18, double* %4
br label %19
19: ; preds = %8
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
store i32 %21, i32* %3
br label %5
22: ; preds = %5
%23 = load double, double* %4
%24 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), double %23)
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"Enter number #%d: \00"
@.str.1 = [32 x i8] c"The sum of the 4 values is %lf\0A\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%3 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), double 1.000000e+00)
%4 = call i32 @getLine(i8* %2, i32 10)
%5 = call i64 @stringToDouble(i8* %2)
%6 = sitofp i64 %5 to double
%7 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), double 2.000000e+00)
%8 = call i32 @getLine(i8* %2, i32 10)
%9 = call i64 @stringToDouble(i8* %2)
%10 = sitofp i64 %9 to double
%11 = fadd double %6, %10
%12 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), double 3.000000e+00)
%13 = call i32 @getLine(i8* %2, i32 10)
%14 = call i64 @stringToDouble(i8* %2)
%15 = sitofp i64 %14 to double
%16 = fadd double %11, %15
%17 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), double 4.000000e+00)
%18 = call i32 @getLine(i8* %2, i32 10)
%19 = call i64 @stringToDouble(i8* %2)
%20 = sitofp i64 %19 to double
%21 = fadd double %16, %20
%22 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), double %21)
ret i32 0
}