#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 gauss_trick(int);
int pow(int, int);
int /*<<< orphan*/ printf(char *, int);
int main() {
  int difference = 0;
  difference = pow(gauss_trick(100), 2);
  for (int i = 1; i <= 100; i++) {
    difference -= pow(i, 2);
  }
  printf("DIFFERENCE: %d\n", difference);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    $0x64,%edi
call   1040 <gauss_trick@plt>
mov    %eax,%edi
mov    $0x2,%esi
call   1050 <pow@plt>
mov    %eax,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
cmpl   $0x64,-0xc(%rbp)
jg     1195 <main+0x65>
mov    -0xc(%rbp),%edi
mov    $0x2,%esi
call   1050 <pow@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1166 <main+0x36>
mov    -0x8(%rbp),%esi
lea    0xe61(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x64,%edi
call   1040 <gauss_trick@plt>
mov    %eax,%edi
mov    $0x2,%esi
call   1050 <pow@plt>
mov    %eax,%r15d
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebx,%edi
mov    $0x2,%esi
call   1050 <pow@plt>
mov    %eax,%r14d
lea    0x1(%rbx),%edi
mov    $0x2,%esi
call   1050 <pow@plt>
mov    %eax,%ebp
add    %r14d,%ebp
lea    0x2(%rbx),%edi
mov    $0x2,%esi
call   1050 <pow@plt>
mov    %eax,%r14d
add    %ebp,%r14d
lea    0x3(%rbx),%edi
mov    $0x2,%esi
call   1050 <pow@plt>
mov    %eax,%ebp
add    %r14d,%ebp
lea    0x4(%rbx),%edi
mov    $0x2,%esi
call   1050 <pow@plt>
add    %ebp,%eax
sub    %eax,%r15d
add    $0x5,%ebx
cmp    $0x65,%ebx
jne    1160 <main+0x30>
lea    0xe39(%rip),%rdi
mov    %r15d,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"DIFFERENCE: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
%4 = call i32 @gauss_trick(i32 100)
%5 = call i32 @pow(i32 %4, i32 2)
store i32 %5, i32* %2
store i32 1, i32* %3
br label %6
6: ; preds = %14, %0
%7 = load i32, i32* %3
%8 = icmp sle i32 %7, 100
br i1 %8, label %9, label %17
9: ; preds = %6
%10 = load i32, i32* %3
%11 = call i32 @pow(i32 %10, i32 2)
%12 = load i32, i32* %2
%13 = sub nsw i32 %12, %11
store i32 %13, i32* %2
br label %14
14: ; preds = %9
%15 = load i32, i32* %3
%16 = add nsw i32 %15, 1
store i32 %16, i32* %3
br label %6
17: ; preds = %6
%18 = load i32, i32* %2
%19 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %18)
ret i32 0
}

LLVM IR (-O2):
@.str = [16 x i8] c"DIFFERENCE: %d\0A\00"
define i32 @main() {
%1 = tail call i32 @gauss_trick(i32 100)
%2 = tail call i32 @pow(i32 %1, i32 2)
br label %5
3: ; preds = %5
%4 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %21)
ret i32 0
5: ; preds = %5, %0
%6 = phi i32 [ 1, %0 ], [ %22, %5 ]
%7 = phi i32 [ %2, %0 ], [ %21, %5 ]
%8 = tail call i32 @pow(i32 %6, i32 2)
%9 = add nuw nsw i32 %6, 1
%10 = tail call i32 @pow(i32 %9, i32 2)
%11 = add i32 %8, %10
%12 = add nuw nsw i32 %6, 2
%13 = tail call i32 @pow(i32 %12, i32 2)
%14 = add i32 %11, %13
%15 = add nuw nsw i32 %6, 3
%16 = tail call i32 @pow(i32 %15, i32 2)
%17 = add i32 %14, %16
%18 = add nuw nsw i32 %6, 4
%19 = tail call i32 @pow(i32 %18, i32 2)
%20 = add i32 %17, %19
%21 = sub i32 %7, %20
%22 = add nuw nsw i32 %6, 5
%23 = icmp eq i32 %22, 101
br i1 %23, label %3, label %5
}