#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 *, ...);
int /*<<< orphan*/ scanf(char *, double *);
int main(void) {
  double number, sum = 0.0;
  printf("enter the numbers: ");
  scanf("%lf", &number);
  while (number != 0.0) {
    sum += number;
    scanf("%lf", &number);
  }
  printf("sum 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,-0x18(%rbp)
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec8(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1172 <main+0x52>
jp     1172 <main+0x52>
jmp    1196 <main+0x76>
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
lea    0xe8c(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
jmp    1155 <main+0x35>
movsd  -0x18(%rbp),%xmm0
lea    0xe76(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xeda(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee0(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1040 <scanf@plt>
movsd  0x8(%rsp),%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jne    1158 <main+0x38>
jnp    119d <main+0x7d>
lea    0xebd(%rip),%r14
lea    0x8(%rsp),%rbx
xorpd  %xmm0,%xmm0
nopl   0x0(%rax,%rax,1)
addsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rsp)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
ucomisd 0xe67(%rip),%xmm1
jne    1170 <main+0x50>
jp     1170 <main+0x50>
lea    0xe7c(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [20 x i8] c"enter the numbers: \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [12 x i8] c"sum is %lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
store i32 0, i32* %1
store double 0.000000e+00, double* %3
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %2)
br label %6
6: ; preds = %9, %0
%7 = load double, double* %2
%8 = fcmp une double %7, 0.000000e+00
br i1 %8, label %9, label %14
9: ; preds = %6
%10 = load double, double* %2
%11 = load double, double* %3
%12 = fadd double %11, %10
store double %12, double* %3
%13 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %2)
br label %6
14: ; preds = %6
%15 = load double, double* %3
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), double %15)
ret i32 0
}

LLVM IR (-O2):
@.str = [20 x i8] c"enter the numbers: \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [12 x i8] c"sum is %lf\0A\00"
define i32 @main() {
%1 = alloca double
%2 = bitcast double* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
%5 = load double, double* %1
%6 = fcmp une double %5, 0.000000e+00
br i1 %6, label %7, label %14
7: ; preds = %0, %7
%8 = phi double [ %12, %7 ], [ %5, %0 ]
%9 = phi double [ %10, %7 ], [ 0.000000e+00, %0 ]
%10 = fadd double %9, %8
%11 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
%12 = load double, double* %1
%13 = fcmp une double %12, 0.000000e+00
br i1 %13, label %7, label %14
14: ; preds = %7, %0
%15 = phi double [ 0.000000e+00, %0 ], [ %10, %7 ]
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), double %15)
ret i32 0
}