#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, ...);
int /*<<< orphan*/ system(char *);
int main(void) {
  int i, sum_sq = 0, sq_sum = 0, dif;
  for (i = 1; i <= 100; i++) {
    sum_sq += i * i;
    sq_sum += i;
  }
  sq_sum = sq_sum * sq_sum;
  dif = sq_sum - sum_sq;
  printf("Sum of squares: %d\nSquare of sum: %d\n", sum_sq, sq_sum);
  printf("Difference: %d\n", dif);
  system("PAUSE");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x1,-0x8(%rbp)
cmpl   $0x64,-0x8(%rbp)
jg     1172 <main+0x52>
mov    -0x8(%rbp),%eax
imul   -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1144 <main+0x24>
mov    -0x10(%rbp),%eax
imul   -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe85(%rip),%rdi
call   1030 <system@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
mov    $0x529ae,%esi
mov    $0x1852324,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xee6(%rip),%rdi
mov    $0x17ff976,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xee3(%rip),%rdi
call   1030 <system@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [38 x i8] c"Sum of squares: %d\0ASquare of sum: %d\0A\00"
@.str.1 = [16 x i8] c"Difference: %d\0A\00"
@.str.2 = [6 x i8] c"PAUSE\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %4
store i32 1, i32* %2
br label %6
6: ; preds = %18, %0
%7 = load i32, i32* %2
%8 = icmp sle i32 %7, 100
br i1 %8, label %9, label %21
9: ; preds = %6
%10 = load i32, i32* %2
%11 = load i32, i32* %2
%12 = mul nsw i32 %10, %11
%13 = load i32, i32* %3
%14 = add nsw i32 %13, %12
store i32 %14, i32* %3
%15 = load i32, i32* %2
%16 = load i32, i32* %4
%17 = add nsw i32 %16, %15
store i32 %17, i32* %4
br label %18
18: ; preds = %9
%19 = load i32, i32* %2
%20 = add nsw i32 %19, 1
store i32 %20, i32* %2
br label %6
21: ; preds = %6
%22 = load i32, i32* %4
%23 = load i32, i32* %4
%24 = mul nsw i32 %22, %23
store i32 %24, i32* %4
%25 = load i32, i32* %4
%26 = load i32, i32* %3
%27 = sub nsw i32 %25, %26
store i32 %27, i32* %5
%28 = load i32, i32* %3
%29 = load i32, i32* %4
%30 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %28, i32 %29)
%31 = load i32, i32* %5
%32 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %31)
%33 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [38 x i8] c"Sum of squares: %d\0ASquare of sum: %d\0A\00"
@.str.1 = [16 x i8] c"Difference: %d\0A\00"
@.str.2 = [6 x i8] c"PAUSE\00"
define i32 @main() {
%1 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 338350, i32 25502500)
%2 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 25164150)
%3 = tail call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}