#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 *, ...);
int strlen(char *);
void md_header_2(FILE *fw, int term, char *header) {
  int i;
  switch (term) {
  case 0:
    fprintf(fw, " %s \n ", header);
    for (i = 0; i < strlen(header); i++) {
      fprintf(fw, "-");
    }
    fprintf(fw, "\n\n");
    break;
  case 1:
    fprintf(fw, "<h2>%s</h2>\n\n", header);
    break;
  case 2:
    fprintf(fw, "\\subsection*{%s}\n\n", header);
    break;
  }
}


x86 assembly (clang, -O0):
<md_header_2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x20(%rbp)
test   %eax,%eax
je     1168 <md_header_2+0x48>
jmp    1146 <md_header_2+0x26>
mov    -0x20(%rbp),%eax
sub    $0x1,%eax
je     11d8 <md_header_2+0xb8>
jmp    1157 <md_header_2+0x37>
mov    -0x20(%rbp),%eax
sub    $0x2,%eax
je     11f3 <md_header_2+0xd3>
jmp    1209 <md_header_2+0xe9>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe89(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cmp    %ecx,%eax
jge    11c1 <md_header_2+0xa1>
mov    -0x8(%rbp),%rdi
lea    0xe5b(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1185 <md_header_2+0x65>
mov    -0x8(%rbp),%rdi
lea    0xe48(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    1209 <md_header_2+0xe9>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe22(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    1209 <md_header_2+0xe9>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe15(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<md_header_2>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%rbx
mov    %rdi,%r14
cmp    $0x2,%esi
je     11b9 <md_header_2+0x79>
cmp    $0x1,%esi
je     11c2 <md_header_2+0x82>
test   %esi,%esi
jne    11da <md_header_2+0x9a>
lea    0xe9d(%rip),%rsi
xor    %ebp,%ebp
mov    %r14,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    119c <md_header_2+0x5c>
xchg   %ax,%ax
mov    $0x2d,%edi
mov    %r14,%rsi
call   1040 <fputc@plt>
add    $0x1,%ebp
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    %eax,%ebp
jl     1180 <md_header_2+0x40>
lea    0xe6f(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r14,%rcx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1060 <fwrite@plt>
lea    0xe55(%rip),%rsi
jmp    11c9 <md_header_2+0x89>
lea    0xe3e(%rip),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <fprintf@plt>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c" %s \0A \00"
@.str.1 = [2 x i8] c"-\00"
@.str.2 = [3 x i8] c"\0A\0A\00"
@.str.3 = [14 x i8] c"<h2>%s</h2>\0A\0A\00"
@.str.4 = [19 x i8] c"\\subsection*{%s}\0A\0A\00"
define void @md_header_2(i32* %0, i32 %1, i8* %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%8 = load i32, i32* %5
switch i32 %8, label %35 [
i32 0, label %9
i32 1, label %27
i32 2, label %31
]
9: ; preds = %3
%10 = load i32*, i32** %4
%11 = load i8*, i8** %6
%12 = call i32 (i32*, i8*, ...) @fprintf(i32* %10, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %11)
store i32 0, i32* %7
br label %13
13: ; preds = %21, %9
%14 = load i32, i32* %7
%15 = load i8*, i8** %6
%16 = call i32 @strlen(i8* %15)
%17 = icmp slt i32 %14, %16
br i1 %17, label %18, label %24
18: ; preds = %13
%19 = load i32*, i32** %4
%20 = call i32 (i32*, i8*, ...) @fprintf(i32* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %21
21: ; preds = %18
%22 = load i32, i32* %7
%23 = add nsw i32 %22, 1
store i32 %23, i32* %7
br label %13
24: ; preds = %13
%25 = load i32*, i32** %4
%26 = call i32 (i32*, i8*, ...) @fprintf(i32* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %35
27: ; preds = %3
%28 = load i32*, i32** %4
%29 = load i8*, i8** %6
%30 = call i32 (i32*, i8*, ...) @fprintf(i32* %28, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %29)
br label %35
31: ; preds = %3
%32 = load i32*, i32** %4
%33 = load i8*, i8** %6
%34 = call i32 (i32*, i8*, ...) @fprintf(i32* %32, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %33)
br label %35
35: ; preds = %3, %31, %27, %24
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c" %s \0A \00"
@.str.2 = [3 x i8] c"\0A\0A\00"
@.str.3 = [14 x i8] c"<h2>%s</h2>\0A\0A\00"
@.str.4 = [19 x i8] c"\\subsection*{%s}\0A\0A\00"
define void @md_header_2(i32* nocapture %0, i32 %1, i8* %2) {
switch i32 %1, label %20 [
i32 0, label %4
i32 1, label %16
i32 2, label %18
]
4: ; preds = %3
%5 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %2)
%6 = tail call i32 @strlen(i8* %2)
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %14
8: ; preds = %4, %8
%9 = phi i32 [ %11, %8 ], [ 0, %4 ]
%10 = tail call i32 @fputc(i32 45, i32* %0)
%11 = add nuw nsw i32 %9, 1
%12 = tail call i32 @strlen(i8* %2)
%13 = icmp slt i32 %11, %12
br i1 %13, label %8, label %14
14: ; preds = %8, %4
%15 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i64 2, i64 1, i32* %0)
br label %20
16: ; preds = %3
%17 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %2)
br label %20
18: ; preds = %3
%19 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %2)
br label %20
20: ; preds = %3, %18, %16, %14
ret void
}