#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 atoi(char *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  if (argc < 2) {
    printf("Usage:<prog> <value>\n");
    return 1;
  }
  int n = atoi(argv[1]);
  unsigned long sq_of_sum = (n * (n + 1)) / 2;
  sq_of_sum *= sq_of_sum;
  unsigned long sum_of_sq = (n * (n + 1) * (2 * n + 1)) / 6;
  unsigned long val = sq_of_sum - sum_of_sq;
  printf(" n = %d, sum_of_square %lu square_of_sum %lu diff %lu\n", n,
         sum_of_sq, sq_of_sum, val);
  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)
cmpl   $0x2,-0x8(%rbp)
jge    115a <main+0x3a>
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11e7 <main+0xc7>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
imul   %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cltq
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
imul   -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
imul   %ecx,%eax
mov    -0x14(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
imul   %ecx,%eax
mov    $0x6,%ecx
cltd
idiv   %ecx
cltq
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
sub    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x28(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x30(%rbp),%r8
lea    0xe3d(%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   %rbx
cmp    $0x1,%edi
jg     1149 <main+0x19>
lea    0xefa(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
jmp    11a3 <main+0x73>
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
lea    0x1(%rax),%edx
imul   %eax,%edx
mov    %edx,%ecx
shr    $0x1f,%ecx
add    %edx,%ecx
sar    %ecx
movslq %ecx,%rcx
imul   %rcx,%rcx
lea    (%rax,%rax,1),%esi
add    $0x1,%esi
imul   %edx,%esi
movslq %esi,%rdx
imul   $0x2aaaaaab,%rdx,%rdx
mov    %rdx,%rsi
shr    $0x3f,%rsi
shr    $0x20,%rdx
add    %esi,%edx
movslq %edx,%rdx
mov    %rcx,%r8
sub    %rdx,%r8
lea    0xe68(%rip),%rdi
xor    %ebx,%ebx
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Usage:<prog> <value>\0A\00"
@.str.1 = [55 x i8] c" n = %d, sum_of_square %lu square_of_sum %lu diff %lu\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 2
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %46
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @atoi(i8* %17)
store i32 %18, i32* %6
%19 = load i32, i32* %6
%20 = load i32, i32* %6
%21 = add nsw i32 %20, 1
%22 = mul nsw i32 %19, %21
%23 = sdiv i32 %22, 2
%24 = sext i32 %23 to i64
store i64 %24, i64* %7
%25 = load i64, i64* %7
%26 = load i64, i64* %7
%27 = mul i64 %26, %25
store i64 %27, i64* %7
%28 = load i32, i32* %6
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 1
%31 = mul nsw i32 %28, %30
%32 = load i32, i32* %6
%33 = mul nsw i32 2, %32
%34 = add nsw i32 %33, 1
%35 = mul nsw i32 %31, %34
%36 = sdiv i32 %35, 6
%37 = sext i32 %36 to i64
store i64 %37, i64* %8
%38 = load i64, i64* %7
%39 = load i64, i64* %8
%40 = sub i64 %38, %39
store i64 %40, i64* %9
%41 = load i32, i32* %6
%42 = load i64, i64* %8
%43 = load i64, i64* %7
%44 = load i64, i64* %9
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0), i32 %41, i64 %42, i64 %43, i64 %44)
store i32 0, i32* %3
br label %46
46: ; preds = %14, %12
%47 = load i32, i32* %3
ret i32 %47
}

LLVM IR (-O2):
@.str.1 = [55 x i8] c" n = %d, sum_of_square %lu square_of_sum %lu diff %lu\0A\00"
@str = [21 x i8] c"Usage:<prog> <value>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
br label %22
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @atoi(i8* %8)
%10 = add nsw i32 %9, 1
%11 = mul nsw i32 %10, %9
%12 = sdiv i32 %11, 2
%13 = sext i32 %12 to i64
%14 = mul nsw i64 %13, %13
%15 = shl nsw i32 %9, 1
%16 = or i32 %15, 1
%17 = mul nsw i32 %11, %16
%18 = sdiv i32 %17, 6
%19 = sext i32 %18 to i64
%20 = sub nsw i64 %14, %19
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0), i32 %9, i64 %19, i64 %14, i64 %20)
br label %22
22: ; preds = %6, %4
%23 = phi i32 [ 1, %4 ], [ 0, %6 ]
ret i32 %23
}