#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() {
  int i, n, s = 0;
  printf("Please input an integer:");
  scanf("%d", &n);
  for (i = 21; i < n; i += 21)
    s += i;
  printf("The result is:%d\n", s * s);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xece(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x15,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    117e <main+0x5e>
mov    -0x8(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x15,%eax
mov    %eax,-0x8(%rbp)
jmp    115b <main+0x3b>
mov    -0x10(%rbp),%esi
imul   -0x10(%rbp),%esi
lea    0xe90(%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    0xedd(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x16,%eax
jl     1183 <main+0x63>
add    $0xffffffea,%eax
mov    $0x86186187,%ecx
imul   %rax,%rcx
shr    $0x20,%rcx
sub    %ecx,%eax
shr    %eax
add    %ecx,%eax
shr    $0x4,%eax
imul   $0x2a,%eax,%ecx
mov    %eax,%edx
add    $0xffffffff,%edx
imul   %rax,%rdx
shr    %rdx
lea    (%rdx,%rdx,4),%eax
lea    (%rdx,%rax,4),%eax
lea    (%rcx,%rax,1),%ebx
add    $0x15,%ebx
imul   %ebx,%ebx
lea    0xe8f(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [25 x i8] c"Please input an integer:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [18 x i8] c"The result is:%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* %4
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 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* %3)
store i32 21, i32* %2
br label %7
7: ; preds = %15, %0
%8 = load i32, i32* %2
%9 = load i32, i32* %3
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %18
11: ; preds = %7
%12 = load i32, i32* %2
%13 = load i32, i32* %4
%14 = add nsw i32 %13, %12
store i32 %14, i32* %4
br label %15
15: ; preds = %11
%16 = load i32, i32* %2
%17 = add nsw i32 %16, 21
store i32 %17, i32* %2
br label %7
18: ; preds = %7
%19 = load i32, i32* %4
%20 = load i32, i32* %4
%21 = mul nsw i32 %19, %20
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %21)
ret i32 0
}

LLVM IR (-O2):
@.str = [25 x i8] c"Please input an integer:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [18 x i8] c"The result is:%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 ([25 x i8], [25 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, 21
br i1 %6, label %7, label %21
7: ; preds = %0
%8 = add nsw i32 %5, -22
%9 = udiv i32 %8, 21
%10 = mul nuw i32 %9, 42
%11 = udiv i32 %8, 21
%12 = zext i32 %11 to i33
%13 = add nsw i32 %9, -1
%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, 21
%19 = add i32 %10, %18
%20 = add i32 %19, 21
br label %21
21: ; preds = %7, %0
%22 = phi i32 [ 0, %0 ], [ %20, %7 ]
%23 = mul nsw i32 %22, %22
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %23)
ret i32 0
}