#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 n;
  printf("this program prints a square\n");
  printf("enter number of entries in table:\n");
  scanf("%hd", &n);
  printf("%30hd%30hd\n", n, n * n);
  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    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeef(%rip),%rdi
lea    -0x6(%rbp),%rsi
call   1040 <scanf@plt>
movswl -0x6(%rbp),%esi
movswl -0x6(%rbp),%edx
movswl -0x6(%rbp),%eax
imul   %eax,%edx
lea    0xed4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
call   1030 <puts@plt>
lea    0xee9(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb0(%rip),%rdi
lea    0x6(%rsp),%rsi
call   1050 <scanf@plt>
movswl 0x6(%rsp),%esi
mov    %esi,%edx
imul   %esi,%edx
lea    0xe99(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [30 x i8] c"this program prints a square\0A\00"
@.str.1 = [35 x i8] c"enter number of entries in table:\0A\00"
@.str.2 = [4 x i8] c"%hd\00"
@.str.3 = [12 x i8] c"%30hd%30hd\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i16
store i32 0, i32* %1
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 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* %2)
%6 = load i16, i16* %2
%7 = sext i16 %6 to i32
%8 = load i16, i16* %2
%9 = sext i16 %8 to i32
%10 = load i16, i16* %2
%11 = sext i16 %10 to i32
%12 = mul nsw i32 %9, %11
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %7, i32 %12)
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [4 x i8] c"%hd\00"
@.str.3 = [12 x i8] c"%30hd%30hd\0A\00"
@str = [29 x i8] c"this program prints a square\00"
@str.4 = [34 x i8] c"enter number of entries in table:\00"
define i32 @main() {
%1 = alloca i16
%2 = bitcast i16* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.4, 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 = sext i16 %6 to i32
%8 = mul nsw i32 %7, %7
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %7, i32 %8)
ret i32 0
}