#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*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ latin1_json(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ latin1_utf8(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ utf8_latin1(int /*<<< orphan*/, int /*<<< orphan*/);
int main(int argc, char **argv) {
  if (argc > 1) {
    if (strcmp(argv[1], "latin1_utf8") == 0) {
      latin1_utf8(stdin, stdout);
    } else if (strcmp(argv[1], "latin1_json") == 0) {
      latin1_json(stdin, stdout);
    } else if (strcmp(argv[1], "utf8_latin1") == 0) {
      utf8_latin1(stdin, stdout);
    } else {
      fprintf(stderr, "Unknown function '%s'\n", argv[1]);
    }
  } else {
    fprintf(stderr, "Usage: %s FUNCTION\n", argv[0]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    124a <main+0xfa>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe81(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11aa <main+0x5a>
mov    0x2e53(%rip),%rax
mov    (%rax),%edi
mov    0x2e32(%rip),%rax
mov    (%rax),%esi
call   1070 <latin1_utf8@plt>
jmp    1245 <main+0xf5>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe53(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11e4 <main+0x94>
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
mov    0x2df8(%rip),%rax
mov    (%rax),%esi
call   1040 <latin1_json@plt>
jmp    1240 <main+0xf0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe25(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    121e <main+0xce>
mov    0x2ddf(%rip),%rax
mov    (%rax),%edi
mov    0x2dbe(%rip),%rax
mov    (%rax),%esi
call   1030 <utf8_latin1@plt>
jmp    123b <main+0xeb>
mov    0x2db3(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xdee(%rip),%rsi
call   1060 <fprintf@plt>
jmp    1240 <main+0xf0>
jmp    1245 <main+0xf5>
jmp    1266 <main+0x116>
mov    0x2d87(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdda(%rip),%rsi
call   1060 <fprintf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
cmp    $0x2,%edi
jl     11ae <main+0x5e>
mov    0x8(%rbx),%rdi
lea    0xe9c(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11c8 <main+0x78>
mov    0x8(%rbx),%rdi
lea    0xe93(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11e1 <main+0x91>
mov    0x8(%rbx),%rdi
lea    0xe8a(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11fa <main+0xaa>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xe78(%rip),%rsi
jmp    11c1 <main+0x71>
mov    0x2e23(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe7a(%rip),%rsi
call   1060 <fprintf@plt>
jmp    1211 <main+0xc1>
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
mov    0x2df8(%rip),%rax
mov    (%rax),%esi
call   1070 <latin1_utf8@plt>
jmp    1211 <main+0xc1>
mov    0x2e00(%rip),%rax
mov    (%rax),%edi
mov    0x2ddf(%rip),%rax
mov    (%rax),%esi
call   1040 <latin1_json@plt>
jmp    1211 <main+0xc1>
mov    0x2de7(%rip),%rax
mov    (%rax),%edi
mov    0x2dc6(%rip),%rax
mov    (%rax),%esi
call   1030 <utf8_latin1@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [12 x i8] c"latin1_utf8\00"
@stdin = global i32 0
@stdout = global i32 0
@.str.1 = [12 x i8] c"latin1_json\00"
@.str.2 = [12 x i8] c"utf8_latin1\00"
@stderr = global i32 0
@.str.3 = [23 x i8] c"Unknown function '%s'\0A\00"
@.str.4 = [20 x i8] c"Usage: %s FUNCTION\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp sgt i32 %6, 1
br i1 %7, label %8, label %47
8: ; preds = %2
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %8
%15 = load i32, i32* @stdin
%16 = load i32, i32* @stdout
%17 = call i32 @latin1_utf8(i32 %15, i32 %16)
br label %46
18: ; preds = %8
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %28
24: ; preds = %18
%25 = load i32, i32* @stdin
%26 = load i32, i32* @stdout
%27 = call i32 @latin1_json(i32 %25, i32 %26)
br label %45
28: ; preds = %18
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = call i64 @strcmp(i8* %31, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %38
34: ; preds = %28
%35 = load i32, i32* @stdin
%36 = load i32, i32* @stdout
%37 = call i32 @utf8_latin1(i32 %35, i32 %36)
br label %44
38: ; preds = %28
%39 = load i32, i32* @stderr
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 1
%42 = load i8*, i8** %41
%43 = call i32 @fprintf(i32 %39, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %42)
br label %44
44: ; preds = %38, %34
br label %45
45: ; preds = %44, %24
br label %46
46: ; preds = %45, %14
br label %53
47: ; preds = %2
%48 = load i32, i32* @stderr
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 0
%51 = load i8*, i8** %50
%52 = call i32 @fprintf(i32 %48, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* %51)
br label %53
53: ; preds = %47, %46
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"latin1_utf8\00"
@stdin = global i32 0
@stdout = global i32 0
@.str.1 = [12 x i8] c"latin1_json\00"
@.str.2 = [12 x i8] c"utf8_latin1\00"
@stderr = global i32 0
@.str.3 = [23 x i8] c"Unknown function '%s'\0A\00"
@.str.4 = [20 x i8] c"Usage: %s FUNCTION\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %33
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %4
%10 = load i32, i32* @stdin
%11 = load i32, i32* @stdout
%12 = tail call i32 @latin1_utf8(i32 %10, i32 %11)
br label %37
13: ; preds = %4
%14 = load i8*, i8** %5
%15 = tail call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %13
%18 = load i32, i32* @stdin
%19 = load i32, i32* @stdout
%20 = tail call i32 @latin1_json(i32 %18, i32 %19)
br label %37
21: ; preds = %13
%22 = load i8*, i8** %5
%23 = tail call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %21
%26 = load i32, i32* @stdin
%27 = load i32, i32* @stdout
%28 = tail call i32 @utf8_latin1(i32 %26, i32 %27)
br label %37
29: ; preds = %21
%30 = load i32, i32* @stderr
%31 = load i8*, i8** %5
%32 = tail call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %31)
br label %37
33: ; preds = %2
%34 = load i32, i32* @stderr
%35 = load i8*, i8** %1
%36 = tail call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* %35)
br label %37
37: ; preds = %9, %25, %29, %17, %33
ret i32 0
}