#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 *, short *);
int main(void) {
  short i, n;
  printf("This program prints a table of squares.\n");
  printf("Enter the number of entries in table: ");
  scanf("%hd", &n);
  for (i = 1; i <= n; i++) {
    printf("%10hd\t%10d\n", i, i * i);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xefe(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movw   $0x1,-0x6(%rbp)
movswl -0x6(%rbp),%eax
movswl -0x8(%rbp),%ecx
cmp    %ecx,%eax
jg     119f <main+0x7f>
movswl -0x6(%rbp),%esi
movswl -0x6(%rbp),%edx
movswl -0x6(%rbp),%eax
imul   %eax,%edx
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x6(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x6(%rbp)
jmp    1161 <main+0x41>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xefd(%rip),%rdi
call   1030 <puts@plt>
lea    0xeba(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed3(%rip),%rdi
lea    0x6(%rsp),%rsi
call   1050 <scanf@plt>
cmpw   $0x0,0x6(%rsp)
jle    11a0 <main+0x70>
mov    $0x1,%ebp
lea    0xeb9(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebp,%edx
imul   %ebp,%edx
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
movswl %bp,%eax
cmp    0x6(%rsp),%bp
mov    %eax,%ebp
jle    1180 <main+0x50>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [41 x i8] c"This program prints a table of squares.\0A\00"
@.str.1 = [39 x i8] c"Enter the number of entries in table: \00"
@.str.2 = [4 x i8] c"%hd\00"
@.str.3 = [12 x i8] c"%10hd\09%10d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i16
%3 = alloca i16
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i16* %3)
store i16 1, i16* %2
br label %7
7: ; preds = %22, %0
%8 = load i16, i16* %2
%9 = sext i16 %8 to i32
%10 = load i16, i16* %3
%11 = sext i16 %10 to i32
%12 = icmp sle i32 %9, %11
br i1 %12, label %13, label %25
13: ; preds = %7
%14 = load i16, i16* %2
%15 = sext i16 %14 to i32
%16 = load i16, i16* %2
%17 = sext i16 %16 to i32
%18 = load i16, i16* %2
%19 = sext i16 %18 to i32
%20 = mul nsw i32 %17, %19
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %15, i32 %20)
br label %22
22: ; preds = %13
%23 = load i16, i16* %2
%24 = add i16 %23, 1
store i16 %24, i16* %2
br label %7
25: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [39 x i8] c"Enter the number of entries in table: \00"
@.str.2 = [4 x i8] c"%hd\00"
@.str.3 = [12 x i8] c"%10hd\09%10d\0A\00"
@str = [40 x i8] c"This program prints a table of squares.\00"
define i32 @main() {
%1 = alloca i16
%2 = bitcast i16* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i16* %1)
%6 = load i16, i16* %1
%7 = icmp slt i16 %6, 1
br i1 %7, label %17, label %8
8: ; preds = %0, %8
%9 = phi i32 [ %14, %8 ], [ 1, %0 ]
%10 = trunc i32 %9 to i16
%11 = mul nsw i32 %9, %9
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %9, i32 %11)
%13 = add i16 %10, 1
%14 = sext i16 %13 to i32
%15 = load i16, i16* %1
%16 = icmp sgt i16 %13, %15
br i1 %16, label %17, label %8
17: ; preds = %8, %0
ret i32 0
}