#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 */
scalar_t__ bad_limits(int, int, int const, int const);
int get_int();
int /*<<< orphan*/ printf(char *, ...);
double sum_squares(int, int);
int main(int argc, const char *argv[]) {
  const int MIN = -1000;
  const int MAX = +1000;
  int start;
  int stop;
  double answer;
  printf("This program computes the sum of the squares of "
         "integers in a rang.\nThe lower bound should not "
         "be less than -1000 and\nthe upper bound should not "
         "be more than +1000.\nEnter the limits (enter 0 for "
         "both limits to quit):\nlower limit:");
  start = get_int();
  printf("upper limit: ");
  stop = get_int();
  while (start != 0 || stop != 0) {
    if (bad_limits(start, stop, MIN, MAX)) {
      printf("Please try again.\n");
    } else {
      answer = sum_squares(start, stop);
      printf("The sum of the squares of the integers from ");
      printf("from %d to %d is %g\n", start, stop, answer);
    }
    printf("Enter the limits (enter 0 for both limits to quit):\n");
    printf("lower limit: ");
    start = get_int();
    printf("upper limit: ");
    stop = get_int();
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xfffffc18,-0x14(%rbp)
movl   $0x3e8,-0x18(%rbp)
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1060 <get_int@plt>
mov    %eax,-0x1c(%rbp)
lea    0xf63(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1060 <get_int@plt>
mov    %eax,-0x20(%rbp)
mov    $0x1,%al
cmpl   $0x0,-0x1c(%rbp)
mov    %al,-0x29(%rbp)
jne    11ad <main+0x6d>
cmpl   $0x0,-0x20(%rbp)
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    11bd <main+0x7d>
jmp    1269 <main+0x129>
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    $0xfffffc18,%edx
mov    $0x3e8,%ecx
call   1030 <bad_limits@plt>
cmp    $0x0,%rax
je     11ef <main+0xaf>
lea    0xf11(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1226 <main+0xe6>
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1040 <sum_squares@plt>
movsd  %xmm0,-0x28(%rbp)
lea    0xf01(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
movsd  -0x28(%rbp),%xmm0
lea    0xf15(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xf1c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xf43(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1060 <get_int@plt>
mov    %eax,-0x1c(%rbp)
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1060 <get_int@plt>
mov    %eax,-0x20(%rbp)
jmp    1194 <main+0x54>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe9e(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1070 <get_int@plt>
mov    %eax,%ebp
lea    0xf6d(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1070 <get_int@plt>
mov    %eax,%r15d
mov    %ebp,%eax
or     %r15d,%eax
je     1252 <main+0x102>
lea    0xfa8(%rip),%r12
lea    0xf93(%rip),%r13
lea    0xf3c(%rip),%rbx
lea    0xfc7(%rip),%r14
jmp    122b <main+0xdb>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebp,%edi
mov    %r15d,%esi
call   1050 <sum_squares@plt>
movsd  %xmm0,(%rsp)
lea    0xf1e(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xf3d(%rip),%rdi
mov    %ebp,%esi
mov    %r15d,%edx
movsd  (%rsp),%xmm0
mov    $0x1,%al
call   1060 <printf@plt>
mov    %r12,%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1070 <get_int@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1070 <get_int@plt>
mov    %eax,%r15d
mov    %ebp,%eax
or     %r15d,%eax
je     1252 <main+0x102>
mov    %ebp,%edi
mov    %r15d,%esi
mov    $0xfffffc18,%edx
mov    $0x3e8,%ecx
call   1040 <bad_limits@plt>
test   %rax,%rax
je     11c0 <main+0x70>
mov    %r14,%rdi
call   1030 <puts@plt>
jmp    11f5 <main+0xa5>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [230 x i8] c"This program computes the sum of the squares of integers in a rang.\0AThe lower bound should not be less than -1000 and\0Athe upper bound should not be more than +1000.\0AEnter the limits (enter 0 for both limits to quit):\0Alower limit:\00"
@.str.1 = [14 x i8] c"upper limit: \00"
@.str.2 = [19 x i8] c"Please try again.\0A\00"
@.str.3 = [45 x i8] c"The sum of the squares of the integers from \00"
@.str.4 = [21 x i8] c"from %d to %d is %g\0A\00"
@.str.5 = [53 x i8] c"Enter the limits (enter 0 for both limits to quit):\0A\00"
@.str.6 = [14 x i8] c"lower limit: \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 -1000, i32* %6
store i32 1000, i32* %7
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([230 x i8], [230 x i8]* @.str, i64 0, i64 0))
%12 = call i32 (...) @get_int()
store i32 %12, i32* %8
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 (...) @get_int()
store i32 %14, i32* %9
br label %15
15: ; preds = %39, %2
%16 = load i32, i32* %8
%17 = icmp ne i32 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %15
%19 = load i32, i32* %9
%20 = icmp ne i32 %19, 0
br label %21
21: ; preds = %18, %15
%22 = phi i1 [ true, %15 ], [ %20, %18 ]
br i1 %22, label %23, label %45
23: ; preds = %21
%24 = load i32, i32* %8
%25 = load i32, i32* %9
%26 = call i64 @bad_limits(i32 %24, i32 %25, i32 -1000, i32 1000)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %23
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %39
30: ; preds = %23
%31 = load i32, i32* %8
%32 = load i32, i32* %9
%33 = call double @sum_squares(i32 %31, i32 %32)
store double %33, double* %10
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0))
%35 = load i32, i32* %8
%36 = load i32, i32* %9
%37 = load double, double* %10
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %35, i32 %36, double %37)
br label %39
39: ; preds = %30, %28
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.5, i64 0, i64 0))
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%42 = call i32 (...) @get_int()
store i32 %42, i32* %8
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%44 = call i32 (...) @get_int()
store i32 %44, i32* %9
br label %15
45: ; preds = %21
ret i32 0
}

LLVM IR (-O2):
@.str = [230 x i8] c"This program computes the sum of the squares of integers in a rang.\0AThe lower bound should not be less than -1000 and\0Athe upper bound should not be more than +1000.\0AEnter the limits (enter 0 for both limits to quit):\0Alower limit:\00"
@.str.1 = [14 x i8] c"upper limit: \00"
@.str.3 = [45 x i8] c"The sum of the squares of the integers from \00"
@.str.4 = [21 x i8] c"from %d to %d is %g\0A\00"
@.str.6 = [14 x i8] c"lower limit: \00"
@str = [52 x i8] c"Enter the limits (enter 0 for both limits to quit):\00"
@str.7 = [18 x i8] c"Please try again.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([230 x i8], [230 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 (...) @get_int()
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 (...) @get_int()
%7 = icmp ne i32 %4, 0
%8 = icmp ne i32 %6, 0
%9 = select i1 %7, i1 true, i1 %8
br i1 %9, label %10, label %30
10: ; preds = %2, %21
%11 = phi i32 [ %24, %21 ], [ %4, %2 ]
%12 = phi i32 [ %26, %21 ], [ %6, %2 ]
%13 = tail call i64 @bad_limits(i32 %11, i32 %12, i32 -1000, i32 1000)
%14 = icmp eq i64 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %10
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.7, i64 0, i64 0))
br label %21
17: ; preds = %10
%18 = tail call double @sum_squares(i32 %11, i32 %12)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0))
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %11, i32 %12, double %18)
br label %21
21: ; preds = %17, %15
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str, i64 0, i64 0))
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%24 = tail call i32 (...) @get_int()
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%26 = tail call i32 (...) @get_int()
%27 = icmp ne i32 %24, 0
%28 = icmp ne i32 %26, 0
%29 = select i1 %27, i1 true, i1 %28
br i1 %29, label %10, label %30
30: ; preds = %21, %2
ret i32 0
}