#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 scanf(char *, long *);
int main(void) {
  long num;
  long sum = 0L;
  int status;
  printf("Please enter an integer to be summed ");
  printf("(q to quit): ");
  status = scanf("%ld", &num);
  while (status == 1) {
    sum = sum + num;
    printf("Please enter next integer (q to quit): ");
    status = scanf("%ld", &num);
  }
  printf("Those integer num to %ld.\n", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x18(%rbp)
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecc(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jne    11a2 <main+0x82>
mov    -0x18(%rbp),%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe95(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    %eax,-0x1c(%rbp)
jmp    1166 <main+0x46>
mov    -0x18(%rbp),%rsi
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xed1(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf05(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed9(%rip),%rdi
mov    %rsp,%rsi
call   1040 <scanf@plt>
cmp    $0x1,%eax
jne    118e <main+0x6e>
lea    0xec9(%rip),%r14
lea    0xebe(%rip),%r15
mov    %rsp,%r12
xor    %ebx,%ebx
nopl   (%rax)
add    (%rsp),%rbx
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <scanf@plt>
cmp    $0x1,%eax
je     1170 <main+0x50>
lea    0xebd(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [38 x i8] c"Please enter an integer to be summed \00"
@.str.1 = [14 x i8] c"(q to quit): \00"
@.str.2 = [4 x i8] c"%ld\00"
@.str.3 = [40 x i8] c"Please enter next integer (q to quit): \00"
@.str.4 = [27 x i8] c"Those integer num to %ld.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i32
store i32 0, i32* %1
store i64 0, i64* %3
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64* %2)
store i32 %7, i32* %4
br label %8
8: ; preds = %11, %0
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %17
11: ; preds = %8
%12 = load i64, i64* %3
%13 = load i64, i64* %2
%14 = add nsw i64 %12, %13
store i64 %14, i64* %3
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64* %2)
store i32 %16, i32* %4
br label %8
17: ; preds = %8
%18 = load i64, i64* %3
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i64 %18)
ret i32 0
}

LLVM IR (-O2):
@.str = [38 x i8] c"Please enter an integer to be summed \00"
@.str.1 = [14 x i8] c"(q to quit): \00"
@.str.2 = [4 x i8] c"%ld\00"
@.str.3 = [40 x i8] c"Please enter next integer (q to quit): \00"
@.str.4 = [27 x i8] c"Those integer num to %ld.\0A\00"
define i32 @main() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 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), i64* %1)
%6 = icmp eq i32 %5, 1
br i1 %6, label %7, label %14
7: ; preds = %0, %7
%8 = phi i64 [ %10, %7 ], [ 0, %0 ]
%9 = load i64, i64* %1
%10 = add nsw i64 %9, %8
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64* %1)
%13 = icmp eq i32 %12, 1
br i1 %13, label %7, label %14
14: ; preds = %7, %0
%15 = phi i64 [ 0, %0 ], [ %10, %7 ]
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i64 %15)
ret i32 0
}