#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 sum = 0.0, number;
  printf("this program sums a series of intergers\n");
  printf("enterintegers (0 to terminate)\n");
  scanf("%lf", &number);
  while (number != 0) {
    sum += number;
    scanf("%lf", &number);
  }
  printf("the 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,-0x10(%rbp)
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeef(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1180 <main+0x60>
jp     1180 <main+0x60>
jmp    11a4 <main+0x84>
movsd  -0x18(%rbp),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
lea    0xeb3(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
jmp    1163 <main+0x43>
movsd  -0x10(%rbp),%xmm0
lea    0xe9d(%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    0xee0(%rip),%rdi
call   1030 <puts@plt>
lea    0xefc(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb2(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
movsd  0x8(%rsp),%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jne    1172 <main+0x42>
jnp    11bd <main+0x8d>
lea    0xe8f(%rip),%r14
lea    0x8(%rsp),%rbx
xorpd  %xmm0,%xmm0
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
addsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rsp)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
ucomisd 0xe47(%rip),%xmm1
jne    1190 <main+0x60>
jp     1190 <main+0x60>
lea    0xe48(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [41 x i8] c"this program sums a series of intergers\0A\00"
@.str.1 = [32 x i8] c"enterintegers (0 to terminate)\0A\00"
@.str.2 = [4 x i8] c"%lf\00"
@.str.3 = [18 x i8] c"the 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* %2
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %3)
br label %7
7: ; preds = %10, %0
%8 = load double, double* %3
%9 = fcmp une double %8, 0.000000e+00
br i1 %9, label %10, label %15
10: ; preds = %7
%11 = load double, double* %3
%12 = load double, double* %2
%13 = fadd double %12, %11
store double %13, double* %2
%14 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %3)
br label %7
15: ; preds = %7
%16 = load double, double* %2
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), double %16)
ret i32 0
}

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