#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*/ u_int8_t;
typedef int /*<<< orphan*/ u_int16_t;
typedef int /*<<< orphan*/ u_int;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int get_option(int, char **);
int /*<<< orphan*/ init();
int layer2();
int layer3(int /*<<< orphan*/);
int /*<<< orphan*/ layer4(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ receive_packet();
int main(int argc, char **argv) {
  int type;
  int protocol;
  int count;
  if (argc == 1) {
    count = 5;
  } else if ((count = get_option(argc, argv)) < 0) {
    exit(EXIT_FAILURE);
  } else if (count == 0) {
    exit(EXIT_SUCCESS);
  }
  init();
  while (count-- > 0) {
    receive_packet();
    puts("============================= HEADER ==============================");
    if ((type = layer2()) < 0)
      continue;
    protocol = layer3((u_int)type);
    if (protocol < 0)
      continue;
    layer4((u_int16_t)type, (u_int8_t)protocol);
    putchar('\n');
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    11bc <main+0x2c>
movl   $0x5,-0x1c(%rbp)
jmp    1204 <main+0x74>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1090 <get_option@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jge    11e2 <main+0x52>
mov    0x2e05(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
cmpl   $0x0,-0x1c(%rbp)
jne    11fa <main+0x6a>
mov    0x2de5(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
jmp    11ff <main+0x6f>
jmp    1204 <main+0x74>
mov    $0x0,%al
call   1060 <init@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x1c(%rbp)
cmp    $0x0,%eax
jle    127e <main+0xee>
mov    $0x0,%al
call   1070 <receive_packet@plt>
lea    0xdd3(%rip),%rdi
call   1040 <puts@plt>
mov    $0x0,%al
call   10a0 <layer2@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    124a <main+0xba>
jmp    120b <main+0x7b>
mov    -0x14(%rbp),%edi
call   1050 <layer3@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    1264 <main+0xd4>
jmp    120b <main+0x7b>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   10b0 <layer4@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    120b <main+0x7b>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    $0x5,%ebx
cmp    $0x1,%edi
je     11ab <main+0x1b>
call   1090 <get_option@plt>
test   %eax,%eax
js     120b <main+0x7b>
mov    %eax,%ebx
je     1219 <main+0x89>
xor    %eax,%eax
call   1060 <init@plt>
add    $0x1,%ebx
lea    0xe44(%rip),%r14
jmp    11c8 <main+0x38>
xchg   %ax,%ax
add    $0xffffffff,%ebx
cmp    $0x1,%ebx
jbe    1204 <main+0x74>
xor    %eax,%eax
call   1070 <receive_packet@plt>
mov    %r14,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   10a0 <layer2@plt>
test   %eax,%eax
js     11c0 <main+0x30>
mov    %eax,%ebp
mov    %eax,%edi
call   1050 <layer3@plt>
test   %eax,%eax
js     11c0 <main+0x30>
mov    %ebp,%edi
mov    %eax,%esi
call   10b0 <layer4@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11c0 <main+0x30>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2dce(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    0x2db8(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
@.str = [68 x i8] c"============================= HEADER ==============================\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 5, i32* %8
br label %28
12: ; preds = %2
%13 = load i32, i32* %4
%14 = load i8**, i8*** %5
%15 = call i32 @get_option(i32 %13, i8** %14)
store i32 %15, i32* %8
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %12
%18 = load i32, i32* @EXIT_FAILURE
%19 = call i32 @exit(i32 %18)
unreachable
20: ; preds = %12
%21 = load i32, i32* %8
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = load i32, i32* @EXIT_SUCCESS
%25 = call i32 @exit(i32 %24)
unreachable
26: ; preds = %20
br label %27
27: ; preds = %26
br label %28
28: ; preds = %27, %11
%29 = call i32 (...) @init()
br label %30
30: ; preds = %46, %45, %39, %28
%31 = load i32, i32* %8
%32 = add nsw i32 %31, -1
store i32 %32, i32* %8
%33 = icmp sgt i32 %31, 0
br i1 %33, label %34, label %51
34: ; preds = %30
%35 = call i32 (...) @receive_packet()
%36 = call i32 @puts(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str, i64 0, i64 0))
%37 = call i32 (...) @layer2()
store i32 %37, i32* %6
%38 = icmp slt i32 %37, 0
br i1 %38, label %39, label %40
39: ; preds = %34
br label %30
40: ; preds = %34
%41 = load i32, i32* %6
%42 = call i32 @layer3(i32 %41)
store i32 %42, i32* %7
%43 = load i32, i32* %7
%44 = icmp slt i32 %43, 0
br i1 %44, label %45, label %46
45: ; preds = %40
br label %30
46: ; preds = %40
%47 = load i32, i32* %6
%48 = load i32, i32* %7
%49 = call i32 @layer4(i32 %47, i32 %48)
%50 = call i32 @putchar(i8 signext 10)
br label %30
51: ; preds = %30
ret i32 0
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
@.str = [68 x i8] c"============================= HEADER ==============================\00"
define i32 @main(i32 %0, i8** %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %15, label %4
4: ; preds = %2
%5 = tail call i32 @get_option(i32 %0, i8** %1)
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %4
%8 = load i32, i32* @EXIT_FAILURE
%9 = tail call i32 @exit(i32 %8)
unreachable
10: ; preds = %4
%11 = icmp eq i32 %5, 0
br i1 %11, label %12, label %15
12: ; preds = %10
%13 = load i32, i32* @EXIT_SUCCESS
%14 = tail call i32 @exit(i32 %13)
unreachable
15: ; preds = %10, %2
%16 = phi i32 [ %5, %10 ], [ 5, %2 ]
%17 = tail call i32 (...) @init()
br label %18
18: ; preds = %15, %31
%19 = phi i32 [ %20, %31 ], [ %16, %15 ]
%20 = add nsw i32 %19, -1
%21 = tail call i32 (...) @receive_packet()
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([68 x i8], [68 x i8]* @.str, i64 0, i64 0))
%23 = tail call i32 (...) @layer2()
%24 = icmp slt i32 %23, 0
br i1 %24, label %31, label %25
25: ; preds = %18
%26 = tail call i32 @layer3(i32 %23)
%27 = icmp slt i32 %26, 0
br i1 %27, label %31, label %28
28: ; preds = %25
%29 = tail call i32 @layer4(i32 %23, i32 %26)
%30 = tail call i32 @putchar(i8 signext 10)
br label %31
31: ; preds = %28, %18, %25
%32 = icmp ugt i32 %19, 1
br i1 %32, label %18, label %33
33: ; preds = %31
ret i32 0
}