#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 n, sum = 0;
  printf("This program sums a series of integers.\n");
  printf("Enter integers (0 to terminate): ");
  scanf("%lf", &n);
  while (n != 0) {
    sum += n;
    scanf("%lf", &n);
  }
  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,-0x18(%rbp)
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef1(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1180 <main+0x60>
jp     1180 <main+0x60>
jmp    11a4 <main+0x84>
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
lea    0xeb5(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
jmp    1163 <main+0x43>
movsd  -0x18(%rbp),%xmm0
lea    0xe9f(%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    0xf01(%rip),%rdi
call   1030 <puts@plt>
lea    0xebe(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed2(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
movsd  0x8(%rsp),%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jne    1174 <main+0x44>
jnp    11bd <main+0x8d>
lea    0xeaf(%rip),%r14
lea    0x8(%rsp),%rbx
xorpd  %xmm0,%xmm0
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
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    0xe6a(%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 integers.\0A\00"
@.str.1 = [34 x i8] c"Enter integers (0 to terminate): \00"
@.str.2 = [4 x i8] c"%lf\00"
@.str.3 = [17 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* %3
%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 ([34 x i8], [34 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* %2)
br label %7
7: ; preds = %10, %0
%8 = load double, double* %2
%9 = fcmp une double %8, 0.000000e+00
br i1 %9, label %10, label %15
10: ; preds = %7
%11 = load double, double* %2
%12 = load double, double* %3
%13 = fadd double %12, %11
store double %13, double* %3
%14 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %2)
br label %7
15: ; preds = %7
%16 = load double, double* %3
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), double %16)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [34 x i8] c"Enter integers (0 to terminate): \00"
@.str.2 = [4 x i8] c"%lf\00"
@.str.3 = [17 x i8] c"The sum is: %lf\0A\00"
@str = [40 x i8] c"This program sums a series of integers.\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 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, 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 ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), double %16)
ret i32 0
}