#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 get16(unsigned char *);
int get32(unsigned char *);
int /*<<< orphan*/ lprintf(int, char *, ...);
int /*<<< orphan*/ servname(int, char *);
void tcp_dump(unsigned char *data, int length, int hexdump) {
  int source, dest;
  int seq;
  int ack;
  int flags;
  int wnd;
  int up;
  int hdrlen;
  int mss = 0;
  source = get16(data + 0);
  dest = get16(data + 2);
  seq = get32(data + 4);
  ack = get32(data + 8);
  hdrlen = (data[12] & 0xF0) >> 2;
  flags = data[13];
  wnd = get16(data + 14);
  up = get16(data + 18);
  lprintf(6, "TCP:");
  lprintf(10, " %s->", servname(source, "tcp"));
  lprintf(10, "%s Seq x%x", servname(dest, "tcp"), seq);
  if (flags & 0x10)
    lprintf(10, " Ack x%x", ack);
  if (flags & 0x40)
    lprintf(10, " CE");
  if (flags & 0x20)
    lprintf(10, " URG");
  if (flags & 0x10)
    lprintf(10, " ACK");
  if (flags & 0x08)
    lprintf(10, " PSH");
  if (flags & 0x04)
    lprintf(10, " RST");
  if (flags & 0x02)
    lprintf(10, " SYN");
  if (flags & 0x01)
    lprintf(10, " FIN");
  lprintf(10, " Wnd %d", wnd);
  if (flags & 0x20)
    lprintf(10, " UP x%x", up);
  if (hdrlen > 20 && length >= hdrlen) {
    unsigned char *cp = data + 20;
    int i = hdrlen - 20;
    int kind, optlen;
    while (i > 0) {
      kind = *cp++;
      switch (kind) {
      case 0:
        i--;
        cp++;
        break;
      case 1:
        i--;
        cp++;
        continue;
      }
      optlen = *cp++;
      switch (kind) {
      case 2:
        if (optlen == 4)
          mss = get16(cp);
        break;
      }
      optlen = ((2) > (optlen) ? (2) : (optlen));
      i -= optlen;
      cp += optlen - 2;
    }
  }
  if (mss != 0)
    lprintf(10, " MSS %d", mss);
  length -= hdrlen;
  data += hdrlen;
  if (length > 0) {
    lprintf(10, " Data %d\n", length);
    data_dump(data, length, hexdump);
    return;
  }
  lprintf(10, "\n");
}


x86 assembly (clang, -O0):
<tcp_dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <get16@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
add    $0x2,%rdi
call   1060 <get16@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
add    $0x4,%rdi
call   1050 <get32@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
add    $0x8,%rdi
call   1050 <get32@plt>
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movzbl 0xc(%rax),%eax
and    $0xf0,%eax
sar    $0x2,%eax
mov    %eax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movzbl 0xd(%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
add    $0xe,%rdi
call   1060 <get16@plt>
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
add    $0x12,%rdi
call   1060 <get16@plt>
mov    %eax,-0x2c(%rbp)
mov    $0x6,%edi
lea    0xe11(%rip),%rsi
mov    $0x0,%al
call   1070 <lprintf@plt>
mov    -0x14(%rbp),%edi
lea    0xe0b(%rip),%rsi
call   1040 <servname@plt>
mov    %eax,%edx
mov    $0xa,%edi
lea    0xdf2(%rip),%rsi
mov    $0x0,%al
call   1070 <lprintf@plt>
mov    -0x18(%rbp),%edi
lea    0xde7(%rip),%rsi
call   1040 <servname@plt>
mov    %eax,%edx
mov    -0x1c(%rbp),%ecx
mov    $0xa,%edi
lea    0xdd5(%rip),%rsi
mov    $0x0,%al
call   1070 <lprintf@plt>
mov    -0x24(%rbp),%eax
and    $0x10,%eax
cmp    $0x0,%eax
je     1266 <tcp_dump+0x116>
mov    -0x20(%rbp),%edx
mov    $0xa,%edi
lea    0xdbb(%rip),%rsi
mov    $0x0,%al
call   1070 <lprintf@plt>
mov    -0x24(%rbp),%eax
and    $0x40,%eax
cmp    $0x0,%eax
je     1288 <tcp_dump+0x138>
mov    $0xa,%edi
lea    0xda2(%rip),%rsi
mov    $0x0,%al
call   1070 <lprintf@plt>
mov    -0x24(%rbp),%eax
and    $0x20,%eax
cmp    $0x0,%eax
je     12aa <tcp_dump+0x15a>
mov    $0xa,%edi
lea    0xd84(%rip),%rsi
mov    $0x0,%al
call   1070 <lprintf@plt>
mov    -0x24(%rbp),%eax
and    $0x10,%eax
cmp    $0x0,%eax
je     12cc <tcp_dump+0x17c>
mov    $0xa,%edi
lea    0xd67(%rip),%rsi
mov    $0x0,%al
call   1070 <lprintf@plt>
mov    -0x24(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     12ee <tcp_dump+0x19e>
mov    $0xa,%edi
lea    0xd4a(%rip),%rsi
mov    $0x0,%al
call   1070 <lprintf@plt>
mov    -0x24(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     1310 <tcp_dump+0x1c0>
mov    $0xa,%edi
lea    0xd2d(%rip),%rsi
mov    $0x0,%al
call   1070 <lprintf@plt>
mov    -0x24(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     1332 <tcp_dump+0x1e2>
mov    $0xa,%edi
lea    0xd10(%rip),%rsi
mov    $0x0,%al
call   1070 <lprintf@plt>
mov    -0x24(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1354 <tcp_dump+0x204>
mov    $0xa,%edi
lea    0xcf3(%rip),%rsi
mov    $0x0,%al
call   1070 <lprintf@plt>
mov    -0x28(%rbp),%edx
mov    $0xa,%edi
lea    0xce2(%rip),%rsi
mov    $0x0,%al
call   1070 <lprintf@plt>
mov    -0x24(%rbp),%eax
and    $0x20,%eax
cmp    $0x0,%eax
je     138f <tcp_dump+0x23f>
mov    -0x2c(%rbp),%edx
mov    $0xa,%edi
lea    0xcc5(%rip),%rsi
mov    $0x0,%al
call   1070 <lprintf@plt>
cmpl   $0x14,-0x30(%rbp)
jle    14c2 <tcp_dump+0x372>
mov    -0xc(%rbp),%eax
cmp    -0x30(%rbp),%eax
jl     14c2 <tcp_dump+0x372>
mov    -0x8(%rbp),%rax
add    $0x14,%rax
mov    %rax,-0x40(%rbp)
mov    -0x30(%rbp),%eax
sub    $0x14,%eax
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
jle    14bd <tcp_dump+0x36d>
mov    -0x40(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x40(%rbp)
movzbl (%rax),%eax
mov    %eax,-0x48(%rbp)
mov    -0x48(%rbp),%eax
mov    %eax,-0x50(%rbp)
test   %eax,%eax
je     13fd <tcp_dump+0x2ad>
jmp    13ec <tcp_dump+0x29c>
mov    -0x50(%rbp),%eax
sub    $0x1,%eax
je     1417 <tcp_dump+0x2c7>
jmp    1431 <tcp_dump+0x2e1>
mov    -0x44(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x44(%rbp)
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    1431 <tcp_dump+0x2e1>
mov    -0x44(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x44(%rbp)
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    13ba <tcp_dump+0x26a>
mov    -0x40(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x40(%rbp)
movzbl (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x48(%rbp),%eax
sub    $0x2,%eax
jne    1472 <tcp_dump+0x322>
jmp    1457 <tcp_dump+0x307>
cmpl   $0x4,-0x4c(%rbp)
jne    146d <tcp_dump+0x31d>
mov    -0x40(%rbp),%rdi
call   1060 <get16@plt>
mov    %eax,-0x34(%rbp)
jmp    1472 <tcp_dump+0x322>
mov    $0x2,%eax
cmp    -0x4c(%rbp),%eax
jle    148d <tcp_dump+0x33d>
mov    $0x2,%eax
mov    %eax,-0x54(%rbp)
jmp    1493 <tcp_dump+0x343>
mov    -0x4c(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x54(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%ecx
mov    -0x44(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x44(%rbp)
mov    -0x4c(%rbp),%ecx
sub    $0x2,%ecx
mov    -0x40(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x40(%rbp)
jmp    13ba <tcp_dump+0x26a>
jmp    14c2 <tcp_dump+0x372>
cmpl   $0x0,-0x34(%rbp)
je     14e2 <tcp_dump+0x392>
mov    -0x34(%rbp),%edx
mov    $0xa,%edi
lea    0xb7a(%rip),%rsi
mov    $0x0,%al
call   1070 <lprintf@plt>
mov    -0x30(%rbp),%ecx
mov    -0xc(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x30(%rbp),%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    1532 <tcp_dump+0x3e2>
mov    -0xc(%rbp),%edx
mov    $0xa,%edi
lea    0xb46(%rip),%rsi
mov    $0x0,%al
call   1070 <lprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1030 <data_dump@plt>
jmp    1545 <tcp_dump+0x3f5>
mov    $0xa,%edi
lea    0xb27(%rip),%rsi
mov    $0x0,%al
call   1070 <lprintf@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tcp_dump>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %edx,0x14(%rsp)
mov    %esi,0x1c(%rsp)
mov    %rdi,%r14
call   1060 <get16@plt>
mov    %eax,%r12d
lea    0x2(%r14),%rdi
call   1060 <get16@plt>
mov    %eax,%r15d
lea    0x4(%r14),%rdi
call   1050 <get32@plt>
mov    %eax,%ebx
lea    0x8(%r14),%rdi
call   1050 <get32@plt>
mov    %eax,0xc(%rsp)
movzbl 0xc(%r14),%eax
mov    %rax,0x20(%rsp)
movzbl 0xd(%r14),%ebp
lea    0xe(%r14),%rdi
call   1060 <get16@plt>
mov    %eax,0x18(%rsp)
lea    0x12(%r14),%rdi
call   1060 <get16@plt>
mov    %eax,0x10(%rsp)
lea    0xe3b(%rip),%rsi
mov    $0x6,%edi
xor    %eax,%eax
call   1070 <lprintf@plt>
lea    0xe33(%rip),%r13
mov    %r12d,%edi
mov    %r13,%rsi
call   1040 <servname@plt>
lea    0xe1b(%rip),%rsi
mov    $0xa,%edi
mov    %eax,%edx
xor    %eax,%eax
call   1070 <lprintf@plt>
mov    %r15d,%edi
mov    %r13,%rsi
call   1040 <servname@plt>
lea    0xe05(%rip),%rsi
mov    $0xa,%edi
mov    %eax,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1070 <lprintf@plt>
test   $0x10,%bpl
je     1237 <tcp_dump+0xe7>
lea    0xdf3(%rip),%rsi
mov    $0xa,%edi
mov    0xc(%rsp),%edx
xor    %eax,%eax
call   1070 <lprintf@plt>
test   $0x40,%bpl
je     1250 <tcp_dump+0x100>
lea    0xddf(%rip),%rsi
mov    $0xa,%edi
xor    %eax,%eax
call   1070 <lprintf@plt>
test   $0x20,%bpl
mov    0x1c(%rsp),%r13d
mov    0x20(%rsp),%rbx
je     1273 <tcp_dump+0x123>
lea    0xdc0(%rip),%rsi
mov    $0xa,%edi
xor    %eax,%eax
call   1070 <lprintf@plt>
test   $0x10,%bpl
je     128c <tcp_dump+0x13c>
lea    0xdac(%rip),%rsi
mov    $0xa,%edi
xor    %eax,%eax
call   1070 <lprintf@plt>
shr    $0x2,%rbx
test   $0x8,%bpl
je     12a9 <tcp_dump+0x159>
lea    0xd94(%rip),%rsi
mov    $0xa,%edi
xor    %eax,%eax
call   1070 <lprintf@plt>
test   $0x4,%bpl
je     12c2 <tcp_dump+0x172>
lea    0xd80(%rip),%rsi
mov    $0xa,%edi
xor    %eax,%eax
call   1070 <lprintf@plt>
and    $0x3c,%ebx
test   $0x2,%bpl
je     12de <tcp_dump+0x18e>
lea    0xd69(%rip),%rsi
mov    $0xa,%edi
xor    %eax,%eax
call   1070 <lprintf@plt>
test   $0x1,%bpl
je     12f7 <tcp_dump+0x1a7>
lea    0xd55(%rip),%rsi
mov    $0xa,%edi
xor    %eax,%eax
call   1070 <lprintf@plt>
lea    0xd47(%rip),%rsi
mov    $0xa,%edi
mov    0x18(%rsp),%edx
xor    %eax,%eax
call   1070 <lprintf@plt>
test   $0x20,%bpl
je     132b <tcp_dump+0x1db>
lea    0xd32(%rip),%rsi
mov    $0xa,%edi
mov    0x10(%rsp),%edx
xor    %eax,%eax
call   1070 <lprintf@plt>
cmp    $0x15,%bl
jb     13fa <tcp_dump+0x2aa>
cmp    %r13d,%ebx
jg     13fa <tcp_dump+0x2aa>
mov    %rbx,%r15
add    $0xffffffec,%ebx
lea    0x14(%r14),%rbp
xor    %edx,%edx
mov    $0x2,%esi
add    $0x2,%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl -0x2(%rbp),%ecx
cmp    $0x1,%cl
jne    1380 <tcp_dump+0x230>
lea    -0x1(%rbx),%eax
add    $0x2,%rbp
cmp    $0x1,%ebx
mov    %eax,%ebx
jg     1360 <tcp_dump+0x210>
jmp    13e0 <tcp_dump+0x290>
nopl   0x0(%rax)
test   %cl,%cl
jne    13a0 <tcp_dump+0x250>
add    $0xffffffff,%ebx
mov    0x0(%rbp),%al
mov    $0x3,%r12d
jmp    13c3 <tcp_dump+0x273>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    -0x1(%rbp),%al
mov    $0x2,%r12d
cmp    $0x2,%cl
jne    13c3 <tcp_dump+0x273>
cmp    $0x4,%al
jne    13c3 <tcp_dump+0x273>
mov    %rbp,%rdi
call   1060 <get16@plt>
mov    $0x2,%esi
mov    %eax,%edx
mov    $0x4,%al
movzbl %al,%eax
cmp    $0x3,%al
cmovb  %esi,%eax
lea    -0x2(%rax),%ecx
add    %r12,%rcx
add    %rcx,%rbp
add    $0xfffffffffffffffe,%rbp
sub    %eax,%ebx
jg     134e <tcp_dump+0x1fe>
test   %edx,%edx
mov    %r15,%rbx
je     13fa <tcp_dump+0x2aa>
lea    0xc67(%rip),%rsi
mov    $0xa,%edi
xor    %eax,%eax
call   1070 <lprintf@plt>
sub    %ebx,%r13d
jle    1435 <tcp_dump+0x2e5>
add    %rbx,%r14
lea    0xc54(%rip),%rsi
mov    $0xa,%edi
mov    %r13d,%edx
xor    %eax,%eax
call   1070 <lprintf@plt>
mov    %r14,%rdi
mov    %r13d,%esi
mov    0x14(%rsp),%edx
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <data_dump@plt>
lea    0xc29(%rip),%rsi
mov    $0xa,%edi
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <lprintf@plt>

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

LLVM IR (-O2):
@.str = [5 x i8] c"TCP:\00"
@.str.1 = [6 x i8] c" %s->\00"
@.str.2 = [4 x i8] c"tcp\00"
@.str.3 = [11 x i8] c"%s Seq x%x\00"
@.str.4 = [9 x i8] c" Ack x%x\00"
@.str.5 = [4 x i8] c" CE\00"
@.str.6 = [5 x i8] c" URG\00"
@.str.7 = [5 x i8] c" ACK\00"
@.str.8 = [5 x i8] c" PSH\00"
@.str.9 = [5 x i8] c" RST\00"
@.str.10 = [5 x i8] c" SYN\00"
@.str.11 = [5 x i8] c" FIN\00"
@.str.12 = [8 x i8] c" Wnd %d\00"
@.str.13 = [8 x i8] c" UP x%x\00"
@.str.14 = [8 x i8] c" MSS %d\00"
@.str.15 = [10 x i8] c" Data %d\0A\00"
@.str.16 = [2 x i8] c"\0A\00"
define void @tcp_dump(i8* %0, i32 %1, i32 %2) {
%4 = tail call i32 @get16(i8* %0)
%5 = getelementptr inbounds i8, i8* %0, i64 2
%6 = tail call i32 @get16(i8* %5)
%7 = getelementptr inbounds i8, i8* %0, i64 4
%8 = tail call i32 @get32(i8* %7)
%9 = getelementptr inbounds i8, i8* %0, i64 8
%10 = tail call i32 @get32(i8* %9)
%11 = getelementptr inbounds i8, i8* %0, i64 12
%12 = load i8, i8* %11
%13 = lshr i8 %12, 2
%14 = and i8 %13, 60
%15 = zext i8 %14 to i32
%16 = getelementptr inbounds i8, i8* %0, i64 13
%17 = load i8, i8* %16
%18 = zext i8 %17 to i32
%19 = getelementptr inbounds i8, i8* %0, i64 14
%20 = tail call i32 @get16(i8* %19)
%21 = getelementptr inbounds i8, i8* %0, i64 18
%22 = tail call i32 @get16(i8* %21)
%23 = tail call i32 (i32, i8*, ...) @lprintf(i32 6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%24 = tail call i32 @servname(i32 %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%25 = tail call i32 (i32, i8*, ...) @lprintf(i32 10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %24)
%26 = tail call i32 @servname(i32 %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%27 = tail call i32 (i32, i8*, ...) @lprintf(i32 10, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %26, i32 %8)
%28 = and i32 %18, 16
%29 = icmp eq i32 %28, 0
br i1 %29, label %32, label %30
30: ; preds = %3
%31 = tail call i32 (i32, i8*, ...) @lprintf(i32 10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 %10)
br label %32
32: ; preds = %30, %3
%33 = and i32 %18, 64
%34 = icmp eq i32 %33, 0
br i1 %34, label %37, label %35
35: ; preds = %32
%36 = tail call i32 (i32, i8*, ...) @lprintf(i32 10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
br label %37
37: ; preds = %35, %32
%38 = and i32 %18, 32
%39 = icmp eq i32 %38, 0
br i1 %39, label %42, label %40
40: ; preds = %37
%41 = tail call i32 (i32, i8*, ...) @lprintf(i32 10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
br label %42
42: ; preds = %40, %37
br i1 %29, label %45, label %43
43: ; preds = %42
%44 = tail call i32 (i32, i8*, ...) @lprintf(i32 10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
br label %45
45: ; preds = %43, %42
%46 = and i32 %18, 8
%47 = icmp eq i32 %46, 0
br i1 %47, label %50, label %48
48: ; preds = %45
%49 = tail call i32 (i32, i8*, ...) @lprintf(i32 10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
br label %50
50: ; preds = %48, %45
%51 = and i32 %18, 4
%52 = icmp eq i32 %51, 0
br i1 %52, label %55, label %53
53: ; preds = %50
%54 = tail call i32 (i32, i8*, ...) @lprintf(i32 10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
br label %55
55: ; preds = %53, %50
%56 = and i32 %18, 2
%57 = icmp eq i32 %56, 0
br i1 %57, label %60, label %58
58: ; preds = %55
%59 = tail call i32 (i32, i8*, ...) @lprintf(i32 10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
br label %60
60: ; preds = %58, %55
%61 = and i32 %18, 1
%62 = icmp eq i32 %61, 0
br i1 %62, label %65, label %63
63: ; preds = %60
%64 = tail call i32 (i32, i8*, ...) @lprintf(i32 10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
br label %65
65: ; preds = %63, %60
%66 = tail call i32 (i32, i8*, ...) @lprintf(i32 10, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i64 0, i64 0), i32 %20)
br i1 %39, label %69, label %67
67: ; preds = %65
%68 = tail call i32 (i32, i8*, ...) @lprintf(i32 10, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.13, i64 0, i64 0), i32 %22)
br label %69
69: ; preds = %67, %65
%70 = icmp ult i8 %14, 21
%71 = icmp sgt i32 %15, %1
%72 = or i1 %70, %71
br i1 %72, label %120, label %73
73: ; preds = %69
%74 = add nsw i32 %15, -20
%75 = getelementptr inbounds i8, i8* %0, i64 20
br label %76
76: ; preds = %73, %101
%77 = phi i32 [ %110, %101 ], [ %74, %73 ]
%78 = phi i8* [ %113, %101 ], [ %75, %73 ]
%79 = phi i32 [ %105, %101 ], [ 0, %73 ]
br label %80
80: ; preds = %76, %88
%81 = phi i32 [ %77, %76 ], [ %89, %88 ]
%82 = phi i8* [ %78, %76 ], [ %90, %88 ]
%83 = load i8, i8* %82
switch i8 %83, label %92 [
i8 0, label %84
i8 1, label %88
]
84: ; preds = %80
%85 = add nsw i32 %81, -1
%86 = getelementptr inbounds i8, i8* %82, i64 2
%87 = load i8, i8* %86
br label %101
88: ; preds = %80
%89 = add nsw i32 %81, -1
%90 = getelementptr inbounds i8, i8* %82, i64 2
%91 = icmp sgt i32 %81, 1
br i1 %91, label %80, label %115
92: ; preds = %80
%93 = getelementptr inbounds i8, i8* %82, i64 1
%94 = load i8, i8* %93
%95 = icmp eq i8 %83, 2
%96 = icmp eq i8 %94, 4
%97 = select i1 %95, i1 %96, i1 false
br i1 %97, label %98, label %101
98: ; preds = %92
%99 = getelementptr inbounds i8, i8* %82, i64 2
%100 = tail call i32 @get16(i8* %99)
br label %101
101: ; preds = %84, %98, %92
%102 = phi i8 [ 4, %98 ], [ %94, %92 ], [ %87, %84 ]
%103 = phi i64 [ 2, %98 ], [ 2, %92 ], [ 3, %84 ]
%104 = phi i32 [ %81, %98 ], [ %81, %92 ], [ %85, %84 ]
%105 = phi i32 [ %100, %98 ], [ %79, %92 ], [ %79, %84 ]
%106 = getelementptr inbounds i8, i8* %82, i64 %103
%107 = zext i8 %102 to i32
%108 = icmp ugt i32 %107, 2
%109 = select i1 %108, i32 %107, i32 2
%110 = sub nsw i32 %104, %109
%111 = add nsw i32 %109, -2
%112 = zext i32 %111 to i64
%113 = getelementptr inbounds i8, i8* %106, i64 %112
%114 = icmp sgt i32 %110, 0
br i1 %114, label %76, label %115
115: ; preds = %101, %88
%116 = phi i32 [ %79, %88 ], [ %105, %101 ]
%117 = icmp eq i32 %116, 0
br i1 %117, label %120, label %118
118: ; preds = %115
%119 = tail call i32 (i32, i8*, ...) @lprintf(i32 10, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.14, i64 0, i64 0), i32 %116)
br label %120
120: ; preds = %69, %118, %115
%121 = sub nsw i32 %1, %15
%122 = icmp sgt i32 %121, 0
br i1 %122, label %123, label %128
123: ; preds = %120
%124 = zext i8 %14 to i64
%125 = getelementptr inbounds i8, i8* %0, i64 %124
%126 = tail call i32 (i32, i8*, ...) @lprintf(i32 10, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i64 0, i64 0), i32 %121)
%127 = tail call i32 @data_dump(i8* %125, i32 %121, i32 %2)
br label %130
128: ; preds = %120
%129 = tail call i32 (i32, i8*, ...) @lprintf(i32 10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.16, i64 0, i64 0))
br label %130
130: ; preds = %128, %123
ret void
}