#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*/ getch();
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int sumOfSquares, squareOfSum, diff, max = 100, i;
  sumOfSquares = squareOfSum = 0;
  printf("Calculating sum of squares...");
  for (i = 1; i <= max; i++) {
    sumOfSquares = sumOfSquares + (i * i);
  }
  printf(" Its %d", sumOfSquares);
  printf("\nCalculating square of sum...");
  for (i = 1; i <= max; i++) {
    squareOfSum = squareOfSum + i;
  }
  squareOfSum = squareOfSum * squareOfSum;
  printf(" Its %d", squareOfSum);
  diff = squareOfSum - sumOfSquares;
  printf("\nDiff is - %d", diff);
  getch();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x64,-0x14(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     1182 <main+0x62>
mov    -0x8(%rbp),%eax
mov    -0x18(%rbp),%ecx
imul   -0x18(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1159 <main+0x39>
mov    -0x8(%rbp),%esi
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     11cb <main+0xab>
mov    -0xc(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11a8 <main+0x88>
mov    -0xc(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getch@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xed8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee8(%rip),%rbx
mov    %rbx,%rdi
mov    $0x529ae,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeda(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x1852324,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xedb(%rip),%rdi
mov    $0x17ff976,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <getch@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [30 x i8] c"Calculating sum of squares...\00"
@.str.1 = [8 x i8] c" Its %d\00"
@.str.2 = [30 x i8] c"\0ACalculating square of sum...\00"
@.str.3 = [14 x i8] c"\0ADiff is - %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 100, i32* %5
store i32 0, i32* %3
store i32 0, i32* %2
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %6
br label %8
8: ; preds = %18, %0
%9 = load i32, i32* %6
%10 = load i32, i32* %5
%11 = icmp sle i32 %9, %10
br i1 %11, label %12, label %21
12: ; preds = %8
%13 = load i32, i32* %2
%14 = load i32, i32* %6
%15 = load i32, i32* %6
%16 = mul nsw i32 %14, %15
%17 = add nsw i32 %13, %16
store i32 %17, i32* %2
br label %18
18: ; preds = %12
%19 = load i32, i32* %6
%20 = add nsw i32 %19, 1
store i32 %20, i32* %6
br label %8
21: ; preds = %8
%22 = load i32, i32* %2
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %22)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %6
br label %25
25: ; preds = %33, %21
%26 = load i32, i32* %6
%27 = load i32, i32* %5
%28 = icmp sle i32 %26, %27
br i1 %28, label %29, label %36
29: ; preds = %25
%30 = load i32, i32* %3
%31 = load i32, i32* %6
%32 = add nsw i32 %30, %31
store i32 %32, i32* %3
br label %33
33: ; preds = %29
%34 = load i32, i32* %6
%35 = add nsw i32 %34, 1
store i32 %35, i32* %6
br label %25
36: ; preds = %25
%37 = load i32, i32* %3
%38 = load i32, i32* %3
%39 = mul nsw i32 %37, %38
store i32 %39, i32* %3
%40 = load i32, i32* %3
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %40)
%42 = load i32, i32* %3
%43 = load i32, i32* %2
%44 = sub nsw i32 %42, %43
store i32 %44, i32* %4
%45 = load i32, i32* %4
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %45)
%47 = call i32 (...) @getch()
ret i32 0
}

LLVM IR (-O2):
@.str = [30 x i8] c"Calculating sum of squares...\00"
@.str.1 = [8 x i8] c" Its %d\00"
@.str.2 = [30 x i8] c"\0ACalculating square of sum...\00"
@.str.3 = [14 x i8] c"\0ADiff is - %d\00"
define i32 @main() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 338350)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 25502500)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 25164150)
%6 = tail call i32 (...) @getch()
ret i32 0
}