#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 dump_standard_hdr_test(char *, int, unsigned char *, unsigned char, int);
int print_uri_junit_tests(char *, int, unsigned char *, unsigned char, int, int,
                          char *);
int strlen(char *);
int write(int, char *, int);
int dump_route_test(char *hdr, int hdrlen, unsigned char *payload, int paylen,
                    int fd, char segregationLevel, char *prefix) {
  int n, i = 2;
  unsigned char flags = 0;
  if (!(segregationLevel & (0x01 | 0x08))) {
    return dump_standard_hdr_test(hdr, hdrlen, (unsigned char *)payload, paylen,
                                  fd);
  }
  flags = payload[0];
  i = 2;
  if (flags & 0x01) {
    i += 2;
  }
  if ((!(segregationLevel & 0x08)) && (segregationLevel & 0x01)) {
    return dump_standard_hdr_test(hdr, hdrlen, (unsigned char *)(payload + i),
                                  payload[1], fd);
  }
  if ((segregationLevel & 0x08) && (segregationLevel & 0x01)) {
    return print_uri_junit_tests(hdr, hdrlen, &payload[i], payload[1], fd, 1,
                                 "");
  }
  if (segregationLevel & 0x08) {
    i = 2;
    n = write(fd, prefix, strlen(prefix));
    n = write(fd, "getAddress.getDisplayName=(S)", 29);
    if (flags & 0x01) {
      n = write(fd, &hdr[payload[i]], payload[i + 1]);
      n = write(fd, "\n", 1);
      i += 2;
    } else
      n = write(fd, "(null)\n", 7);
    return n < 0 ? -1
                 : print_uri_junit_tests(hdr, hdrlen, &payload[i], payload[1],
                                         fd, 0, "getAddress.getURI.");
  }
  return 0;
}


x86 assembly (clang, -O0):
<dump_route_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %r9b,%al
mov    0x10(%rbp),%r9
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8d,-0x28(%rbp)
mov    %al,-0x29(%rbp)
movl   $0x2,-0x34(%rbp)
movb   $0x0,-0x35(%rbp)
movsbl -0x29(%rbp),%eax
and    $0x9,%eax
cmp    $0x0,%eax
jne    11a1 <dump_route_test+0x61>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%eax
mov    -0x28(%rbp),%r8d
movzbl %al,%ecx
call   1040 <dump_standard_hdr_test@plt>
mov    %eax,-0x4(%rbp)
jmp    13a5 <dump_route_test+0x265>
mov    -0x20(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x35(%rbp)
movl   $0x2,-0x34(%rbp)
movzbl -0x35(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     11ca <dump_route_test+0x8a>
mov    -0x34(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x34(%rbp)
movsbl -0x29(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
jne    1217 <dump_route_test+0xd7>
movsbl -0x29(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1217 <dump_route_test+0xd7>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
movslq -0x34(%rbp),%rax
add    %rax,%rdx
mov    -0x20(%rbp),%rax
mov    0x1(%rax),%al
mov    -0x28(%rbp),%r8d
movzbl %al,%ecx
call   1040 <dump_standard_hdr_test@plt>
mov    %eax,-0x4(%rbp)
jmp    13a5 <dump_route_test+0x265>
movsbl -0x29(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     1275 <dump_route_test+0x135>
movsbl -0x29(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1275 <dump_route_test+0x135>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
movslq -0x34(%rbp),%rax
add    %rax,%rdx
mov    -0x20(%rbp),%rax
mov    0x1(%rax),%cl
mov    -0x28(%rbp),%r8d
mov    $0x1,%r9d
lea    0xdc4(%rip),%rax
movzbl %cl,%ecx
mov    %rax,(%rsp)
call   1060 <print_uri_junit_tests@plt>
mov    %eax,-0x4(%rbp)
jmp    13a5 <dump_route_test+0x265>
movsbl -0x29(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     139e <dump_route_test+0x25e>
movl   $0x2,-0x34(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x44(%rbp),%edi
mov    -0x40(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %eax,-0x30(%rbp)
mov    -0x28(%rbp),%edi
lea    0xd42(%rip),%rsi
mov    $0x1d,%edx
call   1030 <write@plt>
mov    %eax,-0x30(%rbp)
movzbl -0x35(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     132f <dump_route_test+0x1ef>
mov    -0x28(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
add    %rax,%rsi
mov    -0x20(%rbp),%rax
mov    -0x34(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%edx
call   1030 <write@plt>
mov    %eax,-0x30(%rbp)
mov    -0x28(%rbp),%edi
lea    0xd10(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    %eax,-0x30(%rbp)
mov    -0x34(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x34(%rbp)
jmp    1346 <dump_route_test+0x206>
mov    -0x28(%rbp),%edi
lea    0xce5(%rip),%rsi
mov    $0x7,%edx
call   1030 <write@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
jge    135d <dump_route_test+0x21d>
mov    $0xffffffff,%eax
mov    %eax,-0x48(%rbp)
jmp    1393 <dump_route_test+0x253>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
movslq -0x34(%rbp),%rax
add    %rax,%rdx
mov    -0x20(%rbp),%rax
mov    0x1(%rax),%cl
mov    -0x28(%rbp),%r8d
xor    %r9d,%r9d
lea    0xca2(%rip),%rax
movzbl %cl,%ecx
mov    %rax,(%rsp)
call   1060 <print_uri_junit_tests@plt>
mov    %eax,-0x48(%rbp)
mov    -0x48(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    13a5 <dump_route_test+0x265>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_route_test>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%r13d
mov    %rdx,%rbp
mov    %esi,%r14d
mov    %rdi,%r15
mov    %r9d,%eax
and    $0x9,%eax
je     1189 <dump_route_test+0x49>
movzbl 0x0(%rbp),%ebx
mov    %ebx,%ecx
and    $0x1,%ecx
lea    (%rcx,%rcx,1),%rdx
add    $0x2,%rdx
cmp    $0x9,%eax
je     11ab <dump_route_test+0x6b>
cmp    $0x1,%eax
jne    11d6 <dump_route_test+0x96>
add    %rbp,%rdx
movzbl 0x1(%rbp),%ecx
mov    %r15,%rdi
mov    %r14d,%esi
jmp    1195 <dump_route_test+0x55>
movzbl %cl,%ecx
mov    %r15,%rdi
mov    %r14d,%esi
mov    %rbp,%rdx
mov    %r13d,%r8d
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <dump_standard_hdr_test@plt>
add    %rbp,%rdx
movzbl 0x1(%rbp),%ecx
lea    0xe6c(%rip),%rax
mov    %rax,(%rsp)
mov    %r15,%rdi
mov    %r14d,%esi
mov    %r13d,%r8d
mov    $0x1,%r9d
call   1060 <print_uri_junit_tests@plt>
jmp    128c <dump_route_test+0x14c>
xor    %eax,%eax
test   $0x8,%r9b
je     128c <dump_route_test+0x14c>
mov    0x40(%rsp),%r12
mov    %r12,%rdi
call   1050 <strlen@plt>
mov    %r13d,%edi
mov    %r12,%rsi
mov    %eax,%edx
call   1030 <write@plt>
lea    0xdfd(%rip),%rsi
mov    %r13d,%edi
mov    $0x1d,%edx
call   1030 <write@plt>
test   $0x1,%bl
jne    1257 <dump_route_test+0x117>
lea    0xe02(%rip),%rsi
mov    %r13d,%edi
mov    $0x7,%edx
call   1030 <write@plt>
mov    $0x2,%edx
test   %eax,%eax
js     1287 <dump_route_test+0x147>
add    %rbp,%rdx
movzbl 0x1(%rbp),%ecx
lea    0xde6(%rip),%rax
mov    %rax,(%rsp)
mov    %r15,%rdi
mov    %r14d,%esi
mov    %r13d,%r8d
xor    %r9d,%r9d
call   1060 <print_uri_junit_tests@plt>
jmp    128c <dump_route_test+0x14c>
movzbl 0x2(%rbp),%esi
add    %r15,%rsi
movzbl 0x3(%rbp),%edx
mov    %r13d,%edi
call   1030 <write@plt>
lea    0xdb3(%rip),%rsi
mov    %r13d,%edi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x4,%edx
test   %eax,%eax
jns    1232 <dump_route_test+0xf2>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [30 x i8] c"getAddress.getDisplayName=(S)\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [8 x i8] c"(null)\0A\00"
@.str.4 = [19 x i8] c"getAddress.getURI.\00"
define i32 @dump_route_test(i8* %0, i32 %1, i8* %2, i32 %3, i32 %4, i8 signext %5, i8* %6) {
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8
%15 = alloca i8*
%16 = alloca i32
%17 = alloca i32
%18 = alloca i8
store i8* %0, i8** %9
store i32 %1, i32* %10
store i8* %2, i8** %11
store i32 %3, i32* %12
store i32 %4, i32* %13
store i8 %5, i8* %14
store i8* %6, i8** %15
store i32 2, i32* %17
store i8 0, i8* %18
%19 = load i8, i8* %14
%20 = sext i8 %19 to i32
%21 = and i32 %20, 9
%22 = icmp ne i32 %21, 0
br i1 %22, label %31, label %23
23: ; preds = %7
%24 = load i8*, i8** %9
%25 = load i32, i32* %10
%26 = load i8*, i8** %11
%27 = load i32, i32* %12
%28 = trunc i32 %27 to i8
%29 = load i32, i32* %13
%30 = call i32 @dump_standard_hdr_test(i8* %24, i32 %25, i8* %26, i8 zeroext %28, i32 %29)
store i32 %30, i32* %8
br label %147
31: ; preds = %7
%32 = load i8*, i8** %11
%33 = getelementptr inbounds i8, i8* %32, i64 0
%34 = load i8, i8* %33
store i8 %34, i8* %18
store i32 2, i32* %17
%35 = load i8, i8* %18
%36 = zext i8 %35 to i32
%37 = and i32 %36, 1
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %42
39: ; preds = %31
%40 = load i32, i32* %17
%41 = add nsw i32 %40, 2
store i32 %41, i32* %17
br label %42
42: ; preds = %39, %31
%43 = load i8, i8* %14
%44 = sext i8 %43 to i32
%45 = and i32 %44, 8
%46 = icmp ne i32 %45, 0
br i1 %46, label %64, label %47
47: ; preds = %42
%48 = load i8, i8* %14
%49 = sext i8 %48 to i32
%50 = and i32 %49, 1
%51 = icmp ne i32 %50, 0
br i1 %51, label %52, label %64
52: ; preds = %47
%53 = load i8*, i8** %9
%54 = load i32, i32* %10
%55 = load i8*, i8** %11
%56 = load i32, i32* %17
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8, i8* %55, i64 %57
%59 = load i8*, i8** %11
%60 = getelementptr inbounds i8, i8* %59, i64 1
%61 = load i8, i8* %60
%62 = load i32, i32* %13
%63 = call i32 @dump_standard_hdr_test(i8* %53, i32 %54, i8* %58, i8 zeroext %61, i32 %62)
store i32 %63, i32* %8
br label %147
64: ; preds = %47, %42
%65 = load i8, i8* %14
%66 = sext i8 %65 to i32
%67 = and i32 %66, 8
%68 = icmp ne i32 %67, 0
br i1 %68, label %69, label %86
69: ; preds = %64
%70 = load i8, i8* %14
%71 = sext i8 %70 to i32
%72 = and i32 %71, 1
%73 = icmp ne i32 %72, 0
br i1 %73, label %74, label %86
74: ; preds = %69
%75 = load i8*, i8** %9
%76 = load i32, i32* %10
%77 = load i8*, i8** %11
%78 = load i32, i32* %17
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds i8, i8* %77, i64 %79
%81 = load i8*, i8** %11
%82 = getelementptr inbounds i8, i8* %81, i64 1
%83 = load i8, i8* %82
%84 = load i32, i32* %13
%85 = call i32 @print_uri_junit_tests(i8* %75, i32 %76, i8* %80, i8 zeroext %83, i32 %84, i32 1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i32 %85, i32* %8
br label %147
86: ; preds = %69, %64
%87 = load i8, i8* %14
%88 = sext i8 %87 to i32
%89 = and i32 %88, 8
%90 = icmp ne i32 %89, 0
br i1 %90, label %91, label %146
91: ; preds = %86
store i32 2, i32* %17
%92 = load i32, i32* %13
%93 = load i8*, i8** %15
%94 = load i8*, i8** %15
%95 = call i32 @strlen(i8* %94)
%96 = call i32 @write(i32 %92, i8* %93, i32 %95)
store i32 %96, i32* %16
%97 = load i32, i32* %13
%98 = call i32 @write(i32 %97, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 29)
store i32 %98, i32* %16
%99 = load i8, i8* %18
%100 = zext i8 %99 to i32
%101 = and i32 %100, 1
%102 = icmp ne i32 %101, 0
br i1 %102, label %103, label %125
103: ; preds = %91
%104 = load i32, i32* %13
%105 = load i8*, i8** %9
%106 = load i8*, i8** %11
%107 = load i32, i32* %17
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds i8, i8* %106, i64 %108
%110 = load i8, i8* %109
%111 = zext i8 %110 to i64
%112 = getelementptr inbounds i8, i8* %105, i64 %111
%113 = load i8*, i8** %11
%114 = load i32, i32* %17
%115 = add nsw i32 %114, 1
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds i8, i8* %113, i64 %116
%118 = load i8, i8* %117
%119 = zext i8 %118 to i32
%120 = call i32 @write(i32 %104, i8* %112, i32 %119)
store i32 %120, i32* %16
%121 = load i32, i32* %13
%122 = call i32 @write(i32 %121, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 1)
store i32 %122, i32* %16
%123 = load i32, i32* %17
%124 = add nsw i32 %123, 2
store i32 %124, i32* %17
br label %128
125: ; preds = %91
%126 = load i32, i32* %13
%127 = call i32 @write(i32 %126, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 7)
store i32 %127, i32* %16
br label %128
128: ; preds = %125, %103
%129 = load i32, i32* %16
%130 = icmp slt i32 %129, 0
br i1 %130, label %131, label %132
131: ; preds = %128
br label %144
132: ; preds = %128
%133 = load i8*, i8** %9
%134 = load i32, i32* %10
%135 = load i8*, i8** %11
%136 = load i32, i32* %17
%137 = sext i32 %136 to i64
%138 = getelementptr inbounds i8, i8* %135, i64 %137
%139 = load i8*, i8** %11
%140 = getelementptr inbounds i8, i8* %139, i64 1
%141 = load i8, i8* %140
%142 = load i32, i32* %13
%143 = call i32 @print_uri_junit_tests(i8* %133, i32 %134, i8* %138, i8 zeroext %141, i32 %142, i32 0, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
br label %144
144: ; preds = %132, %131
%145 = phi i32 [ -1, %131 ], [ %143, %132 ]
store i32 %145, i32* %8
br label %147
146: ; preds = %86
store i32 0, i32* %8
br label %147
147: ; preds = %146, %144, %74, %52, %23
%148 = load i32, i32* %8
ret i32 %148
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [30 x i8] c"getAddress.getDisplayName=(S)\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [8 x i8] c"(null)\0A\00"
@.str.4 = [19 x i8] c"getAddress.getURI.\00"
define i32 @dump_route_test(i8* %0, i32 %1, i8* %2, i32 %3, i32 %4, i8 signext %5, i8* %6) {
%8 = zext i8 %5 to i32
%9 = and i32 %8, 9
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %7
%12 = trunc i32 %3 to i8
%13 = tail call i32 @dump_standard_hdr_test(i8* %0, i32 %1, i8* %2, i8 zeroext %12, i32 %4)
br label %57
14: ; preds = %7
%15 = load i8, i8* %2
%16 = and i8 %15, 1
%17 = icmp eq i8 %16, 0
%18 = select i1 %17, i64 2, i64 4
switch i32 %9, label %29 [
i32 1, label %19
i32 9, label %24
]
19: ; preds = %14
%20 = getelementptr inbounds i8, i8* %2, i64 %18
%21 = getelementptr inbounds i8, i8* %2, i64 1
%22 = load i8, i8* %21
%23 = tail call i32 @dump_standard_hdr_test(i8* %0, i32 %1, i8* %20, i8 zeroext %22, i32 %4)
br label %57
24: ; preds = %14
%25 = getelementptr inbounds i8, i8* %2, i64 %18
%26 = getelementptr inbounds i8, i8* %2, i64 1
%27 = load i8, i8* %26
%28 = tail call i32 @print_uri_junit_tests(i8* %0, i32 %1, i8* %25, i8 zeroext %27, i32 %4, i32 1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %57
29: ; preds = %14
%30 = and i32 %8, 8
%31 = icmp eq i32 %30, 0
br i1 %31, label %57, label %32
32: ; preds = %29
%33 = tail call i32 @strlen(i8* %6)
%34 = tail call i32 @write(i32 %4, i8* %6, i32 %33)
%35 = tail call i32 @write(i32 %4, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 29)
br i1 %17, label %46, label %36
36: ; preds = %32
%37 = getelementptr inbounds i8, i8* %2, i64 2
%38 = load i8, i8* %37
%39 = zext i8 %38 to i64
%40 = getelementptr inbounds i8, i8* %0, i64 %39
%41 = getelementptr inbounds i8, i8* %2, i64 3
%42 = load i8, i8* %41
%43 = zext i8 %42 to i32
%44 = tail call i32 @write(i32 %4, i8* %40, i32 %43)
%45 = tail call i32 @write(i32 %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 1)
br label %48
46: ; preds = %32
%47 = tail call i32 @write(i32 %4, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 7)
br label %48
48: ; preds = %46, %36
%49 = phi i32 [ %45, %36 ], [ %47, %46 ]
%50 = phi i64 [ 4, %36 ], [ 2, %46 ]
%51 = icmp slt i32 %49, 0
br i1 %51, label %57, label %52
52: ; preds = %48
%53 = getelementptr inbounds i8, i8* %2, i64 %50
%54 = getelementptr inbounds i8, i8* %2, i64 1
%55 = load i8, i8* %54
%56 = tail call i32 @print_uri_junit_tests(i8* %0, i32 %1, i8* %53, i8 zeroext %55, i32 %4, i32 0, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
br label %57
57: ; preds = %29, %52, %48, %24, %19, %11
%58 = phi i32 [ %28, %24 ], [ %23, %19 ], [ %13, %11 ], [ %56, %52 ], [ -1, %48 ], [ 0, %29 ]
ret i32 %58
}