#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 *);
void md_table_header(FILE *fw, int term, int cols) {
  int i;
  switch (term) {
  case 0:
    break;
  case 1:
    fprintf(fw, "<table border=\"1\">\n");
    break;
  case 2:
    fprintf(fw, "\\begin{tabular}{|");
    for (i = 0; i < cols; i++) {
      fprintf(fw, "r");
    }
    fprintf(fw, "|}\n\\hline\n");
    break;
  }
}


x86 assembly (clang, -O0):
<md_table_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
test   %eax,%eax
je     1157 <md_table_header+0x47>
jmp    1135 <md_table_header+0x25>
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
je     115c <md_table_header+0x4c>
jmp    1146 <md_table_header+0x36>
mov    -0x18(%rbp),%eax
sub    $0x2,%eax
je     1171 <md_table_header+0x61>
jmp    11c2 <md_table_header+0xb2>
jmp    11c2 <md_table_header+0xb2>
mov    -0x8(%rbp),%rdi
lea    0xe99(%rip),%rsi
call   1030 <fprintf@plt>
jmp    11c2 <md_table_header+0xb2>
mov    -0x8(%rbp),%rdi
lea    0xe98(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11b2 <md_table_header+0xa2>
mov    -0x8(%rbp),%rdi
lea    0xe87(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1188 <md_table_header+0x78>
mov    -0x8(%rbp),%rdi
lea    0xe6b(%rip),%rsi
call   1030 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<md_table_header>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
cmp    $0x2,%esi
je     113e <md_table_header+0x1e>
cmp    $0x1,%esi
jne    1191 <md_table_header+0x71>
lea    0xec9(%rip),%rdi
mov    $0x13,%esi
jmp    117e <md_table_header+0x5e>
mov    %edx,%ebp
lea    0xecd(%rip),%rdi
mov    $0x11,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fwrite@plt>
test   %ebp,%ebp
jle    1172 <md_table_header+0x52>
nopl   (%rax)
mov    $0x72,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
add    $0xffffffff,%ebp
jne    1160 <md_table_header+0x40>
lea    0xead(%rip),%rdi
mov    $0xa,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <fwrite@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"<table border=\221\22>\0A\00"
@.str.1 = [18 x i8] c"\\begin{tabular}{|\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [11 x i8] c"|}\0A\\hline\0A\00"
define void @md_table_header(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %5
switch i32 %8, label %29 [
i32 0, label %9
i32 1, label %10
i32 2, label %13
]
9: ; preds = %3
br label %29
10: ; preds = %3
%11 = load i32*, i32** %4
%12 = call i32 @fprintf(i32* %11, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %29
13: ; preds = %3
%14 = load i32*, i32** %4
%15 = call i32 @fprintf(i32* %14, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %7
br label %16
16: ; preds = %23, %13
%17 = load i32, i32* %7
%18 = load i32, i32* %6
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %26
20: ; preds = %16
%21 = load i32*, i32** %4
%22 = call i32 @fprintf(i32* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %23
23: ; preds = %20
%24 = load i32, i32* %7
%25 = add nsw i32 %24, 1
store i32 %25, i32* %7
br label %16
26: ; preds = %16
%27 = load i32*, i32** %4
%28 = call i32 @fprintf(i32* %27, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
br label %29
29: ; preds = %3, %26, %10, %9
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"<table border=\221\22>\0A\00"
@.str.1 = [18 x i8] c"\\begin{tabular}{|\00"
@.str.3 = [11 x i8] c"|}\0A\\hline\0A\00"
define void @md_table_header(i32* nocapture %0, i32 %1, i32 %2) {
switch i32 %1, label %16 [
i32 2, label %6
i32 1, label %4
]
4: ; preds = %3
%5 = tail call i64 @fwrite(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i64 19, i64 1, i32* %0)
br label %16
6: ; preds = %3
%7 = tail call i64 @fwrite(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i64 17, i64 1, i32* %0)
%8 = icmp sgt i32 %2, 0
br i1 %8, label %9, label %14
9: ; preds = %6, %9
%10 = phi i32 [ %12, %9 ], [ 0, %6 ]
%11 = tail call i32 @fputc(i32 114, i32* %0)
%12 = add nuw nsw i32 %10, 1
%13 = icmp eq i32 %12, %2
br i1 %13, label %14, label %9
14: ; preds = %9, %6
%15 = tail call i64 @fwrite(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i64 10, i64 1, i32* %0)
br label %16
16: ; preds = %3, %14, %4
ret void
}