#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_file_end(FILE *fw, int term) {
  switch (term) {
  case 0:
    fprintf(fw, "\n");
    break;
  case 1:
    fprintf(fw, "</body>\n");
    fprintf(fw, "</html>\n");
    break;
  case 2:
    fprintf(fw, "\\end{document}\n");
    break;
  }
}


x86 assembly (clang, -O0):
<md_file_end>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
test   %eax,%eax
je     1154 <md_file_end+0x44>
jmp    1132 <md_file_end+0x22>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
je     1169 <md_file_end+0x59>
jmp    1143 <md_file_end+0x33>
mov    -0x10(%rbp),%eax
sub    $0x2,%eax
je     118e <md_file_end+0x7e>
jmp    119e <md_file_end+0x8e>
mov    -0x8(%rbp),%rdi
lea    0xeb1(%rip),%rsi
call   1030 <fprintf@plt>
jmp    119e <md_file_end+0x8e>
mov    -0x8(%rbp),%rdi
lea    0xe8c(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xe85(%rip),%rsi
call   1030 <fprintf@plt>
jmp    119e <md_file_end+0x8e>
mov    -0x8(%rbp),%rdi
lea    0xe79(%rip),%rsi
call   1030 <fprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<md_file_end>:
push   %rbx
mov    %rdi,%rbx
cmp    $0x2,%esi
je     1140 <md_file_end+0x20>
cmp    $0x1,%esi
je     114e <md_file_end+0x2e>
test   %esi,%esi
jne    1181 <md_file_end+0x61>
mov    $0xa,%edi
mov    %rbx,%rsi
pop    %rbx
jmp    1030 <fputc@plt>
lea    0xecb(%rip),%rdi
mov    $0xf,%esi
jmp    1173 <md_file_end+0x53>
lea    0xeab(%rip),%rdi
mov    $0x8,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fwrite@plt>
lea    0xe9b(%rip),%rdi
mov    $0x8,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
pop    %rbx
jmp    1040 <fwrite@plt>
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [9 x i8] c"</body>\0A\00"
@.str.2 = [9 x i8] c"</html>\0A\00"
@.str.3 = [16 x i8] c"\\end{document}\0A\00"
define void @md_file_end(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
switch i32 %5, label %17 [
i32 0, label %6
i32 1, label %9
i32 2, label %14
]
6: ; preds = %2
%7 = load i32*, i32** %3
%8 = call i32 @fprintf(i32* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %17
9: ; preds = %2
%10 = load i32*, i32** %3
%11 = call i32 @fprintf(i32* %10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%12 = load i32*, i32** %3
%13 = call i32 @fprintf(i32* %12, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %17
14: ; preds = %2
%15 = load i32*, i32** %3
%16 = call i32 @fprintf(i32* %15, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %17
17: ; preds = %2, %14, %9, %6
ret void
}

LLVM IR (-O2):
@.str.1 = [9 x i8] c"</body>\0A\00"
@.str.2 = [9 x i8] c"</html>\0A\00"
@.str.3 = [16 x i8] c"\\end{document}\0A\00"
define void @md_file_end(i32* nocapture %0, i32 %1) {
switch i32 %1, label %10 [
i32 0, label %3
i32 1, label %5
i32 2, label %8
]
3: ; preds = %2
%4 = tail call i32 @fputc(i32 10, i32* %0)
br label %10
5: ; preds = %2
%6 = tail call i64 @fwrite(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i64 8, i64 1, i32* %0)
%7 = tail call i64 @fwrite(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i64 8, i64 1, i32* %0)
br label %10
8: ; preds = %2
%9 = tail call i64 @fwrite(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i64 15, i64 1, i32* %0)
br label %10
10: ; preds = %2, %8, %5, %3
ret void
}