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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, char *);
int /*<<< orphan*/ stdout;
void ip4_print_flags(const uint16_t frag) {
  fprintf(stdout, "\t    %d... ....  Reserved bit: %s\n", (frag & 0x80) ? 1 : 0,
          (frag & 0x80) ? "set" : "not set");
  fprintf(stdout, "\t    .%d.. ....  Don't fragment: %s\n",
          (frag & 0x40) ? 1 : 0, (frag & 0x40) ? "set" : "not set");
  fprintf(stdout, "\t    ..%d. ....  More fragments: %s\n",
          (frag & 0x20) ? 1 : 0, (frag & 0x20) ? "set" : "not set");
}


x86 assembly (clang, -O0):
<ip4_print_flags>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    0x2ebe(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%ecx
and    $0x80,%ecx
xor    %edx,%edx
mov    $0x1,%eax
cmp    $0x0,%ecx
cmovne %eax,%edx
mov    -0x4(%rbp),%esi
and    $0x80,%esi
lea    0xed9(%rip),%rcx
lea    0xed6(%rip),%rax
cmp    $0x0,%esi
cmovne %rax,%rcx
lea    0xea1(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e75(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%ecx
and    $0x40,%ecx
xor    %edx,%edx
mov    $0x1,%eax
cmp    $0x0,%ecx
cmovne %eax,%edx
mov    -0x4(%rbp),%esi
and    $0x40,%esi
lea    0xe96(%rip),%rcx
lea    0xe93(%rip),%rax
cmp    $0x0,%esi
cmovne %rax,%rcx
lea    0xe89(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%ecx
and    $0x20,%ecx
xor    %edx,%edx
mov    $0x1,%eax
cmp    $0x0,%ecx
cmovne %eax,%edx
mov    -0x4(%rbp),%esi
and    $0x20,%esi
lea    0xe53(%rip),%rcx
lea    0xe50(%rip),%rax
cmp    $0x0,%esi
cmovne %rax,%rcx
lea    0xe6b(%rip),%rsi
call   1030 <fprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ip4_print_flags>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %edi,%ebx
mov    0x2ebf(%rip),%r15
mov    (%r15),%edi
mov    %ebx,%eax
and    $0x80,%eax
mov    %eax,%edx
shr    $0x7,%edx
test   %eax,%eax
lea    0xeea(%rip),%r12
lea    0xee7(%rip),%r14
mov    %r14,%rcx
cmove  %r12,%rcx
lea    0xeb2(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%r15),%edi
mov    %ebx,%eax
and    $0x40,%eax
mov    %eax,%edx
shr    $0x6,%edx
test   %eax,%eax
mov    %r14,%rcx
cmove  %r12,%rcx
lea    0xebb(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%r15),%edi
and    $0x20,%ebx
mov    %ebx,%edx
shr    $0x5,%edx
test   %ebx,%ebx
cmove  %r12,%r14
lea    0xec3(%rip),%rsi
mov    %r14,%rcx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <fprintf@plt>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [35 x i8] c"\09 %d... .... Reserved bit: %s\0A\00"
@.str.1 = [4 x i8] c"set\00"
@.str.2 = [8 x i8] c"not set\00"
@.str.3 = [37 x i8] c"\09 .%d.. .... Don't fragment: %s\0A\00"
@.str.4 = [37 x i8] c"\09 ..%d. .... More fragments: %s\0A\00"
define void @ip4_print_flags(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* @stdout
%4 = load i32, i32* %2
%5 = and i32 %4, 128
%6 = icmp ne i32 %5, 0
%7 = zext i1 %6 to i64
%8 = select i1 %6, i32 1, i32 0
%9 = load i32, i32* %2
%10 = and i32 %9, 128
%11 = icmp ne i32 %10, 0
%12 = zext i1 %11 to i64
%13 = select i1 %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0)
%14 = call i32 @fprintf(i32 %3, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %8, i8* %13)
%15 = load i32, i32* @stdout
%16 = load i32, i32* %2
%17 = and i32 %16, 64
%18 = icmp ne i32 %17, 0
%19 = zext i1 %18 to i64
%20 = select i1 %18, i32 1, i32 0
%21 = load i32, i32* %2
%22 = and i32 %21, 64
%23 = icmp ne i32 %22, 0
%24 = zext i1 %23 to i64
%25 = select i1 %23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0)
%26 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 %20, i8* %25)
%27 = load i32, i32* @stdout
%28 = load i32, i32* %2
%29 = and i32 %28, 32
%30 = icmp ne i32 %29, 0
%31 = zext i1 %30 to i64
%32 = select i1 %30, i32 1, i32 0
%33 = load i32, i32* %2
%34 = and i32 %33, 32
%35 = icmp ne i32 %34, 0
%36 = zext i1 %35 to i64
%37 = select i1 %35, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0)
%38 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i32 %32, i8* %37)
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [35 x i8] c"\09 %d... .... Reserved bit: %s\0A\00"
@.str.1 = [4 x i8] c"set\00"
@.str.2 = [8 x i8] c"not set\00"
@.str.3 = [37 x i8] c"\09 .%d.. .... Don't fragment: %s\0A\00"
@.str.4 = [37 x i8] c"\09 ..%d. .... More fragments: %s\0A\00"
define void @ip4_print_flags(i32 %0) {
%2 = load i32, i32* @stdout
%3 = and i32 %0, 128
%4 = icmp eq i32 %3, 0
%5 = xor i1 %4, true
%6 = zext i1 %5 to i32
%7 = select i1 %4, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0)
%8 = tail call i32 @fprintf(i32 %2, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %6, i8* %7)
%9 = load i32, i32* @stdout
%10 = and i32 %0, 64
%11 = icmp eq i32 %10, 0
%12 = xor i1 %11, true
%13 = zext i1 %12 to i32
%14 = select i1 %11, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0)
%15 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 %13, i8* %14)
%16 = load i32, i32* @stdout
%17 = and i32 %0, 32
%18 = icmp eq i32 %17, 0
%19 = xor i1 %18, true
%20 = zext i1 %19 to i32
%21 = select i1 %18, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0)
%22 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i32 %20, i8* %21)
ret void
}