#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 *, int *, int *);
int main(void) {
  int lower, upper;
  int i, sum;
  printf("Enter lower an upper integer limits: ");
  while (scanf("%d %d", &lower, &upper) == 2 && (lower < upper)) {
    for (i = lower, sum = 0; i <= upper; i++)
      sum += i * i;
    printf("The sums of the squares from %d to %d is %d\n", lower * lower,
           upper * upper, sum);
    printf("Enter next set of limits: ");
  }
  printf("Done\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee2(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <scanf@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x2,%ecx
mov    %al,-0x15(%rbp)
jne    116d <main+0x4d>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
setl   %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    117d <main+0x5d>
jmp    11e3 <main+0xc3>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     11b1 <main+0x91>
mov    -0x10(%rbp),%eax
imul   -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    118a <main+0x6a>
mov    -0x8(%rbp),%esi
imul   -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
imul   -0xc(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    113d <main+0x1d>
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xebe(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed6(%rip),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1050 <scanf@plt>
cmp    $0x2,%eax
jne    1230 <main+0x100>
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
cmp    %edx,%esi
jge    1230 <main+0x100>
lea    0xeb0(%rip),%rbx
lea    0xed6(%rip),%r15
lea    0xe9c(%rip),%r12
lea    0x4(%rsp),%r13
mov    %rsp,%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %edx,%ebp
sub    %esi,%ebp
jge    11b0 <main+0x80>
imul   %esi,%esi
xor    %ecx,%ecx
jmp    11f7 <main+0xc7>
nopl   (%rax)
lea    0x2(%rsi),%ecx
imul   %esi,%ecx
add    $0x1,%ecx
imul   %ebp,%ecx
lea    (%rsi,%rsi,1),%edi
add    $0x3,%edi
mov    %rbx,%r8
mov    %esi,%ebx
not    %ebx
add    %edx,%ebx
mov    %ebp,%eax
add    $0xfffffffe,%eax
imul   %rbx,%rax
imul   %rbp,%rbx
shr    %rbx
imul   %edi,%ebx
imul   %rbp,%rax
shr    %rax
imul   $0x55555556,%eax,%eax
imul   %esi,%esi
add    %esi,%ecx
add    %ebx,%ecx
mov    %r8,%rbx
add    %eax,%ecx
imul   %edx,%edx
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %r14,%rdx
call   1050 <scanf@plt>
cmp    $0x2,%eax
jne    1230 <main+0x100>
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
cmp    %edx,%esi
jl     11a0 <main+0x70>
lea    0xe3d(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [38 x i8] c"Enter lower an upper integer limits: \00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [45 x i8] c"The sums of the squares from %d to %d is %d\0A\00"
@.str.3 = [27 x i8] c"Enter next set of limits: \00"
@.str.4 = [6 x i8] c"Done\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %31, %0
%8 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
%9 = icmp eq i32 %8, 2
br i1 %9, label %10, label %14
10: ; preds = %7
%11 = load i32, i32* %2
%12 = load i32, i32* %3
%13 = icmp slt i32 %11, %12
br label %14
14: ; preds = %10, %7
%15 = phi i1 [ false, %7 ], [ %13, %10 ]
br i1 %15, label %16, label %41
16: ; preds = %14
%17 = load i32, i32* %2
store i32 %17, i32* %4
store i32 0, i32* %5
br label %18
18: ; preds = %28, %16
%19 = load i32, i32* %4
%20 = load i32, i32* %3
%21 = icmp sle i32 %19, %20
br i1 %21, label %22, label %31
22: ; preds = %18
%23 = load i32, i32* %4
%24 = load i32, i32* %4
%25 = mul nsw i32 %23, %24
%26 = load i32, i32* %5
%27 = add nsw i32 %26, %25
store i32 %27, i32* %5
br label %28
28: ; preds = %22
%29 = load i32, i32* %4
%30 = add nsw i32 %29, 1
store i32 %30, i32* %4
br label %18
31: ; preds = %18
%32 = load i32, i32* %2
%33 = load i32, i32* %2
%34 = mul nsw i32 %32, %33
%35 = load i32, i32* %3
%36 = load i32, i32* %3
%37 = mul nsw i32 %35, %36
%38 = load i32, i32* %5
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i32 %34, i32 %37, i32 %38)
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
br label %7
41: ; preds = %14
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [38 x i8] c"Enter lower an upper integer limits: \00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [45 x i8] c"The sums of the squares from %d to %d is %d\0A\00"
@.str.3 = [27 x i8] c"Enter next set of limits: \00"
@str = [5 x i8] c"Done\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%7 = icmp eq i32 %6, 2
%8 = load i32, i32* %1
%9 = load i32, i32* %2
%10 = icmp slt i32 %8, %9
%11 = select i1 %7, i1 %10, i1 false
br i1 %11, label %12, label %58
12: ; preds = %0, %46
%13 = phi i32 [ %55, %46 ], [ %9, %0 ]
%14 = phi i32 [ %54, %46 ], [ %8, %0 ]
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = mul nsw i32 %14, %14
br label %46
18: ; preds = %12
%19 = sub i32 %13, %14
%20 = add i32 %14, 2
%21 = mul i32 %14, %20
%22 = add i32 %21, 1
%23 = mul i32 %19, %22
%24 = shl i32 %14, 1
%25 = add i32 %24, 3
%26 = xor i32 %14, -1
%27 = add i32 %13, %26
%28 = zext i32 %27 to i33
%29 = zext i32 %19 to i33
%30 = mul i33 %28, %29
%31 = lshr i33 %30, 1
%32 = trunc i33 %31 to i32
%33 = mul i32 %25, %32
%34 = add i32 %13, -2
%35 = sub i32 %34, %14
%36 = zext i32 %35 to i33
%37 = mul i33 %28, %36
%38 = mul i33 %37, %29
%39 = lshr i33 %38, 1
%40 = trunc i33 %39 to i32
%41 = mul i32 %40, 1431655766
%42 = mul i32 %14, %14
%43 = add i32 %42, %23
%44 = add i32 %43, %33
%45 = add i32 %44, %41
br label %46
46: ; preds = %16, %18
%47 = phi i32 [ %17, %16 ], [ %42, %18 ]
%48 = phi i32 [ 0, %16 ], [ %45, %18 ]
%49 = mul nsw i32 %13, %13
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i32 %47, i32 %49, i32 %48)
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%52 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%53 = icmp eq i32 %52, 2
%54 = load i32, i32* %1
%55 = load i32, i32* %2
%56 = icmp slt i32 %54, %55
%57 = select i1 %53, i1 %56, i1 false
br i1 %57, label %12, label %58
58: ; preds = %46, %0
%59 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
ret i32 0
}