#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 **table, int 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    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edi
call   1040 <digit_count@plt>
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11cb <print_table+0xab>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11af <print_table+0x8f>
mov    -0x10(%rbp),%esi
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1171 <print_table+0x51>
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115e <print_table+0x3e>
add    $0x20,%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    %esi,%r14d
mov    %rdi,%r15
movslq %esi,%rbx
mov    -0x8(%rdi,%rbx,8),%rax
mov    -0x4(%rax,%rbx,4),%edi
call   1050 <digit_count@plt>
test   %ebx,%ebx
jle    11b0 <print_table+0x80>
mov    %eax,%r12d
add    $0x1,%r12d
mov    %r14d,%r13d
lea    0xe99(%rip),%r14
xor    %ebp,%ebp
nopl   0x0(%rax)
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r15,%rbp,8),%rax
mov    (%rax,%rbx,4),%edx
mov    %r14,%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1180 <print_table+0x50>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
cmp    %r13,%rbp
jne    1170 <print_table+0x40>
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 = load i32, i32* %4
%10 = sub nsw i32 %9, 1
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i32*, i32** %8, i64 %11
%13 = load i32*, i32** %12
%14 = load i32, i32* %4
%15 = sub nsw i32 %14, 1
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i32, i32* %13, i64 %16
%18 = load i32, i32* %17
%19 = call i32 @digit_count(i32 %18)
%20 = add nsw i32 %19, 1
store i32 %20, i32* %5
store i32 0, i32* %6
br label %21
21: ; preds = %47, %2
%22 = load i32, i32* %6
%23 = load i32, i32* %4
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %50
25: ; preds = %21
store i32 0, i32* %7
br label %26
26: ; preds = %42, %25
%27 = load i32, i32* %7
%28 = load i32, i32* %4
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %45
30: ; preds = %26
%31 = load i32, i32* %5
%32 = load i32**, i32*** %3
%33 = load i32, i32* %6
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i32*, i32** %32, i64 %34
%36 = load i32*, i32** %35
%37 = load i32, i32* %7
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* %36, i64 %38
%40 = load i32, i32* %39
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %31, i32 %40)
br label %42
42: ; preds = %30
%43 = load i32, i32* %7
%44 = add nsw i32 %43, 1
store i32 %44, i32* %7
br label %26
45: ; preds = %26
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %47
47: ; preds = %45
%48 = load i32, i32* %6
%49 = add nsw i32 %48, 1
store i32 %49, i32* %6
br label %21
50: ; preds = %21
ret void
}

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