#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 floor(int /*<<< orphan*/);
int /*<<< orphan*/ log10(int);
int /*<<< orphan*/ memset(char *, char, size_t);
int /*<<< orphan*/ printf(char *, ...);
void table(int n) {
  int width = floor(log10(n * n)) + 1;
  printf("%*c |", width, '*');
  for (int j = 1; j <= n; j++) {
    printf(" %*d", width, j);
  }
  size_t line_length = (n + 1) * (width + 1) + 1;
  char hline[line_length + 1];
  memset(hline, '-', line_length);
  hline[width + 1] = '+';
  hline[line_length] = '\0';
  printf("\n%s\n", hline);
  for (int i = 1; i <= n; i++) {
    printf("%*d |", width, i);
    for (int j = 1; j <= n; j++) {
      printf(" %*d", width, i * j);
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<table>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
imul   -0x4(%rbp),%edi
call   1050 <log10@plt>
mov    %eax,%edi
call   1060 <floor@plt>
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe92(%rip),%rdi
mov    $0x2a,%edx
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     11af <table+0x6f>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1181 <table+0x41>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    -0x8(%rbp),%ecx
add    $0x1,%ecx
imul   %ecx,%eax
add    $0x1,%eax
cltq
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rcx
mov    %rcx,%rax
add    $0x1,%rax
mov    %rsp,%rdx
mov    %rdx,-0x20(%rbp)
add    $0x10,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x38(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdx
mov    $0x2d,%esi
call   1040 <memset@plt>
mov    -0x38(%rbp),%rsi
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cltq
movb   $0x2b,(%rsi,%rax,1)
mov    -0x18(%rbp),%rax
movb   $0x0,(%rsi,%rax,1)
lea    0xdec(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     12a2 <table+0x162>
mov    -0x8(%rbp),%esi
mov    -0x2c(%rbp),%edx
lea    0xdca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     1286 <table+0x146>
mov    -0x8(%rbp),%esi
mov    -0x2c(%rbp),%edx
imul   -0x30(%rbp),%edx
lea    0xd95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1254 <table+0x114>
lea    0xd81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    122d <table+0xed>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<table>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%ebx
imul   %edi,%edi
call   1060 <log10@plt>
mov    %eax,%edi
call   1070 <floor@plt>
mov    %eax,%r15d
lea    0x1(%r15),%r12d
lea    0xe83(%rip),%rdi
mov    %r12d,%esi
mov    $0x2a,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,-0x30(%rbp)
test   %ebx,%ebx
jle    11d2 <table+0x82>
mov    -0x30(%rbp),%r14
neg    %r14d
mov    $0x1,%ebx
lea    0xe5f(%rip),%r13
nopw   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %r12d,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    (%r14,%rbx,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
mov    %ecx,%ebx
cmp    $0x1,%eax
jne    11b0 <table+0x60>
mov    -0x30(%rbp),%r13
lea    0x1(%r13),%eax
movslq %r15d,%r14
lea    0x2(%r14),%rcx
imul   %eax,%ecx
movslq %ecx,%r15
lea    0x1(%r15),%rdx
lea    0x11(%r15),%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%rbx
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdi
mov    $0x2d,%esi
call   1050 <memset@plt>
movb   $0x2b,0x2(%r14,%rbx,1)
movb   $0x0,0x1(%r15,%rbx,1)
lea    0xdef(%rip),%rdi
mov    %rbx,%rsi
mov    %r13,%rbx
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebx,%ebx
jle    1292 <table+0x142>
mov    $0x1,%r14d
lea    0xdcc(%rip),%r13
nopw   0x0(%rax,%rax,1)
lea    0xdc9(%rip),%rdi
mov    %r12d,%esi
mov    %r14d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14d,%r15d
nopw   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %r12d,%esi
mov    %r15d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
add    %r14d,%r15d
add    $0xffffffff,%ebx
jne    1260 <table+0x110>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x1(%r14),%eax
mov    -0x30(%rbp),%rbx
cmp    %ebx,%r14d
mov    %eax,%r14d
jne    1240 <table+0xf0>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%*c |\00"
@.str.1 = [5 x i8] c" %*d\00"
@.str.2 = [5 x i8] c"\0A%s\0A\00"
@.str.3 = [6 x i8] c"%*d |\00"
@.str.4 = [2 x i8] c"\0A\00"
define void @table(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %2
%10 = load i32, i32* %2
%11 = load i32, i32* %2
%12 = mul nsw i32 %10, %11
%13 = call i32 @log10(i32 %12)
%14 = call i32 @floor(i32 %13)
%15 = add nsw i32 %14, 1
store i32 %15, i32* %3
%16 = load i32, i32* %3
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %16, i32 42)
store i32 1, i32* %4
br label %18
18: ; preds = %26, %1
%19 = load i32, i32* %4
%20 = load i32, i32* %2
%21 = icmp sle i32 %19, %20
br i1 %21, label %22, label %29
22: ; preds = %18
%23 = load i32, i32* %3
%24 = load i32, i32* %4
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %23, i32 %24)
br label %26
26: ; preds = %22
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 1
store i32 %28, i32* %4
br label %18
29: ; preds = %18
%30 = load i32, i32* %2
%31 = add nsw i32 %30, 1
%32 = load i32, i32* %3
%33 = add nsw i32 %32, 1
%34 = mul nsw i32 %31, %33
%35 = add nsw i32 %34, 1
%36 = sext i32 %35 to i64
store i64 %36, i64* %5
%37 = load i64, i64* %5
%38 = add i64 %37, 1
%39 = call i8* @llvm.stacksave()
store i8* %39, i8** %6
%40 = alloca i8, i64 %38
store i64 %38, i64* %7
%41 = load i64, i64* %5
%42 = call i32 @memset(i8* %40, i8 signext 45, i64 %41)
%43 = load i32, i32* %3
%44 = add nsw i32 %43, 1
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %40, i64 %45
store i8 43, i8* %46
%47 = load i64, i64* %5
%48 = getelementptr inbounds i8, i8* %40, i64 %47
store i8 0, i8* %48
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %40)
store i32 1, i32* %8
br label %50
50: ; preds = %73, %29
%51 = load i32, i32* %8
%52 = load i32, i32* %2
%53 = icmp sle i32 %51, %52
br i1 %53, label %54, label %76
54: ; preds = %50
%55 = load i32, i32* %3
%56 = load i32, i32* %8
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %55, i32 %56)
store i32 1, i32* %9
br label %58
58: ; preds = %68, %54
%59 = load i32, i32* %9
%60 = load i32, i32* %2
%61 = icmp sle i32 %59, %60
br i1 %61, label %62, label %71
62: ; preds = %58
%63 = load i32, i32* %3
%64 = load i32, i32* %8
%65 = load i32, i32* %9
%66 = mul nsw i32 %64, %65
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %63, i32 %66)
br label %68
68: ; preds = %62
%69 = load i32, i32* %9
%70 = add nsw i32 %69, 1
store i32 %70, i32* %9
br label %58
71: ; preds = %58
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %73
73: ; preds = %71
%74 = load i32, i32* %8
%75 = add nsw i32 %74, 1
store i32 %75, i32* %8
br label %50
76: ; preds = %50
%77 = load i8*, i8** %6
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%*c |\00"
@.str.1 = [5 x i8] c" %*d\00"
@.str.2 = [5 x i8] c"\0A%s\0A\00"
@.str.3 = [6 x i8] c"%*d |\00"
define void @table(i32 %0) {
%2 = mul nsw i32 %0, %0
%3 = tail call i32 @log10(i32 %2)
%4 = tail call i32 @floor(i32 %3)
%5 = add nsw i32 %4, 1
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %5, i32 42)
%7 = icmp slt i32 %0, 1
br i1 %7, label %8, label %21
8: ; preds = %21, %1
%9 = add i32 %0, 1
%10 = add nsw i32 %4, 2
%11 = mul nsw i32 %10, %9
%12 = add nsw i32 %11, 1
%13 = sext i32 %12 to i64
%14 = add nsw i64 %13, 1
%15 = alloca i8, i64 %14
%16 = call i32 @memset(i8* %15, i8 signext 45, i64 %13)
%17 = sext i32 %10 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
store i8 43, i8* %18
%19 = getelementptr inbounds i8, i8* %15, i64 %13
store i8 0, i8* %19
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %15)
br i1 %7, label %26, label %27
21: ; preds = %1, %21
%22 = phi i32 [ %24, %21 ], [ 1, %1 ]
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %5, i32 %22)
%24 = add nuw i32 %22, 1
%25 = icmp eq i32 %22, %0
br i1 %25, label %8, label %21
26: ; preds = %30, %8
ret void
27: ; preds = %8, %30
%28 = phi i32 [ %32, %30 ], [ 1, %8 ]
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %5, i32 %28)
br label %34
30: ; preds = %34
%31 = call i32 @putchar(i32 10)
%32 = add nuw i32 %28, 1
%33 = icmp eq i32 %28, %0
br i1 %33, label %26, label %27
34: ; preds = %27, %34
%35 = phi i32 [ %38, %34 ], [ 1, %27 ]
%36 = mul nuw nsw i32 %35, %28
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %5, i32 %36)
%38 = add nuw i32 %35, 1
%39 = icmp eq i32 %35, %0
br i1 %39, label %30, label %34
}