#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 /*<<< orphan*/ printf(char *, ...);
void print_table(int history[][6], int day) {
  printf("Day | Money | Pots | Boats | Pots in | Pots out | Money earned | "
         "Weather\n");
  int i;
  for (i = 1; i <= day; i++) {
    int money = history[i - 1][1];
    int pots = history[i - 1][2];
    int boats = history[i - 1][3];
    int pots_in = history[i - 1][4];
    int money_earned = history[i - 1][5];
    int weather = history[i - 1][6];
    printf("\x1B[0m"
           "%3d | %5d | %4d | %5d | ",
           i, money, pots, boats);
    if (pots_in == -1) {
      printf("%7c | ", '-');
      printf("%8c | ", '-');
    } else {
      printf("%7d | ", pots_in);
      printf("%8d | ", pots - pots_in);
    }
    if (money_earned == -1) {
      printf("%12c", '-');
    } else {
      printf("%12d", money_earned);
    }
    if (weather == -1) {
      printf("%7c\n", '-');
    } else if (weather == 0) {
      printf("\x1B[1;31m"
             "%7s\n",
             "Bad");
    } else {
      printf("\x1B[1;36m"
             "%7s\n",
             "Good");
    }
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<print_table>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     12f7 <print_table+0x1e7>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
mov    0x4(%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
mov    0x8(%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
mov    0xc(%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
mov    0x10(%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
mov    0x14(%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
mov    0x18(%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0xffffffff,-0x20(%rbp)
jne    122c <print_table+0x11c>
lea    0xe5f(%rip),%rdi
mov    $0x2d,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe53(%rip),%rdi
mov    $0x2d,%esi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1251 <print_table+0x141>
mov    -0x20(%rbp),%esi
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
sub    -0x20(%rbp),%esi
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0xffffffff,-0x24(%rbp)
jne    1273 <print_table+0x163>
lea    0xe21(%rip),%rdi
mov    $0x2d,%esi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1284 <print_table+0x174>
mov    -0x24(%rbp),%esi
lea    0xe0b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0xffffffff,-0x28(%rbp)
jne    12a6 <print_table+0x196>
lea    0xdf8(%rip),%rdi
mov    $0x2d,%esi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12e4 <print_table+0x1d4>
cmpl   $0x0,-0x28(%rbp)
jne    12ca <print_table+0x1ba>
lea    0xddb(%rip),%rdi
lea    0xde0(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12df <print_table+0x1cf>
lea    0xdd1(%rip),%rdi
lea    0xdd6(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12e4 <print_table+0x1d4>
jmp    12e9 <print_table+0x1d9>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1134 <print_table+0x24>
lea    0xd92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
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    %esi,%ebp
mov    %rdi,%rbx
lea    0xf22(%rip),%rdi
call   1040 <puts@plt>
mov    %rbp,(%rsp)
test   %ebp,%ebp
jle    1283 <print_table+0x153>
mov    (%rsp),%rax
add    $0x1,%eax
mov    %rax,(%rsp)
add    $0x18,%rbx
mov    $0x1,%r15d
jmp    1197 <print_table+0x67>
nop
lea    0xee1(%rip),%rdi
lea    0xee6(%rip),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%r15
add    $0x18,%rbx
cmp    %r15,(%rsp)
je     1283 <print_table+0x153>
mov    -0x14(%rbx),%edx
mov    -0x10(%rbx),%ebp
mov    -0xc(%rbx),%r8d
mov    -0x8(%rbx),%r12d
mov    -0x4(%rbx),%r13d
mov    (%rbx),%r14d
lea    0xe4d(%rip),%rdi
mov    %r15d,%esi
mov    %ebp,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0xffffffff,%r12d
je     11f0 <print_table+0xc0>
lea    0xe5f(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
sub    %r12d,%ebp
lea    0xe52(%rip),%rdi
mov    %ebp,%esi
jmp    120f <print_table+0xdf>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0xe26(%rip),%rdi
mov    $0x2d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe1a(%rip),%rdi
mov    $0x2d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0xffffffff,%r13d
je     1230 <print_table+0x100>
lea    0xe1b(%rip),%rdi
mov    %r13d,%esi
jmp    123c <print_table+0x10c>
nopl   0x0(%rax,%rax,1)
lea    0xe02(%rip),%rdi
mov    $0x2d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
test   %r14d,%r14d
je     1270 <print_table+0x140>
cmp    $0xffffffff,%r14d
jne    1170 <print_table+0x40>
lea    0xdea(%rip),%rdi
mov    $0x2d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1185 <print_table+0x55>
nopw   0x0(%rax,%rax,1)
lea    0xdd1(%rip),%rdi
lea    0xdd6(%rip),%rsi
jmp    117e <print_table+0x4e>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [74 x i8] c"Day | Money | Pots | Boats | Pots in | Pots out | Money earned | Weather\0A\00"
@.str.1 = [29 x i8] c"\1B[0m%3d | %5d | %4d | %5d | \00"
@.str.2 = [7 x i8] c"%7c | \00"
@.str.3 = [7 x i8] c"%8c | \00"
@.str.4 = [7 x i8] c"%7d | \00"
@.str.5 = [7 x i8] c"%8d | \00"
@.str.6 = [5 x i8] c"%12c\00"
@.str.7 = [5 x i8] c"%12d\00"
@.str.8 = [5 x i8] c"%7c\0A\00"
@.str.9 = [12 x i8] c"\1B[1;31m%7s\0A\00"
@.str.10 = [4 x i8] c"Bad\00"
@.str.11 = [12 x i8] c"\1B[1;36m%7s\0A\00"
@.str.12 = [5 x i8] c"Good\00"
@.str.13 = [2 x i8] c"\0A\00"
define void @print_table([6 x i32]* %0, i32 %1) {
%3 = alloca [6 x i32]*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store [6 x i32]* %0, [6 x i32]** %3
store i32 %1, i32* %4
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %5
br label %13
13: ; preds = %99, %2
%14 = load i32, i32* %5
%15 = load i32, i32* %4
%16 = icmp sle i32 %14, %15
br i1 %16, label %17, label %102
17: ; preds = %13
%18 = load [6 x i32]*, [6 x i32]** %3
%19 = load i32, i32* %5
%20 = sub nsw i32 %19, 1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [6 x i32], [6 x i32]* %18, i64 %21
%23 = getelementptr inbounds [6 x i32], [6 x i32]* %22, i64 0, i64 1
%24 = load i32, i32* %23
store i32 %24, i32* %6
%25 = load [6 x i32]*, [6 x i32]** %3
%26 = load i32, i32* %5
%27 = sub nsw i32 %26, 1
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [6 x i32], [6 x i32]* %25, i64 %28
%30 = getelementptr inbounds [6 x i32], [6 x i32]* %29, i64 0, i64 2
%31 = load i32, i32* %30
store i32 %31, i32* %7
%32 = load [6 x i32]*, [6 x i32]** %3
%33 = load i32, i32* %5
%34 = sub nsw i32 %33, 1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [6 x i32], [6 x i32]* %32, i64 %35
%37 = getelementptr inbounds [6 x i32], [6 x i32]* %36, i64 0, i64 3
%38 = load i32, i32* %37
store i32 %38, i32* %8
%39 = load [6 x i32]*, [6 x i32]** %3
%40 = load i32, i32* %5
%41 = sub nsw i32 %40, 1
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [6 x i32], [6 x i32]* %39, i64 %42
%44 = getelementptr inbounds [6 x i32], [6 x i32]* %43, i64 0, i64 4
%45 = load i32, i32* %44
store i32 %45, i32* %9
%46 = load [6 x i32]*, [6 x i32]** %3
%47 = load i32, i32* %5
%48 = sub nsw i32 %47, 1
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [6 x i32], [6 x i32]* %46, i64 %49
%51 = getelementptr inbounds [6 x i32], [6 x i32]* %50, i64 0, i64 5
%52 = load i32, i32* %51
store i32 %52, i32* %10
%53 = load [6 x i32]*, [6 x i32]** %3
%54 = load i32, i32* %5
%55 = sub nsw i32 %54, 1
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [6 x i32], [6 x i32]* %53, i64 %56
%58 = getelementptr inbounds [6 x i32], [6 x i32]* %57, i64 0, i64 6
%59 = load i32, i32* %58
store i32 %59, i32* %11
%60 = load i32, i32* %5
%61 = load i32, i32* %6
%62 = load i32, i32* %7
%63 = load i32, i32* %8
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %60, i32 %61, i32 %62, i32 %63)
%65 = load i32, i32* %9
%66 = icmp eq i32 %65, -1
br i1 %66, label %67, label %70
67: ; preds = %17
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 45)
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 45)
br label %77
70: ; preds = %17
%71 = load i32, i32* %9
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %71)
%73 = load i32, i32* %7
%74 = load i32, i32* %9
%75 = sub nsw i32 %73, %74
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 %75)
br label %77
77: ; preds = %70, %67
%78 = load i32, i32* %10
%79 = icmp eq i32 %78, -1
br i1 %79, label %80, label %82
80: ; preds = %77
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 45)
br label %85
82: ; preds = %77
%83 = load i32, i32* %10
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 %83)
br label %85
85: ; preds = %82, %80
%86 = load i32, i32* %11
%87 = icmp eq i32 %86, -1
br i1 %87, label %88, label %90
88: ; preds = %85
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i32 45)
br label %98
90: ; preds = %85
%91 = load i32, i32* %11
%92 = icmp eq i32 %91, 0
br i1 %92, label %93, label %95
93: ; preds = %90
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0))
br label %97
95: ; preds = %90
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0))
br label %97
97: ; preds = %95, %93
br label %98
98: ; preds = %97, %88
br label %99
99: ; preds = %98
%100 = load i32, i32* %5
%101 = add nsw i32 %100, 1
store i32 %101, i32* %5
br label %13
102: ; preds = %13
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.1 = [29 x i8] c"\1B[0m%3d | %5d | %4d | %5d | \00"
@.str.2 = [7 x i8] c"%7c | \00"
@.str.3 = [7 x i8] c"%8c | \00"
@.str.4 = [7 x i8] c"%7d | \00"
@.str.5 = [7 x i8] c"%8d | \00"
@.str.6 = [5 x i8] c"%12c\00"
@.str.7 = [5 x i8] c"%12d\00"
@.str.8 = [5 x i8] c"%7c\0A\00"
@.str.9 = [12 x i8] c"\1B[1;31m%7s\0A\00"
@.str.10 = [4 x i8] c"Bad\00"
@.str.11 = [12 x i8] c"\1B[1;36m%7s\0A\00"
@.str.12 = [5 x i8] c"Good\00"
@str = [73 x i8] c"Day | Money | Pots | Boats | Pots in | Pots out | Money earned | Weather\00"
define void @print_table([6 x i32]* nocapture %0, i32 %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([73 x i8], [73 x i8]* @str, i64 0, i64 0))
%4 = icmp slt i32 %1, 1
br i1 %4, label %49, label %5
5: ; preds = %2
%6 = add nuw i32 %1, 1
%7 = zext i32 %6 to i64
br label %8
8: ; preds = %5, %46
%9 = phi i64 [ 1, %5 ], [ %47, %46 ]
%10 = add nsw i64 %9, -1
%11 = getelementptr inbounds [6 x i32], [6 x i32]* %0, i64 %10, i64 1
%12 = load i32, i32* %11
%13 = getelementptr inbounds [6 x i32], [6 x i32]* %0, i64 %10, i64 2
%14 = load i32, i32* %13
%15 = getelementptr inbounds [6 x i32], [6 x i32]* %0, i64 %10, i64 3
%16 = load i32, i32* %15
%17 = getelementptr inbounds [6 x i32], [6 x i32]* %0, i64 %10, i64 4
%18 = load i32, i32* %17
%19 = getelementptr inbounds [6 x i32], [6 x i32]* %0, i64 %10, i64 5
%20 = load i32, i32* %19
%21 = getelementptr inbounds [6 x i32], [6 x i32]* %0, i64 %10, i64 6
%22 = load i32, i32* %21
%23 = trunc i64 %9 to i32
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %23, i32 %12, i32 %14, i32 %16)
%25 = icmp eq i32 %18, -1
br i1 %25, label %26, label %29
26: ; preds = %8
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 45)
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 45)
br label %33
29: ; preds = %8
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %18)
%31 = sub nsw i32 %14, %18
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 %31)
br label %33
33: ; preds = %29, %26
%34 = icmp eq i32 %20, -1
br i1 %34, label %35, label %37
35: ; preds = %33
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 45)
br label %39
37: ; preds = %33
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 %20)
br label %39
39: ; preds = %37, %35
switch i32 %22, label %44 [
i32 -1, label %40
i32 0, label %42
]
40: ; preds = %39
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i32 45)
br label %46
42: ; preds = %39
%43 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0))
br label %46
44: ; preds = %39
%45 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0))
br label %46
46: ; preds = %42, %44, %40
%47 = add nuw nsw i64 %9, 1
%48 = icmp eq i64 %47, %7
br i1 %48, label %49, label %8
49: ; preds = %46, %2
%50 = tail call i32 @putchar(i32 10)
ret void
}