#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int n, i = 0, t = 0;
  printf("Informe a quantidade: ");
  scanf("%d", &n);
  while (i < n) {
    t = t + (i * i);
    i++;
  }
  printf("A soma do quadrado dos %d primeiros números naturais é %d\n", n, t);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec5(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1184 <main+0x64>
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
imul   -0xc(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    115b <main+0x3b>
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xed4(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xedb(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%esi
test   %esi,%esi
jle    1176 <main+0x56>
lea    -0x1(%rsi),%eax
lea    -0x2(%rsi),%ecx
imul   %rax,%rcx
lea    -0x3(%rsi),%eax
imul   %rcx,%rax
shr    %rax
imul   $0x55555556,%eax,%eax
add    %esi,%eax
shr    %rcx
lea    (%rcx,%rcx,2),%ecx
lea    (%rax,%rcx,1),%ebx
add    $0xffffffff,%ebx
lea    0xe9d(%rip),%rdi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Informe a quantidade: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [61 x i8] c"A soma do quadrado dos %d primeiros n\C3\BAmeros naturais \C3\A9 %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %4
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %7
7: ; preds = %11, %0
%8 = load i32, i32* %3
%9 = load i32, i32* %2
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %19
11: ; preds = %7
%12 = load i32, i32* %4
%13 = load i32, i32* %3
%14 = load i32, i32* %3
%15 = mul nsw i32 %13, %14
%16 = add nsw i32 %12, %15
store i32 %16, i32* %4
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 1
store i32 %18, i32* %3
br label %7
19: ; preds = %7
%20 = load i32, i32* %2
%21 = load i32, i32* %4
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.2, i64 0, i64 0), i32 %20, i32 %21)
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"Informe a quantidade: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [61 x i8] c"A soma do quadrado dos %d primeiros n\C3\BAmeros naturais \C3\A9 %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %25
7: ; preds = %0
%8 = add nsw i32 %5, -1
%9 = zext i32 %8 to i33
%10 = add nsw i32 %5, -2
%11 = zext i32 %10 to i33
%12 = mul i33 %9, %11
%13 = add nsw i32 %5, -3
%14 = zext i32 %13 to i33
%15 = mul i33 %12, %14
%16 = lshr i33 %15, 1
%17 = trunc i33 %16 to i32
%18 = mul i32 %17, 1431655766
%19 = add i32 %5, %18
%20 = lshr i33 %12, 1
%21 = trunc i33 %20 to i32
%22 = mul i32 %21, 3
%23 = add i32 %19, %22
%24 = add i32 %23, -1
br label %25
25: ; preds = %7, %0
%26 = phi i32 [ 0, %0 ], [ %24, %7 ]
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @.str.2, i64 0, i64 0), i32 %5, i32 %26)
ret i32 0
}