#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 digit_count(int);
int /*<<< orphan*/ printf(char *, ...);
void print_table(int width, int table[][width]) {
  int padding = digit_count(table[width - 1][width - 1]) + 1;
  for (int row = 0; row < width; ++row) {
    for (int col = 0; col < width; ++col) {
      printf("%*d", padding, table[row][col]);
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<print_table>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,%edx
mov    %rdx,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
imul   %rdx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edi
call   1040 <digit_count@plt>
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11e6 <print_table+0xc6>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11ca <print_table+0xaa>
mov    -0x28(%rbp),%rdx
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
imul   %rdx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1181 <print_table+0x61>
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    116e <print_table+0x4e>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_table>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%r15d
movslq %edi,%r14
lea    -0x1(%r14),%rax
imul   %r15,%rax
lea    (%rsi,%rax,4),%rax
mov    -0x4(%rax,%r14,4),%edi
call   1050 <digit_count@plt>
test   %r14d,%r14d
jle    11c0 <print_table+0x90>
mov    %eax,%ebp
add    $0x1,%ebp
lea    0x0(,%r15,4),%rax
mov    %rax,(%rsp)
lea    0xe89(%rip),%r14
xor    %r13d,%r13d
nopw   0x0(%rax,%rax,1)
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%rbx,%r12,4),%edx
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r12
cmp    %r12,%r15
jne    1190 <print_table+0x60>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r13
add    (%rsp),%rbx
cmp    %r15,%r13
jne    1180 <print_table+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%*d\00"
@.str.1 = [2 x i8] c"\0A\00"
define void @print_table(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i32* %1, i32** %4
%8 = load i32, i32* %3
%9 = zext i32 %8 to i64
%10 = load i32*, i32** %4
%11 = load i32, i32* %3
%12 = sub nsw i32 %11, 1
%13 = sext i32 %12 to i64
%14 = mul nsw i64 %13, %9
%15 = getelementptr inbounds i32, i32* %10, i64 %14
%16 = load i32, i32* %3
%17 = sub nsw i32 %16, 1
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i32, i32* %15, i64 %18
%20 = load i32, i32* %19
%21 = call i32 @digit_count(i32 %20)
%22 = add nsw i32 %21, 1
store i32 %22, i32* %5
store i32 0, i32* %6
br label %23
23: ; preds = %49, %2
%24 = load i32, i32* %6
%25 = load i32, i32* %3
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %52
27: ; preds = %23
store i32 0, i32* %7
br label %28
28: ; preds = %44, %27
%29 = load i32, i32* %7
%30 = load i32, i32* %3
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %47
32: ; preds = %28
%33 = load i32, i32* %5
%34 = load i32*, i32** %4
%35 = load i32, i32* %6
%36 = sext i32 %35 to i64
%37 = mul nsw i64 %36, %9
%38 = getelementptr inbounds i32, i32* %34, i64 %37
%39 = load i32, i32* %7
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i32, i32* %38, i64 %40
%42 = load i32, i32* %41
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %33, i32 %42)
br label %44
44: ; preds = %32
%45 = load i32, i32* %7
%46 = add nsw i32 %45, 1
store i32 %46, i32* %7
br label %28
47: ; preds = %28
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %49
49: ; preds = %47
%50 = load i32, i32* %6
%51 = add nsw i32 %50, 1
store i32 %51, i32* %6
br label %23
52: ; preds = %23
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%*d\00"
define void @print_table(i32 %0, i32* nocapture %1) {
%3 = zext i32 %0 to i64
%4 = add nsw i32 %0, -1
%5 = sext i32 %4 to i64
%6 = mul nsw i64 %5, %3
%7 = getelementptr inbounds i32, i32* %1, i64 %6
%8 = getelementptr inbounds i32, i32* %7, i64 %5
%9 = load i32, i32* %8
%10 = tail call i32 @digit_count(i32 %9)
%11 = add nsw i32 %10, 1
%12 = icmp sgt i32 %0, 0
br i1 %12, label %13, label %17
13: ; preds = %2, %18
%14 = phi i64 [ %20, %18 ], [ 0, %2 ]
%15 = mul nuw nsw i64 %14, %3
%16 = getelementptr inbounds i32, i32* %1, i64 %15
br label %22
17: ; preds = %18, %2
ret void
18: ; preds = %22
%19 = tail call i32 @putchar(i32 10)
%20 = add nuw nsw i64 %14, 1
%21 = icmp eq i64 %20, %3
br i1 %21, label %17, label %13
22: ; preds = %13, %22
%23 = phi i64 [ 0, %13 ], [ %27, %22 ]
%24 = getelementptr inbounds i32, i32* %16, i64 %23
%25 = load i32, i32* %24
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %11, i32 %25)
%27 = add nuw nsw i64 %23, 1
%28 = icmp eq i64 %27, %3
br i1 %28, label %18, label %22
}