#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ free(char const **);
char *gu_str_table_get_cols(char const *, size_t, char const **);
size_t gu_str_table_get_n_cols(char const *);
size_t gu_str_table_get_n_rows(char const *);
char *gu_str_table_get_name(char const *);
int /*<<< orphan*/ gu_str_table_print_row(int /*<<< orphan*/ *, size_t,
                                          char const **);
char *gu_str_table_row_get(char const *, size_t, char const **);
char **malloc(size_t);
void gu_str_table_print(FILE *file, const char *str) {
  size_t i;
  size_t n_cols, n_rows;
  const char *ptr;
  char const **vec;
  fprintf(file, "%s\n", gu_str_table_get_name(str));
  n_cols = gu_str_table_get_n_cols(str);
  n_rows = gu_str_table_get_n_rows(str);
  vec = malloc(n_cols * sizeof(char *));
  ptr = gu_str_table_get_cols(str, n_cols, vec);
  gu_str_table_print_row(file, n_cols, vec);
  for (i = 0; i < n_rows; ++i) {
    ptr = gu_str_table_row_get(ptr, n_cols, vec);
    gu_str_table_print_row(file, n_cols, vec);
  }
  free(vec);
}


x86 assembly (clang, -O0):
<gu_str_table_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <gu_str_table_get_name@plt>
mov    -0x40(%rbp),%rdi
mov    %rax,%rdx
lea    0xe41(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1080 <gu_str_table_get_n_cols@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <gu_str_table_get_n_rows@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
shl    $0x3,%rdi
call   1090 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x38(%rbp),%rdx
call   10a0 <gu_str_table_get_cols@plt>
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x38(%rbp),%rdx
call   10b0 <gu_str_table_print_row@plt>
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x28(%rbp),%rax
jae    1262 <gu_str_table_print+0xd2>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x38(%rbp),%rdx
call   1050 <gu_str_table_row_get@plt>
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x38(%rbp),%rdx
call   10b0 <gu_str_table_print_row@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    121d <gu_str_table_print+0x8d>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gu_str_table_print>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r13
mov    %rdi,%r14
mov    %rsi,%rdi
call   1070 <gu_str_table_get_name@plt>
lea    0xe52(%rip),%rsi
mov    %r14,%rdi
mov    %rax,%rdx
call   1060 <fprintf@plt>
mov    %r13,%rdi
call   1080 <gu_str_table_get_n_cols@plt>
mov    %rax,%r15
mov    %r13,%rdi
call   1040 <gu_str_table_get_n_rows@plt>
mov    %rax,%rbx
lea    0x0(,%r15,8),%rdi
call   1090 <malloc@plt>
mov    %rax,%r12
mov    %r13,%rdi
mov    %r15,%rsi
mov    %rax,%rdx
call   10a0 <gu_str_table_get_cols@plt>
mov    %rax,%r13
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   10b0 <gu_str_table_print_row@plt>
test   %rbx,%rbx
je     1235 <gu_str_table_print+0xa5>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r13,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1050 <gu_str_table_row_get@plt>
mov    %rax,%r13
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   10b0 <gu_str_table_print_row@plt>
add    $0xffffffffffffffff,%rbx
jne    1210 <gu_str_table_print+0x80>
mov    %r12,%rdi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
define void @gu_str_table_print(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i8**
store i32* %0, i32** %3
store i8* %1, i8** %4
%10 = load i32*, i32** %3
%11 = load i8*, i8** %4
%12 = call i8* @gu_str_table_get_name(i8* %11)
%13 = call i32 @fprintf(i32* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = load i8*, i8** %4
%15 = call i64 @gu_str_table_get_n_cols(i8* %14)
store i64 %15, i64* %6
%16 = load i8*, i8** %4
%17 = call i64 @gu_str_table_get_n_rows(i8* %16)
store i64 %17, i64* %7
%18 = load i64, i64* %6
%19 = mul i64 %18, 8
%20 = call i8** @malloc(i64 %19)
store i8** %20, i8*** %9
%21 = load i8*, i8** %4
%22 = load i64, i64* %6
%23 = load i8**, i8*** %9
%24 = call i8* @gu_str_table_get_cols(i8* %21, i64 %22, i8** %23)
store i8* %24, i8** %8
%25 = load i32*, i32** %3
%26 = load i64, i64* %6
%27 = load i8**, i8*** %9
%28 = call i32 @gu_str_table_print_row(i32* %25, i64 %26, i8** %27)
store i64 0, i64* %5
br label %29
29: ; preds = %42, %2
%30 = load i64, i64* %5
%31 = load i64, i64* %7
%32 = icmp ult i64 %30, %31
br i1 %32, label %33, label %45
33: ; preds = %29
%34 = load i8*, i8** %8
%35 = load i64, i64* %6
%36 = load i8**, i8*** %9
%37 = call i8* @gu_str_table_row_get(i8* %34, i64 %35, i8** %36)
store i8* %37, i8** %8
%38 = load i32*, i32** %3
%39 = load i64, i64* %6
%40 = load i8**, i8*** %9
%41 = call i32 @gu_str_table_print_row(i32* %38, i64 %39, i8** %40)
br label %42
42: ; preds = %33
%43 = load i64, i64* %5
%44 = add i64 %43, 1
store i64 %44, i64* %5
br label %29
45: ; preds = %29
%46 = load i8**, i8*** %9
%47 = call i32 @free(i8** %46)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
define void @gu_str_table_print(i32* %0, i8* %1) {
%3 = tail call i8* @gu_str_table_get_name(i8* %1)
%4 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %3)
%5 = tail call i64 @gu_str_table_get_n_cols(i8* %1)
%6 = tail call i64 @gu_str_table_get_n_rows(i8* %1)
%7 = shl i64 %5, 3
%8 = tail call i8** @malloc(i64 %7)
%9 = tail call i8* @gu_str_table_get_cols(i8* %1, i64 %5, i8** %8)
%10 = tail call i32 @gu_str_table_print_row(i32* %0, i64 %5, i8** %8)
%11 = icmp eq i64 %6, 0
br i1 %11, label %19, label %12
12: ; preds = %2, %12
%13 = phi i64 [ %17, %12 ], [ 0, %2 ]
%14 = phi i8* [ %15, %12 ], [ %9, %2 ]
%15 = tail call i8* @gu_str_table_row_get(i8* %14, i64 %5, i8** %8)
%16 = tail call i32 @gu_str_table_print_row(i32* %0, i64 %5, i8** %8)
%17 = add nuw i64 %13, 1
%18 = icmp eq i64 %17, %6
br i1 %18, label %19, label %12
19: ; preds = %12, %2
%20 = tail call i32 @free(i8** %8)
ret void
}