#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 EXIT_FAILURE;
long SquareOfSum(int);
long SumOfSquares(int);
int atoi(char *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  long int sumOfSquares;
  long int squareOfSum;
  int max = atoi(argv[1]);
  if (argc != 2) {
    printf("Wrong number of arguments!\n");
    return EXIT_FAILURE;
  }
  sumOfSquares = SumOfSquares(max);
  printf("The sum of squares up to %d is: %ld\n", max, sumOfSquares);
  squareOfSum = SquareOfSum(max);
  printf("The square of sum up to %d is: %ld\n", max, squareOfSum);
  printf("The difference of the two is: %ld\n", squareOfSum - sumOfSquares);
  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)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     118f <main+0x4f>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e5b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11ee <main+0xae>
mov    -0x24(%rbp),%edi
call   1040 <SumOfSquares@plt>
mov    %rax,-0x18(%rbp)
mov    -0x24(%rbp),%esi
mov    -0x18(%rbp),%rdx
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%edi
call   1050 <SquareOfSum@plt>
mov    %rax,-0x20(%rbp)
mov    -0x24(%rbp),%esi
mov    -0x20(%rbp),%rdx
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rsi
sub    -0x18(%rbp),%rsi
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
mov    0x8(%rsi),%rdi
call   1070 <atoi@plt>
cmp    $0x2,%ebx
jne    11bc <main+0x6c>
mov    %eax,%ebp
mov    %eax,%edi
call   1050 <SumOfSquares@plt>
mov    %rax,%r14
lea    0xe86(%rip),%rdi
xor    %r15d,%r15d
mov    %ebp,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%edi
call   1060 <SquareOfSum@plt>
mov    %rax,%rbx
lea    0xe8b(%rip),%rdi
mov    %ebp,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
sub    %r14,%rbx
lea    0xe99(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11d2 <main+0x82>
lea    0xea9(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e11(%rip),%rax
mov    (%rax),%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Wrong number of arguments!\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [37 x i8] c"The sum of squares up to %d is: %ld\0A\00"
@.str.2 = [36 x i8] c"The square of sum up to %d is: %ld\0A\00"
@.str.3 = [35 x i8] c"The difference of the two is: %ld\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = call i32 @atoi(i8* %11)
store i32 %12, i32* %8
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 2
br i1 %14, label %15, label %18
15: ; preds = %2
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%17 = load i32, i32* @EXIT_FAILURE
store i32 %17, i32* %3
br label %33
18: ; preds = %2
%19 = load i32, i32* %8
%20 = call i64 @SumOfSquares(i32 %19)
store i64 %20, i64* %6
%21 = load i32, i32* %8
%22 = load i64, i64* %6
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %21, i64 %22)
%24 = load i32, i32* %8
%25 = call i64 @SquareOfSum(i32 %24)
store i64 %25, i64* %7
%26 = load i32, i32* %8
%27 = load i64, i64* %7
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i32 %26, i64 %27)
%29 = load i64, i64* %7
%30 = load i64, i64* %6
%31 = sub nsw i64 %29, %30
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i64 %31)
store i32 0, i32* %3
br label %33
33: ; preds = %18, %15
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@.str.1 = [37 x i8] c"The sum of squares up to %d is: %ld\0A\00"
@.str.2 = [36 x i8] c"The square of sum up to %d is: %ld\0A\00"
@.str.3 = [35 x i8] c"The difference of the two is: %ld\0A\00"
@str = [27 x i8] c"Wrong number of arguments!\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i32 @atoi(i8* %4)
%6 = icmp eq i32 %0, 2
br i1 %6, label %10, label %7
7: ; preds = %2
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%9 = load i32, i32* @EXIT_FAILURE
br label %17
10: ; preds = %2
%11 = tail call i64 @SumOfSquares(i32 %5)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %5, i64 %11)
%13 = tail call i64 @SquareOfSum(i32 %5)
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i32 %5, i64 %13)
%15 = sub nsw i64 %13, %11
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i64 %15)
br label %17
17: ; preds = %10, %7
%18 = phi i32 [ %9, %7 ], [ 0, %10 ]
ret i32 %18
}