#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 add_mid(char *, char *);
int /*<<< orphan*/ close_dbz_channel();
int /*<<< orphan*/ init_dbz_channel();
int /*<<< orphan*/ printf(char *, ...);
int query_mid(char *, char *);
int main(int argc, char **argv) {
  char test[4096];
  int ret;
  init_dbz_channel();
  ret = add_mid("<tttt.eeee.ssss.tttt>", "THIS_IS_1ST_PATH");
  if (ret)
    printf("add 1st mid OK\n");
  else
    printf("add 1st mid failed\n");
  ret = add_mid("<bbbb.cccc.dddd.eeee>", "THIS_IS_2ND_PATH");
  if (ret)
    printf("add 2st mid OK\n");
  else
    printf("add 2st mid failed\n");
  ret = query_mid("<tttt.eeee.ssss.tttt>", test);
  if (ret)
    printf("query 1st ok : '%s'\n", test);
  else
    printf("query 1st failed\n");
  ret = query_mid("<bbbb.cccc.dddd.eeee>", test);
  if (ret)
    printf("query 2nd ok : '%s'\n", test);
  else
    printf("query 2nd failed\n");
  ret = query_mid("<no.such.item>", test);
  if (ret)
    printf("query no_such_item found ??? : '%s'\n", test);
  else
    printf("query no_such_item not found\n");
  close_dbz_channel();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1020,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1060 <init_dbz_channel@plt>
lea    0xe89(%rip),%rdi
lea    0xe98(%rip),%rsi
call   1070 <add_mid@plt>
mov    %eax,-0x1014(%rbp)
cmpl   $0x0,-0x1014(%rbp)
je     11a9 <main+0x59>
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11b7 <main+0x67>
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe8d(%rip),%rdi
lea    0xe9c(%rip),%rsi
call   1070 <add_mid@plt>
mov    %eax,-0x1014(%rbp)
cmpl   $0x0,-0x1014(%rbp)
je     11f0 <main+0xa0>
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11fe <main+0xae>
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x1010(%rbp),%rsi
lea    0xdf4(%rip),%rdi
call   1030 <query_mid@plt>
mov    %eax,-0x1014(%rbp)
cmpl   $0x0,-0x1014(%rbp)
je     123e <main+0xee>
lea    -0x1010(%rbp),%rsi
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    124c <main+0xfc>
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x1010(%rbp),%rsi
lea    0xdf1(%rip),%rdi
call   1030 <query_mid@plt>
mov    %eax,-0x1014(%rbp)
cmpl   $0x0,-0x1014(%rbp)
je     128c <main+0x13c>
lea    -0x1010(%rbp),%rsi
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    129a <main+0x14a>
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x1010(%rbp),%rsi
lea    0xe3c(%rip),%rdi
call   1030 <query_mid@plt>
mov    %eax,-0x1014(%rbp)
cmpl   $0x0,-0x1014(%rbp)
je     12da <main+0x18a>
lea    -0x1010(%rbp),%rsi
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12e8 <main+0x198>
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <close_dbz_channel@plt>
xor    %eax,%eax
add    $0x1020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x1000,%rsp
xor    %eax,%eax
call   1070 <init_dbz_channel@plt>
lea    0xe8a(%rip),%rbx
lea    0xe99(%rip),%rsi
mov    %rbx,%rdi
call   1080 <add_mid@plt>
test   %eax,%eax
lea    0xf1e(%rip),%rax
lea    0xf8b(%rip),%rdi
cmove  %rax,%rdi
call   1040 <puts@plt>
lea    0xe82(%rip),%rdi
lea    0xe91(%rip),%rsi
call   1080 <add_mid@plt>
test   %eax,%eax
lea    0xf05(%rip),%rax
lea    0xf50(%rip),%rdi
cmove  %rax,%rdi
call   1040 <puts@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1030 <query_mid@plt>
test   %eax,%eax
je     11ec <main+0x8c>
lea    0xe6e(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11f8 <main+0x98>
lea    0xedf(%rip),%rdi
call   1040 <puts@plt>
lea    0xe28(%rip),%rdi
mov    %rsp,%rsi
call   1030 <query_mid@plt>
test   %eax,%eax
je     121e <main+0xbe>
lea    0xe51(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    122a <main+0xca>
lea    0xebe(%rip),%rdi
call   1040 <puts@plt>
lea    0xe47(%rip),%rdi
mov    %rsp,%rsi
call   1030 <query_mid@plt>
test   %eax,%eax
je     1250 <main+0xf0>
lea    0xe43(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    125c <main+0xfc>
lea    0xe9d(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1060 <close_dbz_channel@plt>
xor    %eax,%eax
add    $0x1000,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [22 x i8] c"<tttt.eeee.ssss.tttt>\00"
@.str.1 = [17 x i8] c"THIS_IS_1ST_PATH\00"
@.str.2 = [16 x i8] c"add 1st mid OK\0A\00"
@.str.3 = [20 x i8] c"add 1st mid failed\0A\00"
@.str.4 = [22 x i8] c"<bbbb.cccc.dddd.eeee>\00"
@.str.5 = [17 x i8] c"THIS_IS_2ND_PATH\00"
@.str.6 = [16 x i8] c"add 2st mid OK\0A\00"
@.str.7 = [20 x i8] c"add 2st mid failed\0A\00"
@.str.8 = [21 x i8] c"query 1st ok : '%s'\0A\00"
@.str.9 = [18 x i8] c"query 1st failed\0A\00"
@.str.10 = [21 x i8] c"query 2nd ok : '%s'\0A\00"
@.str.11 = [18 x i8] c"query 2nd failed\0A\00"
@.str.12 = [15 x i8] c"<no.such.item>\00"
@.str.13 = [37 x i8] c"query no_such_item found ??? : '%s'\0A\00"
@.str.14 = [30 x i8] c"query no_such_item not found\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [4096 x i8]
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 (...) @init_dbz_channel()
%9 = call i32 @add_mid(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
store i32 %9, i32* %7
%10 = load i32, i32* %7
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %16
14: ; preds = %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
br label %16
16: ; preds = %14, %12
%17 = call i32 @add_mid(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
store i32 %17, i32* %7
%18 = load i32, i32* %7
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
br label %24
22: ; preds = %16
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
br label %24
24: ; preds = %22, %20
%25 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%26 = call i32 @query_mid(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %25)
store i32 %26, i32* %7
%27 = load i32, i32* %7
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %24
%30 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), i8* %30)
br label %34
32: ; preds = %24
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0))
br label %34
34: ; preds = %32, %29
%35 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%36 = call i32 @query_mid(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %35)
store i32 %36, i32* %7
%37 = load i32, i32* %7
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %42
39: ; preds = %34
%40 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0), i8* %40)
br label %44
42: ; preds = %34
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.11, i64 0, i64 0))
br label %44
44: ; preds = %42, %39
%45 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%46 = call i32 @query_mid(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.12, i64 0, i64 0), i8* %45)
store i32 %46, i32* %7
%47 = load i32, i32* %7
%48 = icmp ne i32 %47, 0
br i1 %48, label %49, label %52
49: ; preds = %44
%50 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.13, i64 0, i64 0), i8* %50)
br label %54
52: ; preds = %44
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.14, i64 0, i64 0))
br label %54
54: ; preds = %52, %49
%55 = call i32 (...) @close_dbz_channel()
ret i32 0
}

LLVM IR (-O2):
@.str = [22 x i8] c"<tttt.eeee.ssss.tttt>\00"
@.str.1 = [17 x i8] c"THIS_IS_1ST_PATH\00"
@.str.4 = [22 x i8] c"<bbbb.cccc.dddd.eeee>\00"
@.str.5 = [17 x i8] c"THIS_IS_2ND_PATH\00"
@.str.8 = [21 x i8] c"query 1st ok : '%s'\0A\00"
@.str.10 = [21 x i8] c"query 2nd ok : '%s'\0A\00"
@.str.12 = [15 x i8] c"<no.such.item>\00"
@.str.13 = [37 x i8] c"query no_such_item found ??? : '%s'\0A\00"
@str = [19 x i8] c"add 1st mid failed\00"
@str.15 = [19 x i8] c"add 2st mid failed\00"
@str.16 = [17 x i8] c"query 1st failed\00"
@str.17 = [17 x i8] c"query 2nd failed\00"
@str.18 = [29 x i8] c"query no_such_item not found\00"
@str.19 = [15 x i8] c"add 2st mid OK\00"
@str.20 = [15 x i8] c"add 1st mid OK\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [4096 x i8]
%4 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%5 = tail call i32 (...) @init_dbz_channel()
%6 = tail call i32 @add_mid(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i32 %6, 0
%8 = select i1 %7, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @str.20, i64 0, i64 0)
%9 = tail call i32 @puts(i8* dereferenceable(1) %8)
%10 = tail call i32 @add_mid(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
%11 = icmp eq i32 %10, 0
%12 = select i1 %11, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @str.15, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @str.19, i64 0, i64 0)
%13 = tail call i32 @puts(i8* dereferenceable(1) %12)
%14 = call i32 @query_mid(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %4)
%15 = icmp eq i32 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %2
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), i8* %4)
br label %20
18: ; preds = %2
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.16, i64 0, i64 0))
br label %20
20: ; preds = %18, %16
%21 = call i32 @query_mid(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %4)
%22 = icmp eq i32 %21, 0
br i1 %22, label %25, label %23
23: ; preds = %20
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0), i8* %4)
br label %27
25: ; preds = %20
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.17, i64 0, i64 0))
br label %27
27: ; preds = %25, %23
%28 = call i32 @query_mid(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.12, i64 0, i64 0), i8* %4)
%29 = icmp eq i32 %28, 0
br i1 %29, label %32, label %30
30: ; preds = %27
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.13, i64 0, i64 0), i8* %4)
br label %34
32: ; preds = %27
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.18, i64 0, i64 0))
br label %34
34: ; preds = %32, %30
%35 = call i32 (...) @close_dbz_channel()
ret i32 0
}