#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 *, int *, int *);
int main(void) {
  int lower, upper;
  int sum, i;
  printf("Enter lower and upper integer limits:");
  scanf("%d %d", &lower, &upper);
  while (upper > lower) {
    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 lower and upper integer limits:");
    scanf("%d %d", &lower, &upper);
  }
  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    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jle    11d7 <main+0xb7>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     1191 <main+0x71>
mov    -0x14(%rbp),%eax
imul   -0x14(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116a <main+0x4a>
mov    -0x8(%rbp),%esi
imul   -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
imul   -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe61(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <scanf@plt>
jmp    1151 <main+0x31>
lea    0xea6(%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>
mov    (%rsp),%edx
mov    0x4(%rsp),%esi
cmp    %esi,%edx
jle    1214 <main+0xe4>
lea    0xeb9(%rip),%rbx
lea    0xedf(%rip),%r15
lea    0xea5(%rip),%r12
lea    0x4(%rsp),%r13
mov    %rsp,%r14
jmp    1207 <main+0xd7>
xchg   %ax,%ax
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>
mov    (%rsp),%edx
mov    0x4(%rsp),%esi
cmp    %esi,%edx
jle    1214 <main+0xe4>
mov    %edx,%ebp
sub    %esi,%ebp
jge    1190 <main+0x60>
imul   %esi,%esi
xor    %ecx,%ecx
jmp    11d7 <main+0xa7>
lea    0xe69(%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 and 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 = [43 x i8] c"Enter next lower and upper integer 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))
%7 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
br label %8
8: ; preds = %27, %0
%9 = load i32, i32* %3
%10 = load i32, i32* %2
%11 = icmp sgt i32 %9, %10
br i1 %11, label %12, label %38
12: ; preds = %8
%13 = load i32, i32* %2
store i32 %13, i32* %5
store i32 0, i32* %4
br label %14
14: ; preds = %24, %12
%15 = load i32, i32* %5
%16 = load i32, i32* %3
%17 = icmp sle i32 %15, %16
br i1 %17, label %18, label %27
18: ; preds = %14
%19 = load i32, i32* %5
%20 = load i32, i32* %5
%21 = mul nsw i32 %19, %20
%22 = load i32, i32* %4
%23 = add nsw i32 %22, %21
store i32 %23, i32* %4
br label %24
24: ; preds = %18
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 1
store i32 %26, i32* %5
br label %14
27: ; preds = %14
%28 = load i32, i32* %2
%29 = load i32, i32* %2
%30 = mul nsw i32 %28, %29
%31 = load i32, i32* %3
%32 = load i32, i32* %3
%33 = mul nsw i32 %31, %32
%34 = load i32, i32* %4
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i32 %30, i32 %33, i32 %34)
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0))
%37 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
br label %8
38: ; preds = %8
%39 = 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 and 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 = [43 x i8] c"Enter next lower and upper integer 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 = load i32, i32* %2
%8 = load i32, i32* %1
%9 = icmp sgt i32 %7, %8
br i1 %9, label %10, label %54
10: ; preds = %0, %44
%11 = phi i32 [ %52, %44 ], [ %8, %0 ]
%12 = phi i32 [ %51, %44 ], [ %7, %0 ]
%13 = icmp slt i32 %12, %11
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = mul nsw i32 %11, %11
br label %44
16: ; preds = %10
%17 = sub i32 %12, %11
%18 = add i32 %11, 2
%19 = mul i32 %11, %18
%20 = add i32 %19, 1
%21 = mul i32 %17, %20
%22 = shl i32 %11, 1
%23 = add i32 %22, 3
%24 = xor i32 %11, -1
%25 = add i32 %12, %24
%26 = zext i32 %25 to i33
%27 = zext i32 %17 to i33
%28 = mul i33 %26, %27
%29 = lshr i33 %28, 1
%30 = trunc i33 %29 to i32
%31 = mul i32 %23, %30
%32 = add i32 %12, -2
%33 = sub i32 %32, %11
%34 = zext i32 %33 to i33
%35 = mul i33 %26, %34
%36 = mul i33 %35, %27
%37 = lshr i33 %36, 1
%38 = trunc i33 %37 to i32
%39 = mul i32 %38, 1431655766
%40 = mul i32 %11, %11
%41 = add i32 %40, %21
%42 = add i32 %41, %31
%43 = add i32 %42, %39
br label %44
44: ; preds = %14, %16
%45 = phi i32 [ %15, %14 ], [ %40, %16 ]
%46 = phi i32 [ 0, %14 ], [ %43, %16 ]
%47 = mul nsw i32 %12, %12
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i32 %45, i32 %47, i32 %46)
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0))
%50 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%51 = load i32, i32* %2
%52 = load i32, i32* %1
%53 = icmp sgt i32 %51, %52
br i1 %53, label %10, label %54
54: ; preds = %44, %0
%55 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
ret i32 0
}