#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 uint8_t;

/* Variables and functions */
int const TH_ACK;
int const TH_FIN;
int const TH_PUSH;
int const TH_RST;
int const TH_SYN;
int const TH_URG;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int const, ...);
int /*<<< orphan*/ stdout;
void tcp_print_flags(const uint8_t th_flags) {
  fprintf(stdout, "\tFlags: 0x%x\n", th_flags);
  fprintf(stdout, "\t    ..%d. ....  Urgent pointer: %s\n",
          (th_flags & TH_URG) ? 1 : 0, (th_flags & TH_URG) ? "set" : "not set");
  fprintf(stdout, "\t    ...%d ....  ACK: %s\n", (th_flags & TH_ACK) ? 1 : 0,
          (th_flags & TH_ACK) ? "set" : "not set");
  fprintf(stdout, "\t    .... %d...  Push: %s\n", (th_flags & TH_PUSH) ? 1 : 0,
          (th_flags & TH_PUSH) ? "set" : "not set");
  fprintf(stdout, "\t    .... .%d..  Reset: %s\n", (th_flags & TH_RST) ? 1 : 0,
          (th_flags & TH_RST) ? "set" : "not set");
  fprintf(stdout, "\t    .... ..%d.  Syn: %s\n", (th_flags & TH_SYN) ? 1 : 0,
          (th_flags & TH_SYN) ? "set" : "not set");
  fprintf(stdout, "\t    .... ...%d  Fin: %s\n", (th_flags & TH_FIN) ? 1 : 0,
          (th_flags & TH_FIN) ? "set" : "not set");
}


x86 assembly (clang, -O0):
<tcp_print_flags>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    0x2e8e(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%edx
lea    0xed2(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e74(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%ecx
mov    0x2e78(%rip),%rax
and    (%rax),%ecx
xor    %edx,%edx
mov    $0x1,%eax
cmp    $0x0,%ecx
cmovne %eax,%edx
mov    -0x4(%rbp),%esi
mov    0x2e5f(%rip),%rax
and    (%rax),%esi
lea    0xec9(%rip),%rcx
lea    0xec6(%rip),%rax
cmp    $0x0,%esi
cmovne %rax,%rcx
lea    0xe8f(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e23(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%ecx
mov    0x2e37(%rip),%rax
and    (%rax),%ecx
xor    %edx,%edx
mov    $0x1,%eax
cmp    $0x0,%ecx
cmovne %eax,%edx
mov    -0x4(%rbp),%esi
mov    0x2e1e(%rip),%rax
and    (%rax),%esi
lea    0xe78(%rip),%rcx
lea    0xe75(%rip),%rax
cmp    $0x0,%esi
cmovne %rax,%rcx
lea    0xe6b(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2dd2(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%ecx
mov    0x2dce(%rip),%rax
and    (%rax),%ecx
xor    %edx,%edx
mov    $0x1,%eax
cmp    $0x0,%ecx
cmovne %eax,%edx
mov    -0x4(%rbp),%esi
mov    0x2db5(%rip),%rax
and    (%rax),%esi
lea    0xe27(%rip),%rcx
lea    0xe24(%rip),%rax
cmp    $0x0,%esi
cmovne %rax,%rcx
lea    0xe34(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2d81(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%ecx
mov    0x2da5(%rip),%rax
and    (%rax),%ecx
xor    %edx,%edx
mov    $0x1,%eax
cmp    $0x0,%ecx
cmovne %eax,%edx
mov    -0x4(%rbp),%esi
mov    0x2d8c(%rip),%rax
and    (%rax),%esi
lea    0xdd6(%rip),%rcx
lea    0xdd3(%rip),%rax
cmp    $0x0,%esi
cmovne %rax,%rcx
lea    0xdfe(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2d30(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%ecx
mov    0x2d5c(%rip),%rax
and    (%rax),%ecx
xor    %edx,%edx
mov    $0x1,%eax
cmp    $0x0,%ecx
cmovne %eax,%edx
mov    -0x4(%rbp),%esi
mov    0x2d43(%rip),%rax
and    (%rax),%esi
lea    0xd85(%rip),%rcx
lea    0xd82(%rip),%rax
cmp    $0x0,%esi
cmovne %rax,%rcx
lea    0xdc9(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2cdf(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%ecx
mov    0x2ceb(%rip),%rax
and    (%rax),%ecx
xor    %edx,%edx
mov    $0x1,%eax
cmp    $0x0,%ecx
cmovne %eax,%edx
mov    -0x4(%rbp),%esi
mov    0x2cd2(%rip),%rax
and    (%rax),%esi
lea    0xd34(%rip),%rcx
lea    0xd31(%rip),%rax
cmp    $0x0,%esi
cmovne %rax,%rcx
lea    0xd92(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tcp_print_flags>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%edx
mov    0x2ec3(%rip),%rbx
mov    (%rbx),%edi
lea    0xeda(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0xed8(%rip),%rsi
lea    0xef6(%rip),%r14
xor    %edx,%edx
mov    %r14,%rcx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0xee9(%rip),%rsi
xor    %edx,%edx
mov    %r14,%rcx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0xeee(%rip),%rsi
xor    %edx,%edx
mov    %r14,%rcx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0xef4(%rip),%rsi
xor    %edx,%edx
mov    %r14,%rcx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0xefb(%rip),%rsi
xor    %edx,%edx
mov    %r14,%rcx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0xf00(%rip),%rsi
xor    %edx,%edx
mov    %r14,%rcx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <fprintf@plt>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [14 x i8] c"\09Flags: 0x%x\0A\00"
@.str.1 = [37 x i8] c"\09 ..%d. .... Urgent pointer: %s\0A\00"
@TH_URG = constant i32 0
@.str.2 = [4 x i8] c"set\00"
@.str.3 = [8 x i8] c"not set\00"
@.str.4 = [26 x i8] c"\09 ...%d .... ACK: %s\0A\00"
@TH_ACK = constant i32 0
@.str.5 = [27 x i8] c"\09 .... %d... Push: %s\0A\00"
@TH_PUSH = constant i32 0
@.str.6 = [28 x i8] c"\09 .... .%d.. Reset: %s\0A\00"
@TH_RST = constant i32 0
@.str.7 = [26 x i8] c"\09 .... ..%d. Syn: %s\0A\00"
@TH_SYN = constant i32 0
@.str.8 = [26 x i8] c"\09 .... ...%d Fin: %s\0A\00"
@TH_FIN = constant i32 0
define void @tcp_print_flags(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* @stdout
%4 = load i32, i32* %2
%5 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %3, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = load i32, i32* @stdout
%7 = load i32, i32* %2
%8 = load i32, i32* @TH_URG
%9 = and i32 %7, %8
%10 = icmp ne i32 %9, 0
%11 = zext i1 %10 to i64
%12 = select i1 %10, i32 1, i32 0
%13 = load i32, i32* %2
%14 = load i32, i32* @TH_URG
%15 = and i32 %13, %14
%16 = icmp ne i32 %15, 0
%17 = zext i1 %16 to i64
%18 = select i1 %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0)
%19 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %12, i8* %18)
%20 = load i32, i32* @stdout
%21 = load i32, i32* %2
%22 = load i32, i32* @TH_ACK
%23 = and i32 %21, %22
%24 = icmp ne i32 %23, 0
%25 = zext i1 %24 to i64
%26 = select i1 %24, i32 1, i32 0
%27 = load i32, i32* %2
%28 = load i32, i32* @TH_ACK
%29 = and i32 %27, %28
%30 = icmp ne i32 %29, 0
%31 = zext i1 %30 to i64
%32 = select i1 %30, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0)
%33 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %26, i8* %32)
%34 = load i32, i32* @stdout
%35 = load i32, i32* %2
%36 = load i32, i32* @TH_PUSH
%37 = and i32 %35, %36
%38 = icmp ne i32 %37, 0
%39 = zext i1 %38 to i64
%40 = select i1 %38, i32 1, i32 0
%41 = load i32, i32* %2
%42 = load i32, i32* @TH_PUSH
%43 = and i32 %41, %42
%44 = icmp ne i32 %43, 0
%45 = zext i1 %44 to i64
%46 = select i1 %44, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0)
%47 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i32 %40, i8* %46)
%48 = load i32, i32* @stdout
%49 = load i32, i32* %2
%50 = load i32, i32* @TH_RST
%51 = and i32 %49, %50
%52 = icmp ne i32 %51, 0
%53 = zext i1 %52 to i64
%54 = select i1 %52, i32 1, i32 0
%55 = load i32, i32* %2
%56 = load i32, i32* @TH_RST
%57 = and i32 %55, %56
%58 = icmp ne i32 %57, 0
%59 = zext i1 %58 to i64
%60 = select i1 %58, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0)
%61 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i32 %54, i8* %60)
%62 = load i32, i32* @stdout
%63 = load i32, i32* %2
%64 = load i32, i32* @TH_SYN
%65 = and i32 %63, %64
%66 = icmp ne i32 %65, 0
%67 = zext i1 %66 to i64
%68 = select i1 %66, i32 1, i32 0
%69 = load i32, i32* %2
%70 = load i32, i32* @TH_SYN
%71 = and i32 %69, %70
%72 = icmp ne i32 %71, 0
%73 = zext i1 %72 to i64
%74 = select i1 %72, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0)
%75 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), i32 %68, i8* %74)
%76 = load i32, i32* @stdout
%77 = load i32, i32* %2
%78 = load i32, i32* @TH_FIN
%79 = and i32 %77, %78
%80 = icmp ne i32 %79, 0
%81 = zext i1 %80 to i64
%82 = select i1 %80, i32 1, i32 0
%83 = load i32, i32* %2
%84 = load i32, i32* @TH_FIN
%85 = and i32 %83, %84
%86 = icmp ne i32 %85, 0
%87 = zext i1 %86 to i64
%88 = select i1 %86, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0)
%89 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %76, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i32 %82, i8* %88)
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [14 x i8] c"\09Flags: 0x%x\0A\00"
@.str.1 = [37 x i8] c"\09 ..%d. .... Urgent pointer: %s\0A\00"
@TH_URG = constant i32 0
@.str.3 = [8 x i8] c"not set\00"
@.str.4 = [26 x i8] c"\09 ...%d .... ACK: %s\0A\00"
@TH_ACK = constant i32 0
@.str.5 = [27 x i8] c"\09 .... %d... Push: %s\0A\00"
@TH_PUSH = constant i32 0
@.str.6 = [28 x i8] c"\09 .... .%d.. Reset: %s\0A\00"
@TH_RST = constant i32 0
@.str.7 = [26 x i8] c"\09 .... ..%d. Syn: %s\0A\00"
@TH_SYN = constant i32 0
@.str.8 = [26 x i8] c"\09 .... ...%d Fin: %s\0A\00"
@TH_FIN = constant i32 0
define void @tcp_print_flags(i32 %0) {
%2 = load i32, i32* @stdout
%3 = tail call i32 (i32, i8*, i32, ...) @fprintf(i32 %2, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %0)
%4 = load i32, i32* @stdout
%5 = tail call i32 (i32, i8*, i32, ...) @fprintf(i32 %4, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%6 = load i32, i32* @stdout
%7 = tail call i32 (i32, i8*, i32, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%8 = load i32, i32* @stdout
%9 = tail call i32 (i32, i8*, i32, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i32 0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%10 = load i32, i32* @stdout
%11 = tail call i32 (i32, i8*, i32, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i32 0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%12 = load i32, i32* @stdout
%13 = tail call i32 (i32, i8*, i32, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), i32 0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%14 = load i32, i32* @stdout
%15 = tail call i32 (i32, i8*, i32, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i32 0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
ret void
}