// File: /workspace/github_c_makefile_star2_O0/georgeweigt[P]sassafras/sassafras.c
// Function: print_table
void
print_table(char **a, int nrow, int ncol, char *fmt)
{
	int c, i, j, k, n, nsp = 0, t, *w;
	char *b, *buf, *s;

	w = (int *) xmalloc(ncol * sizeof (int));

	// measure column widths

	t = 0;

	for (j = 0; j < ncol; j++) {
		w[j] = 0;
		for (i = 0; i < nrow; i++) {
			s = A(i, j);
			if (s == NULL)
				continue;
			n = (int) strlen(s);
			if (n > w[j])
				w[j] = n;
		}
		t += w[j];
	}

	// spaces between columns

	if (ncol > 1) {
		nsp = (80 - t) / (ncol - 1);
		if (nsp < 2)
			nsp = 2;
		if (nsp > 5)
			nsp = 5;
		t += (ncol - 1) * nsp;
	}

	// number of spaces to center the line

	if (t < 80)
		c = (80 - t) / 2;
	else
		c = 0;

	// alloc line buffer

	buf = (char *) xmalloc(c + t + 1);

	// leading spaces

	memset(buf, ' ', c);

	// for each row

	for (i = 0; i < nrow; i++) {

		b = buf + c;

		// for each column

		for (j = 0; j < ncol; j++) {

			// space between columns

			if (j > 0) {
				memset(b, ' ', nsp);
				b += nsp;
			}

			s = A(i, j);

			if (s == NULL) {
				memset(b, ' ', w[j]);
				b += w[j];
			} else {

				n = (int) strlen(s);

				k = w[j] - n;

				switch (fmt[j]) {

				// right aligned

				case 0:
					memset(b, ' ', k);
					b += k;
					strcpy(b, s);
					b += n;
					break;

				// left aligned

				case 1:
					strcpy(b, s);
					b += n;
					memset(b, ' ', k);
					b += k;
					break;
				}
			}
		}

		*b = 0;

		emit_line(buf);
	}

	free(buf);
	free(w);

	emit_line("");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movl $0x0, -0x30(%rbp)
movslq -0x10(%rbp), %rax
shlq $0x2, %rax
movl %eax, %edi
callq 0x2da0
movq %rax, -0x40(%rbp)
movl $0x0, -0x34(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x10(%rbp), %eax
jge 0x5568
movq -0x40(%rbp), %rax
movslq -0x24(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x5549
movq -0x8(%rbp), %rax
movl -0x20(%rbp), %ecx
imull -0x10(%rbp), %ecx
movslq %ecx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
jne 0x5512
jmp 0x553e
movq -0x58(%rbp), %rdi
callq 0x2090
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq -0x40(%rbp), %rcx
movslq -0x24(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jle 0x553c
movl -0x2c(%rbp), %edx
movq -0x40(%rbp), %rax
movslq -0x24(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x553e
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x54e0
movq -0x40(%rbp), %rax
movslq -0x24(%rbp), %rcx
movl (%rax,%rcx,4), %eax
addl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x54be
cmpl $0x1, -0x10(%rbp)
jle 0x55ac
movl $0x50, %eax
subl -0x34(%rbp), %eax
movl -0x10(%rbp), %ecx
subl $0x1, %ecx
cltd
idivl %ecx
movl %eax, -0x30(%rbp)
cmpl $0x2, -0x30(%rbp)
jge 0x558f
movl $0x2, -0x30(%rbp)
cmpl $0x5, -0x30(%rbp)
jle 0x559c
movl $0x5, -0x30(%rbp)
movl -0x10(%rbp), %eax
subl $0x1, %eax
imull -0x30(%rbp), %eax
addl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
cmpl $0x50, -0x34(%rbp)
jge 0x55c7
movl $0x50, %eax
subl -0x34(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x1c(%rbp)
jmp 0x55ce
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %edi
addl -0x34(%rbp), %edi
addl $0x1, %edi
callq 0x2da0
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
movslq -0x1c(%rbp), %rdx
movl $0x20, %esi
callq 0x20e0
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x57a5
movq -0x50(%rbp), %rax
movslq -0x1c(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x10(%rbp), %eax
jge 0x5787
cmpl $0x0, -0x24(%rbp)
jle 0x5650
movq -0x48(%rbp), %rdi
movslq -0x30(%rbp), %rdx
movl $0x20, %esi
callq 0x20e0
movl -0x30(%rbp), %ecx
movq -0x48(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rax
movl -0x20(%rbp), %ecx
imull -0x10(%rbp), %ecx
movslq %ecx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
jne 0x56b0
movq -0x48(%rbp), %rdi
movq -0x40(%rbp), %rax
movslq -0x24(%rbp), %rcx
movslq (%rax,%rcx,4), %rdx
movl $0x20, %esi
callq 0x20e0
movq -0x40(%rbp), %rax
movslq -0x24(%rbp), %rcx
movl (%rax,%rcx,4), %ecx
movq -0x48(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
jmp 0x5777
movq -0x58(%rbp), %rdi
callq 0x2090
movl %eax, -0x2c(%rbp)
movq -0x40(%rbp), %rax
movslq -0x24(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl -0x2c(%rbp), %ecx
subl %ecx, %eax
movl %eax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movl %eax, -0x5c(%rbp)
testl %eax, %eax
je 0x56f1
jmp 0x56e4
movl -0x5c(%rbp), %eax
subl $0x1, %eax
je 0x5734
jmp 0x5775
movq -0x48(%rbp), %rdi
movslq -0x28(%rbp), %rdx
movl $0x20, %esi
callq 0x20e0
movl -0x28(%rbp), %ecx
movq -0x48(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0x2040
movl -0x2c(%rbp), %ecx
movq -0x48(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
jmp 0x5775
movq -0x48(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0x2040
movl -0x2c(%rbp), %ecx
movq -0x48(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
movslq -0x28(%rbp), %rdx
movl $0x20, %esi
callq 0x20e0
movl -0x28(%rbp), %ecx
movq -0x48(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
jmp 0x5777
jmp 0x5779
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x561b
movq -0x48(%rbp), %rax
movb $0x0, (%rax)
movq -0x50(%rbp), %rdi
callq 0x4bf0
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x55f9
movq -0x50(%rbp), %rdi
callq 0x2030
movq -0x40(%rbp), %rdi
callq 0x2030
leaq 0x9c21(%rip), %rdi      # 0xf3df
callq 0x4bf0
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)