#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*/ data_dump(unsigned char *, int, int);
int /*<<< orphan*/ dump_end(unsigned char *, int);
int flx_get_number(unsigned char **, int *);
int /*<<< orphan*/ isdigit(unsigned char);
int /*<<< orphan*/ isupper(unsigned char);
int /*<<< orphan*/ lprintf(int, char *, ...);
unsigned char *memchr(unsigned char *, char, int);
void flexnet_dump(unsigned char *data, int length, int hexdump) {
  int i;
  int hopcnt, qsonr;
  unsigned char *cp;
  lprintf(6, "FlexNet:");
  if (length < 1) {
    lprintf(1, " bad packet\n");
    return;
  }
  switch (data[0]) {
  default:
    lprintf(1, " unknown packet type\n");
    data_dump(data, length, hexdump);
    return;
  case '0':
    if (length < 2) {
      lprintf(1, " bad packet\n");
      dump_end(data + 1, length - 1);
      return;
    }
    lprintf(3, " Link setup - max SSID %d ", data[1] & 0xf);
    dump_end(data + 1, length - 1);
    return;
  case '1':
    lprintf(3, " Poll response -");
    data++;
    length--;
    i = flx_get_number(&data, &length);
    data++;
    length--;
    if (i < 0)
      goto too_short;
    lprintf(3, " delay: %d\n", i);
    dump_end(data, length);
    return;
  case '2':
    lprintf(3, " Poll");
    return;
  case '3':
    data++;
    length--;
    lprintf(3, " Routing\n");
    while (length > 0) {
      if (isdigit(*data) || isupper(*data)) {
        if (length < 10)
          goto too_short;
        lprintf(3, "  %.6s %2d-%2d ", data, data[6] - '0', data[7] - '0');
        data += 8;
        length -= 8;
        i = flx_get_number(&data, &length);
        data++;
        length--;
        if (!i)
          lprintf(3, "link down\n");
        else
          lprintf(3, "delay: %d\n", i);
      } else {
        if (*data == '+')
          lprintf(3, "  Request token\n");
        else if (*data == '-')
          lprintf(3, "  Release token\n");
        else if (*data != '\r')
          lprintf(3, "  invalid char: %02x\n", *data);
        data++;
        length--;
      }
    }
    return;
  case '6':
  case '7':
    lprintf(3, " Route query");
    if (*data == '7')
      lprintf(3, " response");
    if (length < 2)
      goto too_short;
    hopcnt = data[1] - ' ';
    data += 2;
    length -= 2;
    qsonr = flx_get_number(&data, &length);
    data++;
    length--;
    lprintf(3, " - hop count: %d QSO number: %d\n", hopcnt, qsonr);
    cp = memchr(data, '\r', length);
    if (cp)
      *cp = 0;
    lprintf(3, "  data");
    return;
  }
too_short:
  lprintf(1, " packet too short\n");
  dump_end(data, length);
}


x86 assembly (clang, -O0):
<flexnet_dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    $0x6,%edi
lea    0xe92(%rip),%rsi
mov    $0x0,%al
call   1090 <lprintf@plt>
cmpl   $0x1,-0xc(%rbp)
jge    11b7 <flexnet_dump+0x47>
mov    $0x1,%edi
lea    0xe7e(%rip),%rsi
mov    $0x0,%al
call   1090 <lprintf@plt>
jmp    15c9 <flexnet_dump+0x459>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
add    $0xffffffd0,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x7,%eax
ja     11e4 <flexnet_dump+0x74>
mov    -0x30(%rbp),%rax
lea    0xe25(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x1,%edi
lea    0xe46(%rip),%rsi
mov    $0x0,%al
call   1090 <lprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1040 <data_dump@plt>
jmp    15c9 <flexnet_dump+0x459>
cmpl   $0x2,-0xc(%rbp)
jge    1240 <flexnet_dump+0xd0>
mov    $0x1,%edi
lea    0xe08(%rip),%rsi
mov    $0x0,%al
call   1090 <lprintf@plt>
mov    -0x8(%rbp),%rdi
add    $0x1,%rdi
mov    -0xc(%rbp),%esi
sub    $0x1,%esi
call   1080 <dump_end@plt>
jmp    15c9 <flexnet_dump+0x459>
mov    -0x8(%rbp),%rax
movzbl 0x1(%rax),%edx
and    $0xf,%edx
mov    $0x3,%edi
lea    0xdf5(%rip),%rsi
mov    $0x0,%al
call   1090 <lprintf@plt>
mov    -0x8(%rbp),%rdi
add    $0x1,%rdi
mov    -0xc(%rbp),%esi
sub    $0x1,%esi
call   1080 <dump_end@plt>
jmp    15c9 <flexnet_dump+0x459>
mov    $0x3,%edi
lea    0xde5(%rip),%rsi
mov    $0x0,%al
call   1090 <lprintf@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
lea    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <flx_get_number@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    12d2 <flexnet_dump+0x162>
jmp    15aa <flexnet_dump+0x43a>
mov    -0x14(%rbp),%edx
mov    $0x3,%edi
lea    0xd97(%rip),%rsi
mov    $0x0,%al
call   1090 <lprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1080 <dump_end@plt>
jmp    15c9 <flexnet_dump+0x459>
mov    $0x3,%edi
lea    0xd7f(%rip),%rsi
mov    $0x0,%al
call   1090 <lprintf@plt>
jmp    15c9 <flexnet_dump+0x459>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
mov    $0x3,%edi
lea    0xd58(%rip),%rsi
mov    $0x0,%al
call   1090 <lprintf@plt>
cmpl   $0x0,-0xc(%rbp)
jle    14c0 <flexnet_dump+0x350>
mov    -0x8(%rbp),%rax
movzbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    136d <flexnet_dump+0x1fd>
mov    -0x8(%rbp),%rax
movzbl (%rax),%edi
call   1070 <isupper@plt>
cmp    $0x0,%eax
je     1422 <flexnet_dump+0x2b2>
cmpl   $0xa,-0xc(%rbp)
jge    137c <flexnet_dump+0x20c>
jmp    15aa <flexnet_dump+0x43a>
mov    -0x8(%rbp),%rdx
mov    -0x8(%rbp),%rax
movzbl 0x6(%rax),%ecx
sub    $0x30,%ecx
mov    -0x8(%rbp),%rax
movzbl 0x7(%rax),%r8d
sub    $0x30,%r8d
mov    $0x3,%edi
lea    0xcf0(%rip),%rsi
mov    $0x0,%al
call   1090 <lprintf@plt>
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x8,%eax
mov    %eax,-0xc(%rbp)
lea    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <flx_get_number@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1407 <flexnet_dump+0x297>
mov    $0x3,%edi
lea    0xca9(%rip),%rsi
mov    $0x0,%al
call   1090 <lprintf@plt>
jmp    141d <flexnet_dump+0x2ad>
mov    -0x14(%rbp),%edx
mov    $0x3,%edi
lea    0xc63(%rip),%rsi
mov    $0x0,%al
call   1090 <lprintf@plt>
jmp    14bb <flexnet_dump+0x34b>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x2b,%eax
jne    144a <flexnet_dump+0x2da>
mov    $0x3,%edi
lea    0xc71(%rip),%rsi
mov    $0x0,%al
call   1090 <lprintf@plt>
jmp    14a6 <flexnet_dump+0x336>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x2d,%eax
jne    1472 <flexnet_dump+0x302>
mov    $0x3,%edi
lea    0xc5a(%rip),%rsi
mov    $0x0,%al
call   1090 <lprintf@plt>
jmp    14a1 <flexnet_dump+0x331>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
cmp    $0xd,%eax
je     149c <flexnet_dump+0x32c>
mov    -0x8(%rbp),%rax
movzbl (%rax),%edx
mov    $0x3,%edi
lea    0xc3c(%rip),%rsi
mov    $0x0,%al
call   1090 <lprintf@plt>
jmp    14a1 <flexnet_dump+0x331>
jmp    14a6 <flexnet_dump+0x336>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1339 <flexnet_dump+0x1c9>
jmp    15c9 <flexnet_dump+0x459>
mov    $0x3,%edi
lea    0xc16(%rip),%rsi
mov    $0x0,%al
call   1090 <lprintf@plt>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x37,%eax
jne    14fb <flexnet_dump+0x38b>
mov    $0x3,%edi
lea    0xc00(%rip),%rsi
mov    $0x0,%al
call   1090 <lprintf@plt>
cmpl   $0x2,-0xc(%rbp)
jge    150a <flexnet_dump+0x39a>
jmp    15aa <flexnet_dump+0x43a>
mov    -0x8(%rbp),%rax
movzbl 0x1(%rax),%eax
sub    $0x20,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0xc(%rbp)
lea    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <flx_get_number@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    $0x3,%edi
lea    0xb9a(%rip),%rsi
mov    $0x0,%al
call   1090 <lprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    $0xd,%esi
call   1050 <memchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1592 <flexnet_dump+0x422>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    $0x3,%edi
lea    0xb81(%rip),%rsi
mov    $0x0,%al
call   1090 <lprintf@plt>
jmp    15c9 <flexnet_dump+0x459>
mov    $0x1,%edi
lea    0xb70(%rip),%rsi
mov    $0x0,%al
call   1090 <lprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1080 <dump_end@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<flexnet_dump>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,%ebp
mov    %esi,%r14d
mov    %rdi,%rbx
mov    %rdi,0x10(%rsp)
mov    %esi,0xc(%rsp)
lea    0xe8a(%rip),%rsi
mov    $0x6,%edi
xor    %eax,%eax
call   1090 <lprintf@plt>
test   %r14d,%r14d
jle    127c <flexnet_dump+0x10c>
mov    (%rbx),%al
add    $0xd0,%al
cmp    $0x7,%al
ja     14ca <flexnet_dump+0x35a>
movzbl %al,%eax
lea    0xe3f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf16(%rip),%rsi
mov    $0x3,%edi
xor    %eax,%eax
call   1090 <lprintf@plt>
cmpb   $0x37,(%rbx)
jne    11f5 <flexnet_dump+0x85>
lea    0xf0b(%rip),%rsi
mov    $0x3,%edi
xor    %eax,%eax
call   1090 <lprintf@plt>
cmp    $0x2,%r14d
jb     149a <flexnet_dump+0x32a>
movzbl 0x1(%rbx),%ebp
add    $0xffffffe0,%ebp
add    $0x2,%rbx
mov    %rbx,0x10(%rsp)
add    $0xfffffffe,%r14d
mov    %r14d,0xc(%rsp)
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rsi
call   1060 <flx_get_number@plt>
addq   $0x1,0x10(%rsp)
addl   $0xffffffff,0xc(%rsp)
lea    0xec5(%rip),%rsi
mov    $0x3,%edi
mov    %ebp,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1090 <lprintf@plt>
mov    0x10(%rsp),%rdi
mov    0xc(%rsp),%edx
mov    $0xd,%esi
call   1050 <memchr@plt>
test   %rax,%rax
je     1264 <flexnet_dump+0xf4>
movb   $0x0,(%rax)
lea    0xeb4(%rip),%rsi
mov    $0x3,%edi
xor    %eax,%eax
call   1090 <lprintf@plt>
jmp    14bb <flexnet_dump+0x34b>
lea    0xda6(%rip),%rsi
mov    $0x1,%edi
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1090 <lprintf@plt>
cmp    $0x1,%r14d
ja     14f8 <flexnet_dump+0x388>
lea    0xd7b(%rip),%rsi
mov    $0x1,%edi
xor    %eax,%eax
call   1090 <lprintf@plt>
add    $0x1,%rbx
jmp    1516 <flexnet_dump+0x3a6>
lea    0xd9d(%rip),%rsi
mov    $0x3,%edi
xor    %eax,%eax
call   1090 <lprintf@plt>
add    $0x1,%rbx
mov    %rbx,0x10(%rsp)
add    $0xffffffff,%r14d
mov    %r14d,0xc(%rsp)
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rsi
call   1060 <flx_get_number@plt>
addq   $0x1,0x10(%rsp)
addl   $0xffffffff,0xc(%rsp)
test   %eax,%eax
js     149a <flexnet_dump+0x32a>
lea    0xd67(%rip),%rsi
mov    $0x3,%edi
mov    %eax,%edx
xor    %eax,%eax
call   1090 <lprintf@plt>
jmp    14ad <flexnet_dump+0x33d>
lea    0xd59(%rip),%rsi
mov    $0x3,%edi
jmp    1288 <flexnet_dump+0x118>
add    $0x1,%rbx
mov    %rbx,0x10(%rsp)
lea    -0x1(%r14),%eax
mov    %eax,0xc(%rsp)
lea    0xd3d(%rip),%rsi
mov    $0x3,%edi
xor    %eax,%eax
call   1090 <lprintf@plt>
cmp    $0x2,%r14d
jb     14bb <flexnet_dump+0x34b>
lea    0xd2a(%rip),%r13
lea    0x10(%rsp),%rbp
lea    0xc(%rsp),%r14
lea    0xd29(%rip),%r15
lea    0xcf7(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl (%rbx),%edi
call   1030 <isdigit@plt>
test   %eax,%eax
jne    13b1 <flexnet_dump+0x241>
mov    0x10(%rsp),%rax
movzbl (%rax),%edi
call   1070 <isupper@plt>
test   %eax,%eax
je     1440 <flexnet_dump+0x2d0>
cmpl   $0xa,0xc(%rsp)
jl     149a <flexnet_dump+0x32a>
mov    0x10(%rsp),%rdx
movzbl 0x6(%rdx),%ecx
add    $0xffffffd0,%ecx
movzbl 0x7(%rdx),%r8d
add    $0xffffffd0,%r8d
mov    $0x3,%edi
mov    %r13,%rsi
xor    %eax,%eax
call   1090 <lprintf@plt>
addq   $0x8,0x10(%rsp)
addl   $0xfffffff8,0xc(%rsp)
mov    %rbp,%rdi
mov    %r14,%rsi
call   1060 <flx_get_number@plt>
addq   $0x1,0x10(%rsp)
addl   $0xffffffff,0xc(%rsp)
mov    $0x3,%edi
test   %eax,%eax
je     1420 <flexnet_dump+0x2b0>
mov    %r12,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1090 <lprintf@plt>
jmp    142a <flexnet_dump+0x2ba>
nopl   0x0(%rax,%rax,1)
mov    %r15,%rsi
xor    %eax,%eax
call   1090 <lprintf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    14bb <flexnet_dump+0x34b>
mov    0x10(%rsp),%rbx
jmp    1390 <flexnet_dump+0x220>
mov    0x10(%rsp),%rax
movzbl (%rax),%edx
cmp    $0xd,%edx
je     1483 <flexnet_dump+0x313>
mov    $0x3,%edi
cmp    $0x2d,%dl
je     1465 <flexnet_dump+0x2f5>
cmp    $0x2b,%dl
jne    1475 <flexnet_dump+0x305>
lea    0xc4c(%rip),%rsi
jmp    146c <flexnet_dump+0x2fc>
lea    0xc54(%rip),%rsi
xor    %eax,%eax
call   1090 <lprintf@plt>
jmp    1483 <flexnet_dump+0x313>
lea    0xc55(%rip),%rsi
xor    %eax,%eax
call   1090 <lprintf@plt>
addq   $0x1,0x10(%rsp)
mov    0xc(%rsp),%eax
add    $0xffffffff,%eax
mov    %eax,0xc(%rsp)
test   %eax,%eax
jg     1436 <flexnet_dump+0x2c6>
jmp    14bb <flexnet_dump+0x34b>
lea    0xc85(%rip),%rsi
mov    $0x1,%edi
xor    %eax,%eax
call   1090 <lprintf@plt>
mov    0x10(%rsp),%rdi
mov    0xc(%rsp),%esi
call   1080 <dump_end@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xb65(%rip),%rsi
mov    $0x1,%edi
xor    %eax,%eax
call   1090 <lprintf@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
mov    %ebp,%edx
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <data_dump@plt>
movzbl 0x1(%rbx),%edx
add    $0x1,%rbx
and    $0xf,%edx
lea    0xb42(%rip),%rsi
mov    $0x3,%edi
xor    %eax,%eax
call   1090 <lprintf@plt>
add    $0xffffffff,%r14d
mov    %rbx,%rdi
mov    %r14d,%esi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1080 <dump_end@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"FlexNet:\00"
@.str.1 = [13 x i8] c" bad packet\0A\00"
@.str.2 = [22 x i8] c" unknown packet type\0A\00"
@.str.3 = [27 x i8] c" Link setup - max SSID %d \00"
@.str.4 = [17 x i8] c" Poll response -\00"
@.str.5 = [12 x i8] c" delay: %d\0A\00"
@.str.6 = [6 x i8] c" Poll\00"
@.str.7 = [10 x i8] c" Routing\0A\00"
@.str.8 = [16 x i8] c" %.6s %2d-%2d \00"
@.str.9 = [11 x i8] c"link down\0A\00"
@.str.10 = [11 x i8] c"delay: %d\0A\00"
@.str.11 = [17 x i8] c" Request token\0A\00"
@.str.12 = [17 x i8] c" Release token\0A\00"
@.str.13 = [22 x i8] c" invalid char: %02x\0A\00"
@.str.14 = [13 x i8] c" Route query\00"
@.str.15 = [10 x i8] c" response\00"
@.str.16 = [33 x i8] c" - hop count: %d QSO number: %d\0A\00"
@.str.17 = [7 x i8] c" data\00"
@.str.18 = [19 x i8] c" packet too short\0A\00"
define void @flexnet_dump(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%11 = call i32 (i32, i8*, ...) @lprintf(i32 6, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* %5
%13 = icmp slt i32 %12, 1
br i1 %13, label %14, label %16
14: ; preds = %3
%15 = call i32 (i32, i8*, ...) @lprintf(i32 1, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %201
16: ; preds = %3
%17 = load i8*, i8** %4
%18 = getelementptr inbounds i8, i8* %17, i64 0
%19 = load i8, i8* %18
%20 = zext i8 %19 to i32
switch i32 %20, label %21 [
i32 48, label %27
i32 49, label %49
i32 50, label %69
i32 51, label %71
i32 54, label %157
i32 55, label %157
]
21: ; preds = %16
%22 = call i32 (i32, i8*, ...) @lprintf(i32 1, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%23 = load i8*, i8** %4
%24 = load i32, i32* %5
%25 = load i32, i32* %6
%26 = call i32 @data_dump(i8* %23, i32 %24, i32 %25)
br label %201
27: ; preds = %16
%28 = load i32, i32* %5
%29 = icmp slt i32 %28, 2
br i1 %29, label %30, label %37
30: ; preds = %27
%31 = call i32 (i32, i8*, ...) @lprintf(i32 1, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%32 = load i8*, i8** %4
%33 = getelementptr inbounds i8, i8* %32, i64 1
%34 = load i32, i32* %5
%35 = sub nsw i32 %34, 1
%36 = call i32 @dump_end(i8* %33, i32 %35)
br label %201
37: ; preds = %27
%38 = load i8*, i8** %4
%39 = getelementptr inbounds i8, i8* %38, i64 1
%40 = load i8, i8* %39
%41 = zext i8 %40 to i32
%42 = and i32 %41, 15
%43 = call i32 (i32, i8*, ...) @lprintf(i32 3, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %42)
%44 = load i8*, i8** %4
%45 = getelementptr inbounds i8, i8* %44, i64 1
%46 = load i32, i32* %5
%47 = sub nsw i32 %46, 1
%48 = call i32 @dump_end(i8* %45, i32 %47)
br label %201
49: ; preds = %16
%50 = call i32 (i32, i8*, ...) @lprintf(i32 3, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%51 = load i8*, i8** %4
%52 = getelementptr inbounds i8, i8* %51, i32 1
store i8* %52, i8** %4
%53 = load i32, i32* %5
%54 = add nsw i32 %53, -1
store i32 %54, i32* %5
%55 = call i32 @flx_get_number(i8** %4, i32* %5)
store i32 %55, i32* %7
%56 = load i8*, i8** %4
%57 = getelementptr inbounds i8, i8* %56, i32 1
store i8* %57, i8** %4
%58 = load i32, i32* %5
%59 = add nsw i32 %58, -1
store i32 %59, i32* %5
%60 = load i32, i32* %7
%61 = icmp slt i32 %60, 0
br i1 %61, label %62, label %63
62: ; preds = %49
br label %196
63: ; preds = %49
%64 = load i32, i32* %7
%65 = call i32 (i32, i8*, ...) @lprintf(i32 3, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %64)
%66 = load i8*, i8** %4
%67 = load i32, i32* %5
%68 = call i32 @dump_end(i8* %66, i32 %67)
br label %201
69: ; preds = %16
%70 = call i32 (i32, i8*, ...) @lprintf(i32 3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
br label %201
71: ; preds = %16
%72 = load i8*, i8** %4
%73 = getelementptr inbounds i8, i8* %72, i32 1
store i8* %73, i8** %4
%74 = load i32, i32* %5
%75 = add nsw i32 %74, -1
store i32 %75, i32* %5
%76 = call i32 (i32, i8*, ...) @lprintf(i32 3, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0))
br label %77
77: ; preds = %155, %71
%78 = load i32, i32* %5
%79 = icmp sgt i32 %78, 0
br i1 %79, label %80, label %156
80: ; preds = %77
%81 = load i8*, i8** %4
%82 = load i8, i8* %81
%83 = call i32 @isdigit(i8 zeroext %82)
%84 = icmp ne i32 %83, 0
br i1 %84, label %90, label %85
85: ; preds = %80
%86 = load i8*, i8** %4
%87 = load i8, i8* %86
%88 = call i32 @isupper(i8 zeroext %87)
%89 = icmp ne i32 %88, 0
br i1 %89, label %90, label %124
90: ; preds = %85, %80
%91 = load i32, i32* %5
%92 = icmp slt i32 %91, 10
br i1 %92, label %93, label %94
93: ; preds = %90
br label %196
94: ; preds = %90
%95 = load i8*, i8** %4
%96 = load i8*, i8** %4
%97 = getelementptr inbounds i8, i8* %96, i64 6
%98 = load i8, i8* %97
%99 = zext i8 %98 to i32
%100 = sub nsw i32 %99, 48
%101 = load i8*, i8** %4
%102 = getelementptr inbounds i8, i8* %101, i64 7
%103 = load i8, i8* %102
%104 = zext i8 %103 to i32
%105 = sub nsw i32 %104, 48
%106 = call i32 (i32, i8*, ...) @lprintf(i32 3, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i8* %95, i32 %100, i32 %105)
%107 = load i8*, i8** %4
%108 = getelementptr inbounds i8, i8* %107, i64 8
store i8* %108, i8** %4
%109 = load i32, i32* %5
%110 = sub nsw i32 %109, 8
store i32 %110, i32* %5
%111 = call i32 @flx_get_number(i8** %4, i32* %5)
store i32 %111, i32* %7
%112 = load i8*, i8** %4
%113 = getelementptr inbounds i8, i8* %112, i32 1
store i8* %113, i8** %4
%114 = load i32, i32* %5
%115 = add nsw i32 %114, -1
store i32 %115, i32* %5
%116 = load i32, i32* %7
%117 = icmp ne i32 %116, 0
br i1 %117, label %120, label %118
118: ; preds = %94
%119 = call i32 (i32, i8*, ...) @lprintf(i32 3, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0))
br label %123
120: ; preds = %94
%121 = load i32, i32* %7
%122 = call i32 (i32, i8*, ...) @lprintf(i32 3, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0), i32 %121)
br label %123
123: ; preds = %120, %118
br label %155
124: ; preds = %85
%125 = load i8*, i8** %4
%126 = load i8, i8* %125
%127 = zext i8 %126 to i32
%128 = icmp eq i32 %127, 43
br i1 %128, label %129, label %131
129: ; preds = %124
%130 = call i32 (i32, i8*, ...) @lprintf(i32 3, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0))
br label %150
131: ; preds = %124
%132 = load i8*, i8** %4
%133 = load i8, i8* %132
%134 = zext i8 %133 to i32
%135 = icmp eq i32 %134, 45
br i1 %135, label %136, label %138
136: ; preds = %131
%137 = call i32 (i32, i8*, ...) @lprintf(i32 3, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.12, i64 0, i64 0))
br label %149
138: ; preds = %131
%139 = load i8*, i8** %4
%140 = load i8, i8* %139
%141 = zext i8 %140 to i32
%142 = icmp ne i32 %141, 13
br i1 %142, label %143, label %148
143: ; preds = %138
%144 = load i8*, i8** %4
%145 = load i8, i8* %144
%146 = zext i8 %145 to i32
%147 = call i32 (i32, i8*, ...) @lprintf(i32 3, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.13, i64 0, i64 0), i32 %146)
br label %148
148: ; preds = %143, %138
br label %149
149: ; preds = %148, %136
br label %150
150: ; preds = %149, %129
%151 = load i8*, i8** %4
%152 = getelementptr inbounds i8, i8* %151, i32 1
store i8* %152, i8** %4
%153 = load i32, i32* %5
%154 = add nsw i32 %153, -1
store i32 %154, i32* %5
br label %155
155: ; preds = %150, %123
br label %77
156: ; preds = %77
br label %201
157: ; preds = %16, %16
%158 = call i32 (i32, i8*, ...) @lprintf(i32 3, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.14, i64 0, i64 0))
%159 = load i8*, i8** %4
%160 = load i8, i8* %159
%161 = zext i8 %160 to i32
%162 = icmp eq i32 %161, 55
br i1 %162, label %163, label %165
163: ; preds = %157
%164 = call i32 (i32, i8*, ...) @lprintf(i32 3, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i64 0, i64 0))
br label %165
165: ; preds = %163, %157
%166 = load i32, i32* %5
%167 = icmp slt i32 %166, 2
br i1 %167, label %168, label %169
168: ; preds = %165
br label %196
169: ; preds = %165
%170 = load i8*, i8** %4
%171 = getelementptr inbounds i8, i8* %170, i64 1
%172 = load i8, i8* %171
%173 = zext i8 %172 to i32
%174 = sub nsw i32 %173, 32
store i32 %174, i32* %8
%175 = load i8*, i8** %4
%176 = getelementptr inbounds i8, i8* %175, i64 2
store i8* %176, i8** %4
%177 = load i32, i32* %5
%178 = sub nsw i32 %177, 2
store i32 %178, i32* %5
%179 = call i32 @flx_get_number(i8** %4, i32* %5)
store i32 %179, i32* %9
%180 = load i8*, i8** %4
%181 = getelementptr inbounds i8, i8* %180, i32 1
store i8* %181, i8** %4
%182 = load i32, i32* %5
%183 = add nsw i32 %182, -1
store i32 %183, i32* %5
%184 = load i32, i32* %8
%185 = load i32, i32* %9
%186 = call i32 (i32, i8*, ...) @lprintf(i32 3, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.16, i64 0, i64 0), i32 %184, i32 %185)
%187 = load i8*, i8** %4
%188 = load i32, i32* %5
%189 = call i8* @memchr(i8* %187, i8 signext 13, i32 %188)
store i8* %189, i8** %10
%190 = load i8*, i8** %10
%191 = icmp ne i8* %190, null
br i1 %191, label %192, label %194
192: ; preds = %169
%193 = load i8*, i8** %10
store i8 0, i8* %193
br label %194
194: ; preds = %192, %169
%195 = call i32 (i32, i8*, ...) @lprintf(i32 3, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.17, i64 0, i64 0))
br label %201
196: ; preds = %168, %93, %62
%197 = call i32 (i32, i8*, ...) @lprintf(i32 1, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.18, i64 0, i64 0))
%198 = load i8*, i8** %4
%199 = load i32, i32* %5
%200 = call i32 @dump_end(i8* %198, i32 %199)
br label %201
201: ; preds = %196, %194, %156, %69, %63, %37, %30, %21, %14
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"FlexNet:\00"
@.str.1 = [13 x i8] c" bad packet\0A\00"
@.str.2 = [22 x i8] c" unknown packet type\0A\00"
@.str.3 = [27 x i8] c" Link setup - max SSID %d \00"
@.str.4 = [17 x i8] c" Poll response -\00"
@.str.5 = [12 x i8] c" delay: %d\0A\00"
@.str.6 = [6 x i8] c" Poll\00"
@.str.7 = [10 x i8] c" Routing\0A\00"
@.str.8 = [16 x i8] c" %.6s %2d-%2d \00"
@.str.9 = [11 x i8] c"link down\0A\00"
@.str.10 = [11 x i8] c"delay: %d\0A\00"
@.str.11 = [17 x i8] c" Request token\0A\00"
@.str.12 = [17 x i8] c" Release token\0A\00"
@.str.13 = [22 x i8] c" invalid char: %02x\0A\00"
@.str.14 = [13 x i8] c" Route query\00"
@.str.15 = [10 x i8] c" response\00"
@.str.16 = [33 x i8] c" - hop count: %d QSO number: %d\0A\00"
@.str.17 = [7 x i8] c" data\00"
@.str.18 = [19 x i8] c" packet too short\0A\00"
define void @flexnet_dump(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%6 = tail call i32 (i32, i8*, ...) @lprintf(i32 6, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%7 = icmp slt i32 %1, 1
br i1 %7, label %8, label %10
8: ; preds = %3
%9 = tail call i32 (i32, i8*, ...) @lprintf(i32 1, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %145
10: ; preds = %3
%11 = load i8, i8* %0
switch i8 %11, label %12 [
i8 48, label %15
i8 49, label %30
i8 50, label %45
i8 51, label %47
i8 54, label %112
i8 55, label %112
]
12: ; preds = %10
%13 = tail call i32 (i32, i8*, ...) @lprintf(i32 1, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%14 = tail call i32 @data_dump(i8* %0, i32 %1, i32 %2)
br label %145
15: ; preds = %10
%16 = icmp ult i32 %1, 2
br i1 %16, label %17, label %22
17: ; preds = %15
%18 = tail call i32 (i32, i8*, ...) @lprintf(i32 1, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%19 = getelementptr inbounds i8, i8* %0, i64 1
%20 = add nsw i32 %1, -1
%21 = tail call i32 @dump_end(i8* %19, i32 %20)
br label %145
22: ; preds = %15
%23 = getelementptr inbounds i8, i8* %0, i64 1
%24 = load i8, i8* %23
%25 = and i8 %24, 15
%26 = zext i8 %25 to i32
%27 = tail call i32 (i32, i8*, ...) @lprintf(i32 3, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %26)
%28 = add nsw i32 %1, -1
%29 = tail call i32 @dump_end(i8* %23, i32 %28)
br label %145
30: ; preds = %10
%31 = tail call i32 (i32, i8*, ...) @lprintf(i32 3, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%32 = getelementptr inbounds i8, i8* %0, i64 1
store i8* %32, i8** %4
%33 = add nsw i32 %1, -1
store i32 %33, i32* %5
%34 = call i32 @flx_get_number(i8** %4, i32* %5)
%35 = load i8*, i8** %4
%36 = getelementptr inbounds i8, i8* %35, i64 1
store i8* %36, i8** %4
%37 = load i32, i32* %5
%38 = add nsw i32 %37, -1
store i32 %38, i32* %5
%39 = icmp slt i32 %34, 0
br i1 %39, label %140, label %40
40: ; preds = %30
%41 = call i32 (i32, i8*, ...) @lprintf(i32 3, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %34)
%42 = load i8*, i8** %4
%43 = load i32, i32* %5
%44 = call i32 @dump_end(i8* %42, i32 %43)
br label %145
45: ; preds = %10
%46 = tail call i32 (i32, i8*, ...) @lprintf(i32 3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
br label %145
47: ; preds = %10
%48 = getelementptr inbounds i8, i8* %0, i64 1
store i8* %48, i8** %4
%49 = add nsw i32 %1, -1
store i32 %49, i32* %5
%50 = tail call i32 (i32, i8*, ...) @lprintf(i32 3, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0))
%51 = icmp ugt i32 %1, 1
br i1 %51, label %52, label %145
52: ; preds = %47, %110
%53 = phi i8* [ %111, %110 ], [ %48, %47 ]
%54 = load i8, i8* %53
%55 = call i32 @isdigit(i8 zeroext %54)
%56 = icmp eq i32 %55, 0
br i1 %56, label %57, label %62
57: ; preds = %52
%58 = load i8*, i8** %4
%59 = load i8, i8* %58
%60 = call i32 @isupper(i8 zeroext %59)
%61 = icmp eq i32 %60, 0
br i1 %61, label %90, label %62
62: ; preds = %57, %52
%63 = load i32, i32* %5
%64 = icmp slt i32 %63, 10
br i1 %64, label %140, label %65
65: ; preds = %62
%66 = load i8*, i8** %4
%67 = getelementptr inbounds i8, i8* %66, i64 6
%68 = load i8, i8* %67
%69 = zext i8 %68 to i32
%70 = add nsw i32 %69, -48
%71 = getelementptr inbounds i8, i8* %66, i64 7
%72 = load i8, i8* %71
%73 = zext i8 %72 to i32
%74 = add nsw i32 %73, -48
%75 = call i32 (i32, i8*, ...) @lprintf(i32 3, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i8* %66, i32 %70, i32 %74)
%76 = load i8*, i8** %4
%77 = getelementptr inbounds i8, i8* %76, i64 8
store i8* %77, i8** %4
%78 = load i32, i32* %5
%79 = add nsw i32 %78, -8
store i32 %79, i32* %5
%80 = call i32 @flx_get_number(i8** %4, i32* %5)
%81 = load i8*, i8** %4
%82 = getelementptr inbounds i8, i8* %81, i64 1
store i8* %82, i8** %4
%83 = load i32, i32* %5
%84 = add nsw i32 %83, -1
store i32 %84, i32* %5
%85 = icmp eq i32 %80, 0
br i1 %85, label %86, label %88
86: ; preds = %65
%87 = call i32 (i32, i8*, ...) @lprintf(i32 3, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0))
br label %105
88: ; preds = %65
%89 = call i32 (i32, i8*, ...) @lprintf(i32 3, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0), i32 %80)
br label %105
90: ; preds = %57
%91 = load i8*, i8** %4
%92 = load i8, i8* %91
switch i8 %92, label %97 [
i8 43, label %93
i8 45, label %95
i8 13, label %100
]
93: ; preds = %90
%94 = call i32 (i32, i8*, ...) @lprintf(i32 3, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0))
br label %100
95: ; preds = %90
%96 = call i32 (i32, i8*, ...) @lprintf(i32 3, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.12, i64 0, i64 0))
br label %100
97: ; preds = %90
%98 = zext i8 %92 to i32
%99 = call i32 (i32, i8*, ...) @lprintf(i32 3, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.13, i64 0, i64 0), i32 %98)
br label %100
100: ; preds = %90, %95, %97, %93
%101 = load i8*, i8** %4
%102 = getelementptr inbounds i8, i8* %101, i64 1
store i8* %102, i8** %4
%103 = load i32, i32* %5
%104 = add nsw i32 %103, -1
store i32 %104, i32* %5
br label %107
105: ; preds = %88, %86
%106 = load i32, i32* %5
br label %107
107: ; preds = %105, %100
%108 = phi i32 [ %106, %105 ], [ %104, %100 ]
%109 = icmp sgt i32 %108, 0
br i1 %109, label %110, label %145
110: ; preds = %107
%111 = load i8*, i8** %4
br label %52
112: ; preds = %10, %10
%113 = tail call i32 (i32, i8*, ...) @lprintf(i32 3, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.14, i64 0, i64 0))
%114 = load i8, i8* %0
%115 = icmp eq i8 %114, 55
br i1 %115, label %116, label %118
116: ; preds = %112
%117 = tail call i32 (i32, i8*, ...) @lprintf(i32 3, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i64 0, i64 0))
br label %118
118: ; preds = %116, %112
%119 = icmp ult i32 %1, 2
br i1 %119, label %140, label %120
120: ; preds = %118
%121 = getelementptr inbounds i8, i8* %0, i64 1
%122 = load i8, i8* %121
%123 = zext i8 %122 to i32
%124 = add nsw i32 %123, -32
%125 = getelementptr inbounds i8, i8* %0, i64 2
store i8* %125, i8** %4
%126 = add nsw i32 %1, -2
store i32 %126, i32* %5
%127 = call i32 @flx_get_number(i8** %4, i32* %5)
%128 = load i8*, i8** %4
%129 = getelementptr inbounds i8, i8* %128, i64 1
store i8* %129, i8** %4
%130 = load i32, i32* %5
%131 = add nsw i32 %130, -1
store i32 %131, i32* %5
%132 = call i32 (i32, i8*, ...) @lprintf(i32 3, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.16, i64 0, i64 0), i32 %124, i32 %127)
%133 = load i8*, i8** %4
%134 = load i32, i32* %5
%135 = call i8* @memchr(i8* %133, i8 signext 13, i32 %134)
%136 = icmp eq i8* %135, null
br i1 %136, label %138, label %137
137: ; preds = %120
store i8 0, i8* %135
br label %138
138: ; preds = %137, %120
%139 = call i32 (i32, i8*, ...) @lprintf(i32 3, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.17, i64 0, i64 0))
br label %145
140: ; preds = %62, %118, %30
%141 = call i32 (i32, i8*, ...) @lprintf(i32 1, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.18, i64 0, i64 0))
%142 = load i8*, i8** %4
%143 = load i32, i32* %5
%144 = call i32 @dump_end(i8* %142, i32 %143)
br label %145
145: ; preds = %107, %47, %140, %138, %45, %40, %22, %17, %12, %8
ret void
}