#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 hk_init(char *);
int md5sum_init(char *);
int nsrl_init(char *, int);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int tm_init(char *db_file, char *type) {
  if (strcmp(type, "nsrl-md5") == 0) {
    return nsrl_init(db_file, 0x01);
  } else if (strcmp(type, "nsrl-sha1") == 0) {
    return nsrl_init(db_file, 0x02);
  } else if (strcmp(type, "md5sum") == 0) {
    return md5sum_init(db_file);
  } else if (strcmp(type, "hk") == 0) {
    return hk_init(db_file);
  } else {
    fprintf(stderr, "Unsupported type: %s\n", type);
    fprintf(stderr, "\t%s\n", "nsrl-md5, nsrl-sha1, md5sum, hk");
  }
  return 1;
}


x86 assembly (clang, -O0):
<tm_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe95(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1190 <tm_init+0x40>
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1060 <nsrl_init@plt>
mov    %eax,-0x4(%rbp)
jmp    1261 <tm_init+0x111>
mov    -0x18(%rbp),%rdi
lea    0xe6e(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11c0 <tm_init+0x70>
mov    -0x10(%rbp),%rdi
mov    $0x2,%esi
call   1060 <nsrl_init@plt>
mov    %eax,-0x4(%rbp)
jmp    1261 <tm_init+0x111>
mov    -0x18(%rbp),%rdi
lea    0xe48(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11eb <tm_init+0x9b>
mov    -0x10(%rbp),%rdi
call   1030 <md5sum_init@plt>
mov    %eax,-0x4(%rbp)
jmp    1261 <tm_init+0x111>
mov    -0x18(%rbp),%rdi
lea    0xe5c(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1216 <tm_init+0xc6>
mov    -0x10(%rbp),%rdi
call   1070 <hk_init@plt>
mov    %eax,-0x4(%rbp)
jmp    1261 <tm_init+0x111>
mov    0x2dc3(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xdf0(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2daa(%rip),%rax
mov    (%rax),%edi
lea    0xdf1(%rip),%rsi
lea    0xdef(%rip),%rdx
call   1050 <fprintf@plt>
jmp    1250 <tm_init+0x100>
jmp    1255 <tm_init+0x105>
jmp    125a <tm_init+0x10a>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tm_init>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xe9f(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11e6 <tm_init+0x96>
lea    0xe94(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11f0 <tm_init+0xa0>
lea    0xe8a(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1204 <tm_init+0xb4>
lea    0xeb5(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1213 <tm_init+0xc3>
mov    0x2e2f(%rip),%r14
mov    (%r14),%edi
lea    0xe5f(%rip),%rsi
mov    %rbx,%rdx
call   1050 <fprintf@plt>
mov    (%r14),%edi
lea    0xe63(%rip),%rsi
lea    0xe61(%rip),%rdx
call   1050 <fprintf@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    %r14,%rdi
mov    $0x1,%esi
jmp    11f8 <tm_init+0xa8>
mov    %r14,%rdi
mov    $0x2,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <nsrl_init@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <md5sum_init@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1070 <hk_init@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"nsrl-md5\00"
@.str.1 = [10 x i8] c"nsrl-sha1\00"
@.str.2 = [7 x i8] c"md5sum\00"
@.str.3 = [3 x i8] c"hk\00"
@stderr = global i32 0
@.str.4 = [22 x i8] c"Unsupported type: %s\0A\00"
@.str.5 = [5 x i8] c"\09%s\0A\00"
@.str.6 = [32 x i8] c"nsrl-md5, nsrl-sha1, md5sum, hk\00"
define i32 @tm_init(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%6 = load i8*, i8** %5
%7 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i8*, i8** %4
%11 = call i32 @nsrl_init(i8* %10, i32 1)
store i32 %11, i32* %3
br label %43
12: ; preds = %2
%13 = load i8*, i8** %5
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = load i8*, i8** %4
%18 = call i32 @nsrl_init(i8* %17, i32 2)
store i32 %18, i32* %3
br label %43
19: ; preds = %12
%20 = load i8*, i8** %5
%21 = call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %19
%24 = load i8*, i8** %4
%25 = call i32 @md5sum_init(i8* %24)
store i32 %25, i32* %3
br label %43
26: ; preds = %19
%27 = load i8*, i8** %5
%28 = call i64 @strcmp(i8* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %26
%31 = load i8*, i8** %4
%32 = call i32 @hk_init(i8* %31)
store i32 %32, i32* %3
br label %43
33: ; preds = %26
%34 = load i32, i32* @stderr
%35 = load i8*, i8** %5
%36 = call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %35)
%37 = load i32, i32* @stderr
%38 = call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0))
br label %39
39: ; preds = %33
br label %40
40: ; preds = %39
br label %41
41: ; preds = %40
br label %42
42: ; preds = %41
store i32 1, i32* %3
br label %43
43: ; preds = %42, %30, %23, %16, %9
%44 = load i32, i32* %3
ret i32 %44
}

LLVM IR (-O2):
@.str = [9 x i8] c"nsrl-md5\00"
@.str.1 = [10 x i8] c"nsrl-sha1\00"
@.str.2 = [7 x i8] c"md5sum\00"
@.str.3 = [3 x i8] c"hk\00"
@stderr = global i32 0
@.str.4 = [22 x i8] c"Unsupported type: %s\0A\00"
@.str.5 = [5 x i8] c"\09%s\0A\00"
@.str.6 = [32 x i8] c"nsrl-md5, nsrl-sha1, md5sum, hk\00"
define i32 @tm_init(i8* %0, i8* %1) {
%3 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @nsrl_init(i8* %0, i32 1)
br label %27
7: ; preds = %2
%8 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = tail call i32 @nsrl_init(i8* %0, i32 2)
br label %27
12: ; preds = %7
%13 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = tail call i32 @md5sum_init(i8* %0)
br label %27
17: ; preds = %12
%18 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = tail call i32 @hk_init(i8* %0)
br label %27
22: ; preds = %17
%23 = load i32, i32* @stderr
%24 = tail call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %1)
%25 = load i32, i32* @stderr
%26 = tail call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0))
br label %27
27: ; preds = %22, %20, %15, %10, %5
%28 = phi i32 [ %6, %5 ], [ %11, %10 ], [ %16, %15 ], [ %21, %20 ], [ 1, %22 ]
ret i32 %28
}