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

/* Variables and functions */
int /*<<< orphan*/ dump_tcpflag(int /*<<< orphan*/ *, char *,
                                unsigned char const *, size_t const,
                                char const *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char const *, char *,
                           char const *);
char *get_option(char const *, int /*<<< orphan*/ *);
void dump_tcpflags(FILE *pigsty, const char *field, const unsigned char *buffer,
                   const size_t buffer_size) {
  char *data = NULL;
  struct dump_program_instruction_set {
    const char *option;
    const char *field;
    const char *ntok;
  };
  struct dump_program_instruction_set dump_task[] = {
      {"tcp-urg", "tcp.urg", ","}, {"tcp-ack", "tcp.ack", ","},
      {"tcp-psh", "tcp.psh", ","}, {"tcp-rst", "tcp.rst", ","},
      {"tcp-syn", "tcp.syn", ","}, {"tcp-fin", "tcp.fin", ""}};
  size_t dump_task_nr = sizeof(dump_task) / sizeof(dump_task[0]);
  size_t d;
  for (d = 0; d < dump_task_nr; d++) {
    data = get_option(dump_task[d].option, NULL);
    if (data != NULL) {
      fprintf(pigsty,
              "\n "
              "%s = %s%s",
              dump_task[d].field, data, dump_task[d].ntok);
    } else {
      dump_tcpflag(pigsty, dump_task[d].field, buffer, buffer_size,
                   dump_task[d].ntok);
    }
  }
}


x86 assembly (clang, -O0):
<dump_tcpflags>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
lea    -0xc0(%rbp),%rdi
lea    0x2c1f(%rip),%rsi
mov    $0x90,%edx
call   1040 <memcpy@plt>
movq   $0x6,-0xc8(%rbp)
movq   $0x0,-0xd0(%rbp)
mov    -0xd0(%rbp),%rax
cmp    -0xc8(%rbp),%rax
jae    1270 <dump_tcpflags+0x130>
lea    -0xc0(%rbp),%rax
imul   $0x18,-0xd0(%rbp),%rcx
18
add    %rcx,%rax
mov    (%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <get_option@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1217 <dump_tcpflags+0xd7>
mov    -0x8(%rbp),%rdi
lea    -0xc0(%rbp),%rax
imul   $0x18,-0xd0(%rbp),%rcx
18
add    %rcx,%rax
mov    0x8(%rax),%rdx
mov    -0x28(%rbp),%rcx
lea    -0xc0(%rbp),%rax
imul   $0x18,-0xd0(%rbp),%rsi
18
add    %rsi,%rax
mov    0x10(%rax),%r8
lea    0xe55(%rip),%rsi
call   1030 <fprintf@plt>
jmp    1254 <dump_tcpflags+0x114>
mov    -0x8(%rbp),%rdi
lea    -0xc0(%rbp),%rax
imul   $0x18,-0xd0(%rbp),%rcx
18
add    %rcx,%rax
mov    0x8(%rax),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    -0xc0(%rbp),%rax
imul   $0x18,-0xd0(%rbp),%r8
18
add    %r8,%rax
mov    0x10(%rax),%r8
call   1050 <dump_tcpflag@plt>
jmp    1259 <dump_tcpflags+0x119>
mov    -0xd0(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xd0(%rbp)
jmp    1191 <dump_tcpflags+0x51>
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_tcpflags>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rdi,%r13
mov    $0x10,%ebp
lea    0x2c40(%rip),%r12
jmp    117b <dump_tcpflags+0x4b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
call   1040 <dump_tcpflag@plt>
add    $0x18,%rbp
cmp    $0xa0,%rbp
je     11ad <dump_tcpflags+0x7d>
mov    -0x10(%rbp,%r12,1),%rdi
mov    -0x8(%rbp,%r12,1),%rbx
xor    %esi,%esi
call   1050 <get_option@plt>
mov    0x0(%rbp,%r12,1),%r8
mov    %r13,%rdi
test   %rax,%rax
je     1160 <dump_tcpflags+0x30>
lea    0xec2(%rip),%rsi
mov    %rbx,%rdx
mov    %rax,%rcx
call   1030 <fprintf@plt>
jmp    116e <dump_tcpflags+0x3e>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.dump_program_instruction_set = type { i8*, i8*, i8* }
@.str = [8 x i8] c"tcp-urg\00"
@.str.1 = [8 x i8] c"tcp.urg\00"
@.str.2 = [2 x i8] c",\00"
@.str.3 = [8 x i8] c"tcp-ack\00"
@.str.4 = [8 x i8] c"tcp.ack\00"
@.str.5 = [8 x i8] c"tcp-psh\00"
@.str.6 = [8 x i8] c"tcp.psh\00"
@.str.7 = [8 x i8] c"tcp-rst\00"
@.str.8 = [8 x i8] c"tcp.rst\00"
@.str.9 = [8 x i8] c"tcp-syn\00"
@.str.10 = [8 x i8] c"tcp.syn\00"
@.str.11 = [8 x i8] c"tcp-fin\00"
@.str.12 = [8 x i8] c"tcp.fin\00"
@.str.13 = [1 x i8] zeroinitializer
@__const.dump_tcpflags.dump_task = [6 x %struct.dump_program_instruction_set] [%struct.dump_program_instruction_set { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i32 0, i32 0) }, %struct.dump_program_instruction_set { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i32 0, i32 0) }, %struct.dump_program_instruction_set { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i32 0, i32 0) }, %struct.dump_program_instruction_set { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i32 0, i32 0) }, %struct.dump_program_instruction_set { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i32 0, i32 0) }, %struct.dump_program_instruction_set { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.13, i32 0, i32 0) }]
@.str.14 = [12 x i8] c"\0A %s = %s%s\00"
define void @dump_tcpflags(i32* %0, i8* %1, i8* %2, i64 %3) {
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i8*
%10 = alloca [6 x %struct.dump_program_instruction_set]
%11 = alloca i64
%12 = alloca i64
store i32* %0, i32** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i64 %3, i64* %8
store i8* null, i8** %9
%13 = bitcast [6 x %struct.dump_program_instruction_set]* %10 to i8*
store i64 6, i64* %11
store i64 0, i64* %12
br label %14
14: ; preds = %52, %4
%15 = load i64, i64* %12
%16 = load i64, i64* %11
%17 = icmp ult i64 %15, %16
br i1 %17, label %18, label %55
18: ; preds = %14
%19 = load i64, i64* %12
%20 = getelementptr inbounds [6 x %struct.dump_program_instruction_set], [6 x %struct.dump_program_instruction_set]* %10, i64 0, i64 %19
%21 = getelementptr inbounds %struct.dump_program_instruction_set, %struct.dump_program_instruction_set* %20, i32 0, i32 0
%22 = load i8*, i8** %21
%23 = call i8* @get_option(i8* %22, i32* null)
store i8* %23, i8** %9
%24 = load i8*, i8** %9
%25 = icmp ne i8* %24, null
br i1 %25, label %26, label %38
26: ; preds = %18
%27 = load i32*, i32** %5
%28 = load i64, i64* %12
%29 = getelementptr inbounds [6 x %struct.dump_program_instruction_set], [6 x %struct.dump_program_instruction_set]* %10, i64 0, i64 %28
%30 = getelementptr inbounds %struct.dump_program_instruction_set, %struct.dump_program_instruction_set* %29, i32 0, i32 1
%31 = load i8*, i8** %30
%32 = load i8*, i8** %9
%33 = load i64, i64* %12
%34 = getelementptr inbounds [6 x %struct.dump_program_instruction_set], [6 x %struct.dump_program_instruction_set]* %10, i64 0, i64 %33
%35 = getelementptr inbounds %struct.dump_program_instruction_set, %struct.dump_program_instruction_set* %34, i32 0, i32 2
%36 = load i8*, i8** %35
%37 = call i32 @fprintf(i32* %27, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.14, i64 0, i64 0), i8* %31, i8* %32, i8* %36)
br label %51
38: ; preds = %18
%39 = load i32*, i32** %5
%40 = load i64, i64* %12
%41 = getelementptr inbounds [6 x %struct.dump_program_instruction_set], [6 x %struct.dump_program_instruction_set]* %10, i64 0, i64 %40
%42 = getelementptr inbounds %struct.dump_program_instruction_set, %struct.dump_program_instruction_set* %41, i32 0, i32 1
%43 = load i8*, i8** %42
%44 = load i8*, i8** %7
%45 = load i64, i64* %8
%46 = load i64, i64* %12
%47 = getelementptr inbounds [6 x %struct.dump_program_instruction_set], [6 x %struct.dump_program_instruction_set]* %10, i64 0, i64 %46
%48 = getelementptr inbounds %struct.dump_program_instruction_set, %struct.dump_program_instruction_set* %47, i32 0, i32 2
%49 = load i8*, i8** %48
%50 = call i32 @dump_tcpflag(i32* %39, i8* %43, i8* %44, i64 %45, i8* %49)
br label %51
51: ; preds = %38, %26
br label %52
52: ; preds = %51
%53 = load i64, i64* %12
%54 = add i64 %53, 1
store i64 %54, i64* %12
br label %14
55: ; preds = %14
ret void
}

LLVM IR (-O2):
%struct.dump_program_instruction_set = type { i8*, i8*, i8* }
@.str = [8 x i8] c"tcp-urg\00"
@.str.1 = [8 x i8] c"tcp.urg\00"
@.str.2 = [2 x i8] c",\00"
@.str.3 = [8 x i8] c"tcp-ack\00"
@.str.4 = [8 x i8] c"tcp.ack\00"
@.str.5 = [8 x i8] c"tcp-psh\00"
@.str.6 = [8 x i8] c"tcp.psh\00"
@.str.7 = [8 x i8] c"tcp-rst\00"
@.str.8 = [8 x i8] c"tcp.rst\00"
@.str.9 = [8 x i8] c"tcp-syn\00"
@.str.10 = [8 x i8] c"tcp.syn\00"
@.str.11 = [8 x i8] c"tcp-fin\00"
@.str.12 = [8 x i8] c"tcp.fin\00"
@.str.13 = [1 x i8] zeroinitializer
@__const.dump_tcpflags.dump_task = [6 x %struct.dump_program_instruction_set] [%struct.dump_program_instruction_set { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i32 0, i32 0) }, %struct.dump_program_instruction_set { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i32 0, i32 0) }, %struct.dump_program_instruction_set { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i32 0, i32 0) }, %struct.dump_program_instruction_set { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i32 0, i32 0) }, %struct.dump_program_instruction_set { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i32 0, i32 0) }, %struct.dump_program_instruction_set { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.13, i32 0, i32 0) }]
@.str.14 = [12 x i8] c"\0A %s = %s%s\00"
define void @dump_tcpflags(i32* %0, i8* nocapture readnone %1, i8* %2, i64 %3) {
br label %5
5: ; preds = %4, %19
%6 = phi i64 [ 0, %4 ], [ %20, %19 ]
%7 = getelementptr inbounds [6 x %struct.dump_program_instruction_set], [6 x %struct.dump_program_instruction_set]* @__const.dump_tcpflags.dump_task, i64 0, i64 %6, i32 0
%8 = load i8*, i8** %7
%9 = tail call i8* @get_option(i8* %8, i32* null)
%10 = icmp eq i8* %9, null
%11 = getelementptr inbounds [6 x %struct.dump_program_instruction_set], [6 x %struct.dump_program_instruction_set]* @__const.dump_tcpflags.dump_task, i64 0, i64 %6, i32 1
%12 = load i8*, i8** %11
%13 = getelementptr inbounds [6 x %struct.dump_program_instruction_set], [6 x %struct.dump_program_instruction_set]* @__const.dump_tcpflags.dump_task, i64 0, i64 %6, i32 2
%14 = load i8*, i8** %13
br i1 %10, label %17, label %15
15: ; preds = %5
%16 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.14, i64 0, i64 0), i8* %12, i8* %9, i8* %14)
br label %19
17: ; preds = %5
%18 = tail call i32 @dump_tcpflag(i32* %0, i8* %12, i8* %2, i64 %3, i8* %14)
br label %19
19: ; preds = %15, %17
%20 = add nuw nsw i64 %6, 1
%21 = icmp eq i64 %20, 6
br i1 %21, label %22, label %5
22: ; preds = %19
ret void
}