#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*/ ax25_dump(unsigned char *, int, int);
int /*<<< orphan*/ data_dump(unsigned char *, int, int);
int get16(unsigned char *);
int /*<<< orphan*/ icmp_dump(unsigned char *, int, int);
int /*<<< orphan*/ lprintf(int, char *, ...);
int /*<<< orphan*/ rspf_dump(unsigned char *, int);
int /*<<< orphan*/ tcp_dump(unsigned char *, int, int);
int /*<<< orphan*/ udp_dump(unsigned char *, int, int);
void ip_dump(unsigned char *data, int length, int hexdump) {
  int hdr_length;
  int tos;
  int ip_length;
  int id;
  int fl_offs;
  int flags;
  int offset;
  int ttl;
  int protocol;
  unsigned char *source, *dest;
  lprintf(6, "IP:");
  hdr_length = (data[0] & 0xf) << 2;
  if (hdr_length < 20) {
    lprintf(1, " bad header\n");
    return;
  }
  tos = data[1];
  ip_length = get16(data + 2);
  id = get16(data + 4);
  fl_offs = get16(data + 6);
  flags = fl_offs & 0xE000;
  offset = (fl_offs & 0x1FFF) << 3;
  ttl = data[8];
  protocol = data[9];
  source = data + 12;
  dest = data + 16;
  lprintf(9, " len %d", ip_length);
  lprintf(8, " %d.%d.%d.%d->%d.%d.%d.%d", source[0], source[1], source[2],
          source[3], dest[0], dest[1], dest[2], dest[3]);
  lprintf(9, " ihl %d ttl %d", hdr_length, ttl);
  if (tos != 0)
    lprintf(9, " tos %d", tos);
  if (offset != 0 || (flags & 0x2000))
    lprintf(9, " id %d offs %d", id, offset);
  if (flags & 0x4000)
    lprintf(9, " DF");
  if (flags & 0x2000)
    lprintf(9, " MF");
  if (flags & 0x8000)
    lprintf(9, " CE");
  data += hdr_length;
  length -= hdr_length;
  if (offset != 0) {
    lprintf(9, "\n");
    if (length > 0)
      data_dump(data, length, hexdump);
    return;
  }
  switch (protocol) {
  case 94:
  case 4:
    lprintf(9, " prot IP\n");
    ip_dump(data, length, hexdump);
    break;
  case 6:
    lprintf(9, " prot TCP\n");
    tcp_dump(data, length, hexdump);
    break;
  case 17:
    lprintf(9, " prot UDP\n");
    udp_dump(data, length, hexdump);
    break;
  case 1:
    lprintf(9, " prot ICMP\n");
    icmp_dump(data, length, hexdump);
    break;
  case 93:
    lprintf(9, " prot AX25\n");
    ax25_dump(data, length, hexdump);
    break;
  case 73:
    lprintf(9, " prot RSPF\n");
    rspf_dump(data, length);
    break;
  default:
    lprintf(9, " prot %d\n", protocol);
    data_dump(data, length, hexdump);
    break;
  }
}


x86 assembly (clang, -O0):
<ip_dump>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x78,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    $0x6,%edi
lea    0xe51(%rip),%rsi
mov    $0x0,%al
call   10b0 <lprintf@plt>
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
and    $0xf,%eax
shl    $0x2,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x14,-0x1c(%rbp)
jge    11e8 <ip_dump+0x58>
mov    $0x1,%edi
lea    0xe28(%rip),%rsi
mov    $0x0,%al
call   10b0 <lprintf@plt>
jmp    159c <ip_dump+0x40c>
mov    -0x10(%rbp),%rax
movzbl 0x1(%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x2,%rdi
call   10a0 <get16@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x4,%rdi
call   10a0 <get16@plt>
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x6,%rdi
call   10a0 <get16@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
and    $0xe000,%eax
mov    %eax,-0x30(%rbp)
mov    -0x2c(%rbp),%eax
and    $0x1fff,%eax
shl    $0x3,%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rax
movzbl 0x8(%rax),%eax
mov    %eax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
movzbl 0x9(%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x10(%rbp),%rax
add    $0xc,%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x50(%rbp)
mov    -0x24(%rbp),%edx
mov    $0x9,%edi
lea    0xd98(%rip),%rsi
mov    $0x0,%al
call   10b0 <lprintf@plt>
mov    -0x48(%rbp),%rax
movzbl (%rax),%edx
mov    -0x48(%rbp),%rax
movzbl 0x1(%rax),%ecx
mov    -0x48(%rbp),%rax
movzbl 0x2(%rax),%r8d
mov    -0x48(%rbp),%rax
movzbl 0x3(%rax),%r9d
mov    -0x50(%rbp),%rax
movzbl (%rax),%ebx
mov    -0x50(%rbp),%rax
movzbl 0x1(%rax),%r11d
mov    -0x50(%rbp),%rax
movzbl 0x2(%rax),%r10d
mov    -0x50(%rbp),%rax
movzbl 0x3(%rax),%eax
mov    $0x8,%edi
lea    0xd4b(%rip),%rsi
mov    %ebx,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %eax,0x18(%rsp)
mov    $0x0,%al
call   10b0 <lprintf@plt>
mov    -0x1c(%rbp),%edx
mov    -0x38(%rbp),%ecx
mov    $0x9,%edi
lea    0xd3b(%rip),%rsi
mov    $0x0,%al
call   10b0 <lprintf@plt>
cmpl   $0x0,-0x20(%rbp)
je     131f <ip_dump+0x18f>
mov    -0x20(%rbp),%edx
mov    $0x9,%edi
lea    0xd2a(%rip),%rsi
mov    $0x0,%al
call   10b0 <lprintf@plt>
cmpl   $0x0,-0x34(%rbp)
jne    133a <ip_dump+0x1aa>
mov    -0x30(%rbp),%eax
and    $0x2000,%eax
cmp    $0x0,%eax
je     1353 <ip_dump+0x1c3>
mov    -0x28(%rbp),%edx
mov    -0x34(%rbp),%ecx
mov    $0x9,%edi
lea    0xcfe(%rip),%rsi
mov    $0x0,%al
call   10b0 <lprintf@plt>
mov    -0x30(%rbp),%eax
and    $0x4000,%eax
cmp    $0x0,%eax
je     1377 <ip_dump+0x1e7>
mov    $0x9,%edi
lea    0xce9(%rip),%rsi
mov    $0x0,%al
call   10b0 <lprintf@plt>
mov    -0x30(%rbp),%eax
and    $0x2000,%eax
cmp    $0x0,%eax
je     139b <ip_dump+0x20b>
mov    $0x9,%edi
lea    0xcc9(%rip),%rsi
mov    $0x0,%al
call   10b0 <lprintf@plt>
mov    -0x30(%rbp),%eax
and    $0x8000,%eax
cmp    $0x0,%eax
je     13bf <ip_dump+0x22f>
mov    $0x9,%edi
lea    0xca9(%rip),%rsi
mov    $0x0,%al
call   10b0 <lprintf@plt>
mov    -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x1c(%rbp),%ecx
mov    -0x14(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x34(%rbp)
je     1416 <ip_dump+0x286>
mov    $0x9,%edi
lea    0xcaa(%rip),%rsi
mov    $0x0,%al
call   10b0 <lprintf@plt>
cmpl   $0x0,-0x14(%rbp)
jle    1411 <ip_dump+0x281>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1050 <data_dump@plt>
jmp    159c <ip_dump+0x40c>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x54(%rbp)
sub    $0x1,%eax
je     1505 <ip_dump+0x375>
jmp    142a <ip_dump+0x29a>
mov    -0x54(%rbp),%eax
sub    $0x4,%eax
je     1490 <ip_dump+0x300>
jmp    143b <ip_dump+0x2ab>
mov    -0x54(%rbp),%eax
sub    $0x6,%eax
je     14b7 <ip_dump+0x327>
jmp    144c <ip_dump+0x2bc>
mov    -0x54(%rbp),%eax
sub    $0x11,%eax
je     14de <ip_dump+0x34e>
jmp    145d <ip_dump+0x2cd>
mov    -0x54(%rbp),%eax
sub    $0x49,%eax
je     1553 <ip_dump+0x3c3>
jmp    146e <ip_dump+0x2de>
mov    -0x54(%rbp),%eax
sub    $0x5d,%eax
je     152c <ip_dump+0x39c>
jmp    147f <ip_dump+0x2ef>
mov    -0x54(%rbp),%eax
sub    $0x5e,%eax
jne    1577 <ip_dump+0x3e7>
jmp    1490 <ip_dump+0x300>
mov    $0x9,%edi
lea    0xbc9(%rip),%rsi
mov    $0x0,%al
call   10b0 <lprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1090 <ip_dump@plt>
jmp    159c <ip_dump+0x40c>
mov    $0x9,%edi
lea    0xbac(%rip),%rsi
mov    $0x0,%al
call   10b0 <lprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1040 <tcp_dump@plt>
jmp    159c <ip_dump+0x40c>
mov    $0x9,%edi
lea    0xb90(%rip),%rsi
mov    $0x0,%al
call   10b0 <lprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1030 <udp_dump@plt>
jmp    159c <ip_dump+0x40c>
mov    $0x9,%edi
lea    0xb74(%rip),%rsi
mov    $0x0,%al
call   10b0 <lprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1070 <icmp_dump@plt>
jmp    159c <ip_dump+0x40c>
mov    $0x9,%edi
lea    0xb59(%rip),%rsi
mov    $0x0,%al
call   10b0 <lprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1060 <ax25_dump@plt>
jmp    159c <ip_dump+0x40c>
mov    $0x9,%edi
lea    0xb3e(%rip),%rsi
mov    $0x0,%al
call   10b0 <lprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1080 <rspf_dump@plt>
jmp    159c <ip_dump+0x40c>
mov    -0x3c(%rbp),%edx
mov    $0x9,%edi
lea    0xb23(%rip),%rsi
mov    $0x0,%al
call   10b0 <lprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1050 <data_dump@plt>
add    $0x78,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<ip_dump>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %edx,0x8(%rsp)
mov    %esi,%r14d
mov    %rdi,%rbp
lea    0xea5(%rip),%rsi
mov    $0x6,%edi
jmp    11d8 <ip_dump+0x58>
cs nopw 0x0(%rax,%rax,1)
cmp    $0x5e,%dl
jne    13cf <ip_dump+0x24f>
mov    $0x9,%edi
lea    0xee4(%rip),%rsi
xor    %eax,%eax
call   10a0 <lprintf@plt>
mov    $0x6,%edi
lea    0xe6c(%rip),%rsi
xor    %eax,%eax
call   10a0 <lprintf@plt>
movzbl 0x0(%rbp),%eax
shl    $0x2,%al
and    $0x3c,%al
cmp    $0x14,%al
jb     13ae <ip_dump+0x22e>
mov    %r14d,0x1c(%rsp)
movzbl %al,%r13d
movzbl 0x1(%rbp),%eax
mov    %eax,0x14(%rsp)
lea    0x2(%rbp),%rdi
call   1090 <get16@plt>
mov    %eax,%r14d
lea    0x4(%rbp),%rdi
call   1090 <get16@plt>
mov    %eax,0xc(%rsp)
lea    0x6(%rbp),%rdi
call   1090 <get16@plt>
mov    %eax,%r12d
lea    0x0(,%r12,8),%eax
mov    %eax,0x10(%rsp)
movzbl 0x8(%rbp),%r15d
movzbl 0x9(%rbp),%eax
mov    %rax,0x20(%rsp)
mov    $0x9,%edi
lea    0xe09(%rip),%rsi
mov    %r14d,%edx
xor    %eax,%eax
call   10a0 <lprintf@plt>
movzbl 0xc(%rbp),%edx
movzbl 0xd(%rbp),%ecx
movzbl 0xe(%rbp),%r8d
movzbl 0xf(%rbp),%r9d
movzbl 0x10(%rbp),%r10d
movzbl 0x11(%rbp),%r11d
movzbl 0x12(%rbp),%r14d
movzbl 0x13(%rbp),%ebx
mov    $0x8,%edi
lea    0xdd6(%rip),%rsi
xor    %eax,%eax
push   %rbx
push   %r14
push   %r11
push   %r10
call   10a0 <lprintf@plt>
add    $0x20,%rsp
mov    $0x9,%edi
lea    0xdd2(%rip),%rsi
mov    %r13d,0x18(%rsp)
mov    %r13d,%edx
mov    %r15d,%ecx
xor    %eax,%eax
call   10a0 <lprintf@plt>
mov    0x14(%rsp),%edx
test   %edx,%edx
je     12d2 <ip_dump+0x152>
mov    $0x9,%edi
lea    0xdbb(%rip),%rsi
xor    %eax,%eax
call   10a0 <lprintf@plt>
movzwl 0x10(%rsp),%ebx
mov    %r12d,%eax
and    $0x2000,%eax
or     %ebx,%eax
je     12fc <ip_dump+0x17c>
mov    $0x9,%edi
lea    0xd9f(%rip),%rsi
mov    0xc(%rsp),%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   10a0 <lprintf@plt>
test   $0x4000,%r12d
mov    0x1c(%rsp),%r14d
jne    1370 <ip_dump+0x1f0>
test   $0x2000,%r12d
jne    138c <ip_dump+0x20c>
test   $0x8000,%r12d
je     132f <ip_dump+0x1af>
mov    $0x9,%edi
lea    0xd7d(%rip),%rsi
xor    %eax,%eax
call   10a0 <lprintf@plt>
mov    0x18(%rsp),%ecx
mov    %ecx,%eax
add    %rax,%rbp
sub    %ecx,%r14d
test   %ebx,%ebx
jne    1411 <ip_dump+0x291>
mov    0x20(%rsp),%rdx
cmp    $0x48,%dl
jg     11b0 <ip_dump+0x30>
lea    -0x1(%rdx),%eax
cmp    $0x10,%al
ja     14f8 <ip_dump+0x378>
movzbl %al,%eax
lea    0xc9a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
nop
mov    $0x9,%edi
lea    0xd21(%rip),%rsi
xor    %eax,%eax
call   10a0 <lprintf@plt>
test   $0x2000,%r12d
je     1313 <ip_dump+0x193>
mov    $0x9,%edi
lea    0xd09(%rip),%rsi
xor    %eax,%eax
call   10a0 <lprintf@plt>
test   $0x8000,%r12d
jne    131c <ip_dump+0x19c>
jmp    132f <ip_dump+0x1af>
lea    0xc93(%rip),%rsi
mov    $0x1,%edi
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    10a0 <lprintf@plt>
cmp    $0x49,%dl
je     14cc <ip_dump+0x34c>
cmp    $0x5d,%dl
jne    14f8 <ip_dump+0x378>
lea    0xced(%rip),%rsi
mov    $0x9,%edi
xor    %eax,%eax
call   10a0 <lprintf@plt>
mov    %rbp,%rdi
mov    %r14d,%esi
mov    0x8(%rsp),%edx
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <ax25_dump@plt>
lea    0xcc7(%rip),%rsi
mov    $0x9,%edi
xor    %eax,%eax
call   10a0 <lprintf@plt>
test   %r14d,%r14d
jg     150b <ip_dump+0x38b>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc86(%rip),%rsi
mov    $0x9,%edi
xor    %eax,%eax
call   10a0 <lprintf@plt>
mov    %rbp,%rdi
mov    %r14d,%esi
mov    0x8(%rsp),%edx
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <icmp_dump@plt>
lea    0xc40(%rip),%rsi
mov    $0x9,%edi
xor    %eax,%eax
call   10a0 <lprintf@plt>
mov    %rbp,%rdi
mov    %r14d,%esi
mov    0x8(%rsp),%edx
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <tcp_dump@plt>
lea    0xc1b(%rip),%rsi
mov    $0x9,%edi
xor    %eax,%eax
call   10a0 <lprintf@plt>
mov    %rbp,%rdi
mov    %r14d,%esi
mov    0x8(%rsp),%edx
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <udp_dump@plt>
lea    0xc0e(%rip),%rsi
mov    $0x9,%edi
xor    %eax,%eax
call   10a0 <lprintf@plt>
mov    %rbp,%rdi
mov    %r14d,%esi
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1080 <rspf_dump@plt>
lea    0xbee(%rip),%rsi
mov    $0x9,%edi
xor    %eax,%eax
call   10a0 <lprintf@plt>
mov    %rbp,%rdi
mov    %r14d,%esi
mov    0x8(%rsp),%edx
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <data_dump@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"IP:\00"
@.str.1 = [13 x i8] c" bad header\0A\00"
@.str.2 = [8 x i8] c" len %d\00"
@.str.3 = [26 x i8] c" %d.%d.%d.%d->%d.%d.%d.%d\00"
@.str.4 = [15 x i8] c" ihl %d ttl %d\00"
@.str.5 = [8 x i8] c" tos %d\00"
@.str.6 = [15 x i8] c" id %d offs %d\00"
@.str.7 = [4 x i8] c" DF\00"
@.str.8 = [4 x i8] c" MF\00"
@.str.9 = [4 x i8] c" CE\00"
@.str.10 = [2 x i8] c"\0A\00"
@.str.11 = [10 x i8] c" prot IP\0A\00"
@.str.12 = [11 x i8] c" prot TCP\0A\00"
@.str.13 = [11 x i8] c" prot UDP\0A\00"
@.str.14 = [12 x i8] c" prot ICMP\0A\00"
@.str.15 = [12 x i8] c" prot AX25\0A\00"
@.str.16 = [12 x i8] c" prot RSPF\0A\00"
@.str.17 = [10 x i8] c" prot %d\0A\00"
define void @ip_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 i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i8*
%17 = alloca i8*
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%18 = call i32 (i32, i8*, ...) @lprintf(i32 6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%19 = load i8*, i8** %4
%20 = getelementptr inbounds i8, i8* %19, i64 0
%21 = load i8, i8* %20
%22 = zext i8 %21 to i32
%23 = and i32 %22, 15
%24 = shl i32 %23, 2
store i32 %24, i32* %7
%25 = load i32, i32* %7
%26 = icmp slt i32 %25, 20
br i1 %26, label %27, label %29
27: ; preds = %3
%28 = call i32 (i32, i8*, ...) @lprintf(i32 1, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %195
29: ; preds = %3
%30 = load i8*, i8** %4
%31 = getelementptr inbounds i8, i8* %30, i64 1
%32 = load i8, i8* %31
%33 = zext i8 %32 to i32
store i32 %33, i32* %8
%34 = load i8*, i8** %4
%35 = getelementptr inbounds i8, i8* %34, i64 2
%36 = call i32 @get16(i8* %35)
store i32 %36, i32* %9
%37 = load i8*, i8** %4
%38 = getelementptr inbounds i8, i8* %37, i64 4
%39 = call i32 @get16(i8* %38)
store i32 %39, i32* %10
%40 = load i8*, i8** %4
%41 = getelementptr inbounds i8, i8* %40, i64 6
%42 = call i32 @get16(i8* %41)
store i32 %42, i32* %11
%43 = load i32, i32* %11
%44 = and i32 %43, 57344
store i32 %44, i32* %12
%45 = load i32, i32* %11
%46 = and i32 %45, 8191
%47 = shl i32 %46, 3
store i32 %47, i32* %13
%48 = load i8*, i8** %4
%49 = getelementptr inbounds i8, i8* %48, i64 8
%50 = load i8, i8* %49
%51 = zext i8 %50 to i32
store i32 %51, i32* %14
%52 = load i8*, i8** %4
%53 = getelementptr inbounds i8, i8* %52, i64 9
%54 = load i8, i8* %53
%55 = zext i8 %54 to i32
store i32 %55, i32* %15
%56 = load i8*, i8** %4
%57 = getelementptr inbounds i8, i8* %56, i64 12
store i8* %57, i8** %16
%58 = load i8*, i8** %4
%59 = getelementptr inbounds i8, i8* %58, i64 16
store i8* %59, i8** %17
%60 = load i32, i32* %9
%61 = call i32 (i32, i8*, ...) @lprintf(i32 9, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %60)
%62 = load i8*, i8** %16
%63 = getelementptr inbounds i8, i8* %62, i64 0
%64 = load i8, i8* %63
%65 = zext i8 %64 to i32
%66 = load i8*, i8** %16
%67 = getelementptr inbounds i8, i8* %66, i64 1
%68 = load i8, i8* %67
%69 = zext i8 %68 to i32
%70 = load i8*, i8** %16
%71 = getelementptr inbounds i8, i8* %70, i64 2
%72 = load i8, i8* %71
%73 = zext i8 %72 to i32
%74 = load i8*, i8** %16
%75 = getelementptr inbounds i8, i8* %74, i64 3
%76 = load i8, i8* %75
%77 = zext i8 %76 to i32
%78 = load i8*, i8** %17
%79 = getelementptr inbounds i8, i8* %78, i64 0
%80 = load i8, i8* %79
%81 = zext i8 %80 to i32
%82 = load i8*, i8** %17
%83 = getelementptr inbounds i8, i8* %82, i64 1
%84 = load i8, i8* %83
%85 = zext i8 %84 to i32
%86 = load i8*, i8** %17
%87 = getelementptr inbounds i8, i8* %86, i64 2
%88 = load i8, i8* %87
%89 = zext i8 %88 to i32
%90 = load i8*, i8** %17
%91 = getelementptr inbounds i8, i8* %90, i64 3
%92 = load i8, i8* %91
%93 = zext i8 %92 to i32
%94 = call i32 (i32, i8*, ...) @lprintf(i32 8, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %65, i32 %69, i32 %73, i32 %77, i32 %81, i32 %85, i32 %89, i32 %93)
%95 = load i32, i32* %7
%96 = load i32, i32* %14
%97 = call i32 (i32, i8*, ...) @lprintf(i32 9, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %95, i32 %96)
%98 = load i32, i32* %8
%99 = icmp ne i32 %98, 0
br i1 %99, label %100, label %103
100: ; preds = %29
%101 = load i32, i32* %8
%102 = call i32 (i32, i8*, ...) @lprintf(i32 9, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32 %101)
br label %103
103: ; preds = %100, %29
%104 = load i32, i32* %13
%105 = icmp ne i32 %104, 0
br i1 %105, label %110, label %106
106: ; preds = %103
%107 = load i32, i32* %12
%108 = and i32 %107, 8192
%109 = icmp ne i32 %108, 0
br i1 %109, label %110, label %114
110: ; preds = %106, %103
%111 = load i32, i32* %10
%112 = load i32, i32* %13
%113 = call i32 (i32, i8*, ...) @lprintf(i32 9, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i32 %111, i32 %112)
br label %114
114: ; preds = %110, %106
%115 = load i32, i32* %12
%116 = and i32 %115, 16384
%117 = icmp ne i32 %116, 0
br i1 %117, label %118, label %120
118: ; preds = %114
%119 = call i32 (i32, i8*, ...) @lprintf(i32 9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
br label %120
120: ; preds = %118, %114
%121 = load i32, i32* %12
%122 = and i32 %121, 8192
%123 = icmp ne i32 %122, 0
br i1 %123, label %124, label %126
124: ; preds = %120
%125 = call i32 (i32, i8*, ...) @lprintf(i32 9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
br label %126
126: ; preds = %124, %120
%127 = load i32, i32* %12
%128 = and i32 %127, 32768
%129 = icmp ne i32 %128, 0
br i1 %129, label %130, label %132
130: ; preds = %126
%131 = call i32 (i32, i8*, ...) @lprintf(i32 9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
br label %132
132: ; preds = %130, %126
%133 = load i32, i32* %7
%134 = load i8*, i8** %4
%135 = sext i32 %133 to i64
%136 = getelementptr inbounds i8, i8* %134, i64 %135
store i8* %136, i8** %4
%137 = load i32, i32* %7
%138 = load i32, i32* %5
%139 = sub nsw i32 %138, %137
store i32 %139, i32* %5
%140 = load i32, i32* %13
%141 = icmp ne i32 %140, 0
br i1 %141, label %142, label %152
142: ; preds = %132
%143 = call i32 (i32, i8*, ...) @lprintf(i32 9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%144 = load i32, i32* %5
%145 = icmp sgt i32 %144, 0
br i1 %145, label %146, label %151
146: ; preds = %142
%147 = load i8*, i8** %4
%148 = load i32, i32* %5
%149 = load i32, i32* %6
%150 = call i32 @data_dump(i8* %147, i32 %148, i32 %149)
br label %151
151: ; preds = %146, %142
br label %195
152: ; preds = %132
%153 = load i32, i32* %15
switch i32 %153, label %188 [
i32 94, label %154
i32 4, label %154
i32 6, label %159
i32 17, label %165
i32 1, label %171
i32 93, label %177
i32 73, label %183
]
154: ; preds = %152, %152
%155 = call i32 (i32, i8*, ...) @lprintf(i32 9, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0))
%156 = load i8*, i8** %4
%157 = load i32, i32* %5
%158 = load i32, i32* %6
br label %195
159: ; preds = %152
%160 = call i32 (i32, i8*, ...) @lprintf(i32 9, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.12, i64 0, i64 0))
%161 = load i8*, i8** %4
%162 = load i32, i32* %5
%163 = load i32, i32* %6
%164 = call i32 @tcp_dump(i8* %161, i32 %162, i32 %163)
br label %195
165: ; preds = %152
%166 = call i32 (i32, i8*, ...) @lprintf(i32 9, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.13, i64 0, i64 0))
%167 = load i8*, i8** %4
%168 = load i32, i32* %5
%169 = load i32, i32* %6
%170 = call i32 @udp_dump(i8* %167, i32 %168, i32 %169)
br label %195
171: ; preds = %152
%172 = call i32 (i32, i8*, ...) @lprintf(i32 9, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.14, i64 0, i64 0))
%173 = load i8*, i8** %4
%174 = load i32, i32* %5
%175 = load i32, i32* %6
%176 = call i32 @icmp_dump(i8* %173, i32 %174, i32 %175)
br label %195
177: ; preds = %152
%178 = call i32 (i32, i8*, ...) @lprintf(i32 9, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.15, i64 0, i64 0))
%179 = load i8*, i8** %4
%180 = load i32, i32* %5
%181 = load i32, i32* %6
%182 = call i32 @ax25_dump(i8* %179, i32 %180, i32 %181)
br label %195
183: ; preds = %152
%184 = call i32 (i32, i8*, ...) @lprintf(i32 9, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.16, i64 0, i64 0))
%185 = load i8*, i8** %4
%186 = load i32, i32* %5
%187 = call i32 @rspf_dump(i8* %185, i32 %186)
br label %195
188: ; preds = %152
%189 = load i32, i32* %15
%190 = call i32 (i32, i8*, ...) @lprintf(i32 9, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.17, i64 0, i64 0), i32 %189)
%191 = load i8*, i8** %4
%192 = load i32, i32* %5
%193 = load i32, i32* %6
%194 = call i32 @data_dump(i8* %191, i32 %192, i32 %193)
br label %195
195: ; preds = %27, %151, %188, %183, %177, %171, %165, %159, %154
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"IP:\00"
@.str.1 = [13 x i8] c" bad header\0A\00"
@.str.2 = [8 x i8] c" len %d\00"
@.str.3 = [26 x i8] c" %d.%d.%d.%d->%d.%d.%d.%d\00"
@.str.4 = [15 x i8] c" ihl %d ttl %d\00"
@.str.5 = [8 x i8] c" tos %d\00"
@.str.6 = [15 x i8] c" id %d offs %d\00"
@.str.7 = [4 x i8] c" DF\00"
@.str.8 = [4 x i8] c" MF\00"
@.str.9 = [4 x i8] c" CE\00"
@.str.10 = [2 x i8] c"\0A\00"
@.str.11 = [10 x i8] c" prot IP\0A\00"
@.str.12 = [11 x i8] c" prot TCP\0A\00"
@.str.13 = [11 x i8] c" prot UDP\0A\00"
@.str.14 = [12 x i8] c" prot ICMP\0A\00"
@.str.15 = [12 x i8] c" prot AX25\0A\00"
@.str.16 = [12 x i8] c" prot RSPF\0A\00"
@.str.17 = [10 x i8] c" prot %d\0A\00"
define void @ip_dump(i8* %0, i32 %1, i32 %2) {
%4 = tail call i32 (i32, i8*, ...) @lprintf(i32 6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%5 = load i8, i8* %0
%6 = shl i8 %5, 2
%7 = and i8 %6, 60
%8 = icmp ult i8 %7, 20
br i1 %8, label %9, label %11
9: ; preds = %92, %3
%10 = 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 %118
11: ; preds = %3, %92
%12 = phi i8 [ %97, %92 ], [ %7, %3 ]
%13 = phi i32 [ %85, %92 ], [ %1, %3 ]
%14 = phi i8* [ %84, %92 ], [ %0, %3 ]
%15 = zext i8 %12 to i32
%16 = getelementptr inbounds i8, i8* %14, i64 1
%17 = load i8, i8* %16
%18 = getelementptr inbounds i8, i8* %14, i64 2
%19 = tail call i32 @get16(i8* %18)
%20 = getelementptr inbounds i8, i8* %14, i64 4
%21 = tail call i32 @get16(i8* %20)
%22 = getelementptr inbounds i8, i8* %14, i64 6
%23 = tail call i32 @get16(i8* %22)
%24 = shl i32 %23, 3
%25 = and i32 %24, 65528
%26 = getelementptr inbounds i8, i8* %14, i64 8
%27 = load i8, i8* %26
%28 = zext i8 %27 to i32
%29 = getelementptr inbounds i8, i8* %14, i64 9
%30 = load i8, i8* %29
%31 = getelementptr inbounds i8, i8* %14, i64 12
%32 = getelementptr inbounds i8, i8* %14, i64 16
%33 = tail call i32 (i32, i8*, ...) @lprintf(i32 9, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %19)
%34 = load i8, i8* %31
%35 = zext i8 %34 to i32
%36 = getelementptr inbounds i8, i8* %14, i64 13
%37 = load i8, i8* %36
%38 = zext i8 %37 to i32
%39 = getelementptr inbounds i8, i8* %14, i64 14
%40 = load i8, i8* %39
%41 = zext i8 %40 to i32
%42 = getelementptr inbounds i8, i8* %14, i64 15
%43 = load i8, i8* %42
%44 = zext i8 %43 to i32
%45 = load i8, i8* %32
%46 = zext i8 %45 to i32
%47 = getelementptr inbounds i8, i8* %14, i64 17
%48 = load i8, i8* %47
%49 = zext i8 %48 to i32
%50 = getelementptr inbounds i8, i8* %14, i64 18
%51 = load i8, i8* %50
%52 = zext i8 %51 to i32
%53 = getelementptr inbounds i8, i8* %14, i64 19
%54 = load i8, i8* %53
%55 = zext i8 %54 to i32
%56 = tail call i32 (i32, i8*, ...) @lprintf(i32 8, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %35, i32 %38, i32 %41, i32 %44, i32 %46, i32 %49, i32 %52, i32 %55)
%57 = tail call i32 (i32, i8*, ...) @lprintf(i32 9, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %15, i32 %28)
%58 = icmp eq i8 %17, 0
br i1 %58, label %62, label %59
59: ; preds = %11
%60 = zext i8 %17 to i32
%61 = tail call i32 (i32, i8*, ...) @lprintf(i32 9, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32 %60)
br label %62
62: ; preds = %59, %11
%63 = icmp eq i32 %25, 0
%64 = and i32 %23, 8192
%65 = icmp eq i32 %64, 0
%66 = select i1 %63, i1 %65, i1 false
br i1 %66, label %69, label %67
67: ; preds = %62
%68 = tail call i32 (i32, i8*, ...) @lprintf(i32 9, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i32 %21, i32 %25)
br label %69
69: ; preds = %62, %67
%70 = and i32 %23, 16384
%71 = icmp eq i32 %70, 0
br i1 %71, label %74, label %72
72: ; preds = %69
%73 = tail call i32 (i32, i8*, ...) @lprintf(i32 9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
br label %74
74: ; preds = %72, %69
br i1 %65, label %77, label %75
75: ; preds = %74
%76 = tail call i32 (i32, i8*, ...) @lprintf(i32 9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
br label %77
77: ; preds = %75, %74
%78 = and i32 %23, 32768
%79 = icmp eq i32 %78, 0
br i1 %79, label %82, label %80
80: ; preds = %77
%81 = tail call i32 (i32, i8*, ...) @lprintf(i32 9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
br label %82
82: ; preds = %80, %77
%83 = zext i8 %12 to i64
%84 = getelementptr inbounds i8, i8* %14, i64 %83
%85 = sub nsw i32 %13, %15
br i1 %63, label %91, label %86
86: ; preds = %82
%87 = tail call i32 (i32, i8*, ...) @lprintf(i32 9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%88 = icmp sgt i32 %85, 0
br i1 %88, label %89, label %118
89: ; preds = %86
%90 = tail call i32 @data_dump(i8* %84, i32 %85, i32 %2)
br label %118
91: ; preds = %82
switch i8 %30, label %114 [
i8 94, label %92
i8 4, label %92
i8 6, label %99
i8 17, label %102
i8 1, label %105
i8 93, label %108
i8 73, label %111
]
92: ; preds = %91, %91
%93 = tail call i32 (i32, i8*, ...) @lprintf(i32 9, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0))
%94 = tail call i32 (i32, i8*, ...) @lprintf(i32 6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%95 = load i8, i8* %84
%96 = shl i8 %95, 2
%97 = and i8 %96, 60
%98 = icmp ult i8 %97, 20
br i1 %98, label %9, label %11
99: ; preds = %91
%100 = tail call i32 (i32, i8*, ...) @lprintf(i32 9, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.12, i64 0, i64 0))
%101 = tail call i32 @tcp_dump(i8* %84, i32 %85, i32 %2)
br label %118
102: ; preds = %91
%103 = tail call i32 (i32, i8*, ...) @lprintf(i32 9, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.13, i64 0, i64 0))
%104 = tail call i32 @udp_dump(i8* %84, i32 %85, i32 %2)
br label %118
105: ; preds = %91
%106 = tail call i32 (i32, i8*, ...) @lprintf(i32 9, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.14, i64 0, i64 0))
%107 = tail call i32 @icmp_dump(i8* %84, i32 %85, i32 %2)
br label %118
108: ; preds = %91
%109 = tail call i32 (i32, i8*, ...) @lprintf(i32 9, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.15, i64 0, i64 0))
%110 = tail call i32 @ax25_dump(i8* %84, i32 %85, i32 %2)
br label %118
111: ; preds = %91
%112 = tail call i32 (i32, i8*, ...) @lprintf(i32 9, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.16, i64 0, i64 0))
%113 = tail call i32 @rspf_dump(i8* %84, i32 %85)
br label %118
114: ; preds = %91
%115 = zext i8 %30 to i32
%116 = tail call i32 (i32, i8*, ...) @lprintf(i32 9, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.17, i64 0, i64 0), i32 %115)
%117 = tail call i32 @data_dump(i8* %84, i32 %85, i32 %2)
br label %118
118: ; preds = %99, %102, %105, %108, %111, %114, %86, %89, %9
ret void
}