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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2eb2(%rip),%rax
mov    (%rax),%esi
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef0(%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     11b6 <main+0x96>
movswl -0x6(%rbp),%esi
movswl -0x6(%rbp),%edx
movswl -0x6(%rbp),%eax
imul   %eax,%edx
lea    0xebf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x6(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x6(%rbp)
jmp    1178 <main+0x58>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    0x2eae(%rip),%rax
mov    (%rax),%esi
lea    0xebd(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeed(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec5(%rip),%rdi
lea    0x6(%rsp),%rsi
call   1050 <scanf@plt>
cmpw   $0x0,0x6(%rsp)
jle    11b0 <main+0x80>
mov    $0x1,%ebp
lea    0xeab(%rip),%rbx
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    1190 <main+0x60>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [13 x i8] c"Max Int: %d\0A\00"
@INT_MAX = global i32 0
@.str.2 = [35 x i8] c"Enter number of entries in table: \00"
@.str.3 = [4 x i8] c"%hi\00"
@.str.4 = [10 x i8] c"%12i%12i\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 = load i32, i32* @INT_MAX
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i16* %1)
%8 = load i16, i16* %1
%9 = icmp slt i16 %8, 1
br i1 %9, label %19, label %10
10: ; preds = %0, %10
%11 = phi i32 [ %16, %10 ], [ 1, %0 ]
%12 = trunc i32 %11 to i16
%13 = mul nsw i32 %11, %11
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 %11, i32 %13)
%15 = add i16 %12, 1
%16 = sext i16 %15 to i32
%17 = load i16, i16* %1
%18 = icmp sgt i16 %15, %17
br i1 %18, label %19, label %10
19: ; preds = %10, %0
ret i32 0
}