#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 pow(int, int);
int /*<<< orphan*/ printf(char *, int, int);
int task6() {
  const int limit = 100;
  int i, l1 = 0, l2 = 0;
  for (i = 1; i <= limit; i++) {
    l1 += pow(i, 2);
  }
  for (i = 1; i <= limit; i++) {
    l2 += i;
  }
  l2 = pow(l2, 2);
  printf("Sum1: %i, Sum2: %i \n", l1, l2);
  return (l2 - l1);
}


x86 assembly (clang, -O0):
<task6>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x64,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x1,-0x8(%rbp)
cmpl   $0x64,-0x8(%rbp)
jg     116f <task6+0x4f>
mov    -0x8(%rbp),%edi
mov    $0x2,%esi
call   1040 <pow@plt>
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1144 <task6+0x24>
movl   $0x1,-0x8(%rbp)
cmpl   $0x64,-0x8(%rbp)
jg     1197 <task6+0x77>
mov    -0x8(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1176 <task6+0x56>
mov    -0x10(%rbp),%edi
mov    $0x2,%esi
call   1040 <pow@plt>
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe4c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
sub    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<task6>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x1,%ebx
xor    %ebp,%ebp
xchg   %ax,%ax
mov    %ebx,%edi
mov    $0x2,%esi
call   1040 <pow@plt>
mov    %eax,%r14d
add    %ebp,%r14d
lea    0x1(%rbx),%edi
mov    $0x2,%esi
call   1040 <pow@plt>
mov    %eax,%ebp
add    %r14d,%ebp
lea    0x2(%rbx),%edi
mov    $0x2,%esi
call   1040 <pow@plt>
mov    %eax,%r14d
add    %ebp,%r14d
lea    0x3(%rbx),%edi
mov    $0x2,%esi
call   1040 <pow@plt>
mov    %eax,%r15d
add    %r14d,%r15d
lea    0x4(%rbx),%edi
mov    $0x2,%esi
call   1040 <pow@plt>
mov    %eax,%ebp
add    %r15d,%ebp
add    $0x5,%ebx
cmp    $0x65,%ebx
jne    1130 <task6+0x10>
mov    $0x13ba,%edi
mov    $0x2,%esi
call   1040 <pow@plt>
mov    %eax,%ebx
lea    0xe54(%rip),%rdi
mov    %ebp,%esi
mov    %eax,%edx
call   1030 <printf@plt>
sub    %ebp,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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