#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char const *,
                           unsigned char const, char const *);
scalar_t__ strcmp(char const *, char *);
void dump_tcpflag(FILE *pigsty, const char *field, const unsigned char *buffer,
                  const size_t buffer_size, const char *ntok) {
  int rsh = -1;
  if (pigsty == NULL || field == NULL || buffer == NULL || buffer_size == 0) {
    return;
  }
  if (strcmp(field, "tcp.urg") == 0) {
    rsh = 5;
  } else if (strcmp(field, "tcp.ack") == 0) {
    rsh = 4;
  } else if (strcmp(field, "tcp.psh") == 0) {
    rsh = 3;
  } else if (strcmp(field, "tcp.rst") == 0) {
    rsh = 2;
  } else if (strcmp(field, "tcp.syn") == 0) {
    rsh = 1;
  } else if (strcmp(field, "tcp.fin") == 0) {
    rsh = 0;
  }
  if (rsh != -1) {
    fprintf(pigsty,
            "\n "
            "%s = %d%s",
            field, (((*buffer) >> rsh) & 0x1), ntok);
  }
}


x86 assembly (clang, -O0):
<dump_tcpflag>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0xffffffff,-0x2c(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     116f <dump_tcpflag+0x4f>
cmpq   $0x0,-0x10(%rbp)
je     116f <dump_tcpflag+0x4f>
cmpq   $0x0,-0x18(%rbp)
je     116f <dump_tcpflag+0x4f>
cmpq   $0x0,-0x20(%rbp)
jne    1174 <dump_tcpflag+0x54>
jmp    12a0 <dump_tcpflag+0x180>
mov    -0x10(%rbp),%rdi
lea    0xe81(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    119a <dump_tcpflag+0x7a>
movl   $0x5,-0x2c(%rbp)
jmp    126c <dump_tcpflag+0x14c>
mov    -0x10(%rbp),%rdi
lea    0xe63(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11c0 <dump_tcpflag+0xa0>
movl   $0x4,-0x2c(%rbp)
jmp    1267 <dump_tcpflag+0x147>
mov    -0x10(%rbp),%rdi
lea    0xe45(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11e6 <dump_tcpflag+0xc6>
movl   $0x3,-0x2c(%rbp)
jmp    1262 <dump_tcpflag+0x142>
mov    -0x10(%rbp),%rdi
lea    0xe27(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    120c <dump_tcpflag+0xec>
movl   $0x2,-0x2c(%rbp)
jmp    125d <dump_tcpflag+0x13d>
mov    -0x10(%rbp),%rdi
lea    0xe09(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1232 <dump_tcpflag+0x112>
movl   $0x1,-0x2c(%rbp)
jmp    1258 <dump_tcpflag+0x138>
mov    -0x10(%rbp),%rdi
lea    0xdeb(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1253 <dump_tcpflag+0x133>
movl   $0x0,-0x2c(%rbp)
jmp    1258 <dump_tcpflag+0x138>
jmp    125d <dump_tcpflag+0x13d>
jmp    1262 <dump_tcpflag+0x142>
jmp    1267 <dump_tcpflag+0x147>
jmp    126c <dump_tcpflag+0x14c>
cmpl   $0xffffffff,-0x2c(%rbp)
je     12a0 <dump_tcpflag+0x180>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rax
movzbl (%rax),%eax
mov    -0x2c(%rbp),%ecx
sar    %cl,%eax
and    $0x1,%eax
mov    -0x28(%rbp),%r8
lea    0xd98(%rip),%rsi
movzbl %al,%ecx
call   1040 <fprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_tcpflag>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rdi,%rdi
je     11d5 <dump_tcpflag+0xb5>
mov    %rsi,%rbx
test   %rsi,%rsi
je     11d5 <dump_tcpflag+0xb5>
mov    %rdx,%r12
test   %rdx,%rdx
je     11d5 <dump_tcpflag+0xb5>
test   %rcx,%rcx
je     11d5 <dump_tcpflag+0xb5>
mov    %r8,%r14
mov    %rdi,%r15
lea    0xea1(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11e1 <dump_tcpflag+0xc1>
lea    0xe95(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11e8 <dump_tcpflag+0xc8>
lea    0xe89(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11ef <dump_tcpflag+0xcf>
lea    0xe7d(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11f6 <dump_tcpflag+0xd6>
lea    0xe71(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11fd <dump_tcpflag+0xdd>
lea    0xe65(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %al
je     1204 <dump_tcpflag+0xe4>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    $0x5,%ecx
jmp    1208 <dump_tcpflag+0xe8>
mov    $0x4,%ecx
jmp    1208 <dump_tcpflag+0xe8>
mov    $0x3,%ecx
jmp    1208 <dump_tcpflag+0xe8>
mov    $0x2,%ecx
jmp    1208 <dump_tcpflag+0xe8>
mov    $0x1,%ecx
jmp    1208 <dump_tcpflag+0xe8>
mov    %al,%cl
neg    %ecx
movzbl (%r12),%eax
shr    %cl,%eax
and    $0x1,%eax
lea    0xe17(%rip),%rsi
mov    %r15,%rdi
mov    %rbx,%rdx
mov    %eax,%ecx
mov    %r14,%r8
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <fprintf@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"tcp.urg\00"
@.str.1 = [8 x i8] c"tcp.ack\00"
@.str.2 = [8 x i8] c"tcp.psh\00"
@.str.3 = [8 x i8] c"tcp.rst\00"
@.str.4 = [8 x i8] c"tcp.syn\00"
@.str.5 = [8 x i8] c"tcp.fin\00"
@.str.6 = [12 x i8] c"\0A %s = %d%s\00"
define void @dump_tcpflag(i32* %0, i8* %1, i8* %2, i64 %3, i8* %4) {
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i8*
%11 = alloca i32
store i32* %0, i32** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i64 %3, i64* %9
store i8* %4, i8** %10
store i32 -1, i32* %11
%12 = load i32*, i32** %6
%13 = icmp eq i32* %12, null
br i1 %13, label %23, label %14
14: ; preds = %5
%15 = load i8*, i8** %7
%16 = icmp eq i8* %15, null
br i1 %16, label %23, label %17
17: ; preds = %14
%18 = load i8*, i8** %8
%19 = icmp eq i8* %18, null
br i1 %19, label %23, label %20
20: ; preds = %17
%21 = load i64, i64* %9
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %20, %17, %14, %5
br label %74
24: ; preds = %20
%25 = load i8*, i8** %7
%26 = call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %24
store i32 5, i32* %11
br label %59
29: ; preds = %24
%30 = load i8*, i8** %7
%31 = call i64 @strcmp(i8* %30, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %29
store i32 4, i32* %11
br label %58
34: ; preds = %29
%35 = load i8*, i8** %7
%36 = call i64 @strcmp(i8* %35, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %39
38: ; preds = %34
store i32 3, i32* %11
br label %57
39: ; preds = %34
%40 = load i8*, i8** %7
%41 = call i64 @strcmp(i8* %40, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %44
43: ; preds = %39
store i32 2, i32* %11
br label %56
44: ; preds = %39
%45 = load i8*, i8** %7
%46 = call i64 @strcmp(i8* %45, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %49
48: ; preds = %44
store i32 1, i32* %11
br label %55
49: ; preds = %44
%50 = load i8*, i8** %7
%51 = call i64 @strcmp(i8* %50, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%52 = icmp eq i64 %51, 0
br i1 %52, label %53, label %54
53: ; preds = %49
store i32 0, i32* %11
br label %54
54: ; preds = %53, %49
br label %55
55: ; preds = %54, %48
br label %56
56: ; preds = %55, %43
br label %57
57: ; preds = %56, %38
br label %58
58: ; preds = %57, %33
br label %59
59: ; preds = %58, %28
%60 = load i32, i32* %11
%61 = icmp ne i32 %60, -1
br i1 %61, label %62, label %74
62: ; preds = %59
%63 = load i32*, i32** %6
%64 = load i8*, i8** %7
%65 = load i8*, i8** %8
%66 = load i8, i8* %65
%67 = zext i8 %66 to i32
%68 = load i32, i32* %11
%69 = ashr i32 %67, %68
%70 = and i32 %69, 1
%71 = trunc i32 %70 to i8
%72 = load i8*, i8** %10
%73 = call i32 @fprintf(i32* %63, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* %64, i8 zeroext %71, i8* %72)
br label %74
74: ; preds = %23, %62, %59
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"tcp.urg\00"
@.str.1 = [8 x i8] c"tcp.ack\00"
@.str.2 = [8 x i8] c"tcp.psh\00"
@.str.3 = [8 x i8] c"tcp.rst\00"
@.str.4 = [8 x i8] c"tcp.syn\00"
@.str.5 = [8 x i8] c"tcp.fin\00"
@.str.6 = [12 x i8] c"\0A %s = %d%s\00"
define void @dump_tcpflag(i32* %0, i8* %1, i8* %2, i64 %3, i8* %4) {
%6 = icmp eq i32* %0, null
%7 = icmp eq i8* %1, null
%8 = or i1 %6, %7
%9 = icmp eq i8* %2, null
%10 = or i1 %8, %9
%11 = icmp eq i64 %3, 0
%12 = or i1 %10, %11
br i1 %12, label %41, label %13
13: ; preds = %5
%14 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %33, label %16
16: ; preds = %13
%17 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %33, label %19
19: ; preds = %16
%20 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %33, label %22
22: ; preds = %19
%23 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %33, label %25
25: ; preds = %22
%26 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %33, label %28
28: ; preds = %25
%29 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
%31 = xor i1 %30, true
%32 = sext i1 %31 to i32
br i1 %30, label %33, label %41
33: ; preds = %25, %22, %19, %16, %13, %28
%34 = phi i32 [ %32, %28 ], [ 1, %25 ], [ 2, %22 ], [ 3, %19 ], [ 4, %16 ], [ 5, %13 ]
%35 = load i8, i8* %2
%36 = zext i8 %35 to i32
%37 = lshr i32 %36, %34
%38 = trunc i32 %37 to i8
%39 = and i8 %38, 1
%40 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* %1, i8 zeroext %39, i8* %4)
br label %41
41: ; preds = %28, %33, %5
ret void
}