#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 */

/* Variables and functions */
int /*<<< orphan*/ ETH_P_IP;
#define IPPROTO_ICMP 133
#define IPPROTO_IGMP 132
#define IPPROTO_IPIP 131
#define IPPROTO_RAW 130
#define IPPROTO_TCP 129
#define IPPROTO_UDP 128
int /*<<< orphan*/ PF_PACKET;
int /*<<< orphan*/ SOCK_RAW;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ htons(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int recvfrom(int, char *, int, int /*<<< orphan*/, int /*<<< orphan*/ *,
             int /*<<< orphan*/ *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  int sock, n_read, proto;
  char buffer[2048];
  char *ethhead, *iphead, *tcphead, *udphead, *icmphead, *p;
  if ((sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_IP))) < 0) {
    fprintf(stdout, "create socket error/n");
    exit(0);
  }
  while (1) {
    n_read = recvfrom(sock, buffer, 2048, 0, NULL, NULL);
    if (n_read < 42) {
      fprintf(stdout, "Incomplete header, packet corrupt/n");
      continue;
    }
    ethhead = buffer;
    p = ethhead;
    int n = 0XFF;
    printf("MAC: %.2X:%02X:%02X:%02X:%02X:%02X==>"
           "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X/n",
           p[6] & n, p[7] & n, p[8] & n, p[9] & n, p[10] & n, p[11] & n,
           p[0] & n, p[1] & n, p[2] & n, p[3] & n, p[4] & n, p[5] & n);
    iphead = ethhead + 14;
    p = iphead + 12;
    printf("IP: %d.%d.%d.%d => %d.%d.%d.%d/n", p[0] & 0XFF, p[1] & 0XFF,
           p[2] & 0XFF, p[3] & 0XFF, p[4] & 0XFF, p[5] & 0XFF, p[6] & 0XFF,
           p[7] & 0XFF);
    proto = (iphead + 9)[0];
    p = iphead + 20;
    printf("Protocol: ");
    switch (proto) {
    case IPPROTO_ICMP:
      printf("ICMP/n");
      break;
    case IPPROTO_IGMP:
      printf("IGMP/n");
      break;
    case IPPROTO_IPIP:
      printf("IPIP/n");
      break;
    case IPPROTO_TCP:
    case IPPROTO_UDP:
      printf("%s,", proto == IPPROTO_TCP ? "TCP" : "UDP");
      printf("source port: %u,", (p[0] << 8) & 0XFF00 | p[1] & 0XFF);
      printf("dest port: %u/n", (p[2] << 8) & 0XFF00 | p[3] & 0XFF);
      break;
    case IPPROTO_RAW:
      printf("RAW/n");
      break;
    default:
      printf("Unkown, please query in include/linux/in.h/n");
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x8c0,%rsp
movl   $0x0,-0x24(%rbp)
mov    %edi,-0x28(%rbp)
mov    %rsi,-0x30(%rbp)
mov    0x2e69(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x87c(%rbp)
mov    0x2e4a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x878(%rbp)
mov    0x2e23(%rip),%rax
mov    (%rax),%edi
call   1030 <htons@plt>
mov    -0x87c(%rbp),%edi
mov    -0x878(%rbp),%esi
mov    %eax,%edx
call   1080 <socket@plt>
mov    %eax,-0x34(%rbp)
cmp    $0x0,%eax
jge    11e7 <main+0x87>
mov    0x2dfe(%rip),%rax
mov    (%rax),%edi
lea    0xe3d(%rip),%rsi
call   1050 <fprintf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
jmp    11ec <main+0x8c>
mov    -0x34(%rbp),%edi
lea    -0x840(%rbp),%rsi
mov    $0x800,%edx
xor    %ecx,%ecx
xor    %eax,%eax
mov    %eax,%r9d
mov    %r9,%r8
call   1060 <recvfrom@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x2a,-0x38(%rbp)
jge    1231 <main+0xd1>
mov    0x2db2(%rip),%rax
mov    (%rax),%edi
lea    0xe07(%rip),%rsi
call   1050 <fprintf@plt>
jmp    11ec <main+0x8c>
lea    -0x840(%rbp),%rax
mov    %rax,-0x848(%rbp)
mov    -0x848(%rbp),%rax
mov    %rax,-0x870(%rbp)
movl   $0xff,-0x874(%rbp)
mov    -0x870(%rbp),%r12
mov    %r12,-0x8a8(%rbp)
movsbl 0x6(%r12),%esi
mov    -0x874(%rbp),%eax
mov    %eax,-0x89c(%rbp)
and    %eax,%esi
movsbl 0x7(%r12),%edx
and    %eax,%edx
movsbl 0x8(%r12),%ecx
and    %eax,%ecx
movsbl 0x9(%r12),%r8d
and    %eax,%r8d
movsbl 0xa(%r12),%r9d
and    %eax,%r9d
movsbl 0xb(%r12),%edi
and    %eax,%edi
movsbl (%r12),%r10d
and    %eax,%r10d
movsbl 0x1(%r12),%r11d
and    %eax,%r11d
movsbl 0x2(%r12),%ebx
and    %eax,%ebx
movsbl 0x3(%r12),%r14d
and    %eax,%r14d
movsbl 0x4(%r12),%r15d
and    %eax,%r15d
movsbl 0x5(%r12),%r12d
and    %eax,%r12d
mov    %rsp,%rax
mov    %r12d,0x30(%rax)
mov    %r15d,0x28(%rax)
mov    %r14d,0x20(%rax)
mov    %ebx,0x18(%rax)
mov    %r11d,0x10(%rax)
mov    %r10d,0x8(%rax)
mov    %edi,(%rax)
lea    0xd58(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x889(%rbp)
call   1040 <printf@plt>
mov    -0x889(%rbp),%al
mov    -0x848(%rbp),%rcx
add    $0xe,%rcx
mov    %rcx,-0x850(%rbp)
mov    -0x850(%rbp),%rcx
add    $0xc,%rcx
mov    %rcx,-0x870(%rbp)
mov    -0x870(%rbp),%rdi
mov    %rdi,-0x898(%rbp)
movzbl (%rdi),%esi
movzbl 0x1(%rdi),%edx
movzbl 0x2(%rdi),%ecx
movzbl 0x3(%rdi),%r8d
movzbl 0x4(%rdi),%r9d
movzbl 0x5(%rdi),%r10d
movzbl 0x6(%rdi),%r11d
movzbl 0x7(%rdi),%ebx
mov    %rsp,%rdi
mov    %ebx,0x10(%rdi)
mov    %r11d,0x8(%rdi)
mov    %r10d,(%rdi)
lea    0xd21(%rip),%rdi
call   1040 <printf@plt>
mov    -0x889(%rbp),%al
mov    -0x850(%rbp),%rcx
movsbl 0x9(%rcx),%ecx
mov    %ecx,-0x3c(%rbp)
mov    -0x850(%rbp),%rcx
add    $0x14,%rcx
mov    %rcx,-0x870(%rbp)
lea    0xd10(%rip),%rdi
call   1040 <printf@plt>
mov    -0x3c(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x888(%rbp)
sub    $0x5,%eax
ja     14bd <main+0x35d>
mov    -0x888(%rbp),%rax
lea    0xc2d(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xce0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    14cb <main+0x36b>
lea    0xcd4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    14cb <main+0x36b>
lea    0xcc8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    14cb <main+0x36b>
mov    -0x3c(%rbp),%ecx
lea    0xcc1(%rip),%rsi
lea    0xcb6(%rip),%rax
cmp    $0x81,%ecx
cmove  %rax,%rsi
lea    0xca1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x870(%rbp),%rax
movsbl (%rax),%esi
shl    $0x8,%esi
and    $0xff00,%esi
mov    -0x870(%rbp),%rax
movsbl 0x1(%rax),%eax
and    $0xff,%eax
or     %eax,%esi
lea    0xc7a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x870(%rbp),%rax
movsbl 0x2(%rax),%esi
shl    $0x8,%esi
and    $0xff00,%esi
mov    -0x870(%rbp),%rax
movsbl 0x3(%rax),%eax
and    $0xff,%eax
or     %eax,%esi
lea    0xc57(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    14cb <main+0x36b>
lea    0xc54(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    14cb <main+0x36b>
lea    0xc47(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11ec <main+0x8c>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x808,%rsp
mov    0x2e78(%rip),%rax
mov    (%rax),%ebx
mov    0x2e5f(%rip),%rax
mov    (%rax),%ebp
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
call   1030 <htons@plt>
mov    %ebx,%edi
mov    %ebp,%esi
mov    %eax,%edx
call   1080 <socket@plt>
test   %eax,%eax
js     12b2 <main+0x152>
mov    %eax,%r13d
mov    %rsp,%rbx
jmp    127a <main+0x11a>
nop
movzbl 0x6(%rsp),%esi
movzbl 0x7(%rsp),%edx
movzbl 0x8(%rsp),%ecx
movzbl 0x9(%rsp),%r8d
movzbl 0xa(%rsp),%r9d
movzbl 0xb(%rsp),%r10d
movzbl (%rsp),%r11d
movzbl 0x1(%rsp),%ebp
movzbl 0x2(%rsp),%ebx
movzbl 0x3(%rsp),%r12d
movzbl 0x4(%rsp),%r15d
movzbl 0x5(%rsp),%r14d
sub    $0x8,%rsp
lea    0xe3d(%rip),%rdi
xor    %eax,%eax
push   %r14
push   %r15
push   %r12
push   %rbx
push   %rbp
push   %r11
push   %r10
call   1040 <printf@plt>
add    $0x40,%rsp
movzbl 0x1a(%rsp),%esi
movzbl 0x1b(%rsp),%edx
movzbl 0x1c(%rsp),%ecx
movzbl 0x1d(%rsp),%r8d
movzbl 0x1e(%rsp),%r9d
movzbl 0x1f(%rsp),%r10d
movzbl 0x20(%rsp),%ebx
movzbl 0x21(%rsp),%ebp
sub    $0x8,%rsp
lea    0xe35(%rip),%rdi
xor    %eax,%eax
push   %rbp
push   %rbx
lea    0x18(%rsp),%rbx
push   %r10
call   1040 <printf@plt>
add    $0x20,%rsp
lea    0xe3b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe38(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    $0x800,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1060 <recvfrom@plt>
cmp    $0x29,%eax
jg     11b0 <main+0x50>
mov    0x2d2e(%rip),%rax
mov    (%rax),%edi
lea    0xd6b(%rip),%rsi
call   1050 <fprintf@plt>
jmp    127a <main+0x11a>
mov    0x2d17(%rip),%rax
mov    (%rax),%edi
lea    0xd3e(%rip),%rsi
call   1050 <fprintf@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@PF_PACKET = global i32 0
@SOCK_RAW = global i32 0
@ETH_P_IP = global i32 0
@stdout = global i32 0
@.str = [22 x i8] c"create socket error/n\00"
@.str.1 = [36 x i8] c"Incomplete header, packet corrupt/n\00"
@.str.2 = [69 x i8] c"MAC: %.2X:%02X:%02X:%02X:%02X:%02X==>%.2X:%.2X:%.2X:%.2X:%.2X:%.2X/n\00"
@.str.3 = [33 x i8] c"IP: %d.%d.%d.%d => %d.%d.%d.%d/n\00"
@.str.4 = [11 x i8] c"Protocol: \00"
@.str.5 = [7 x i8] c"ICMP/n\00"
@.str.6 = [7 x i8] c"IGMP/n\00"
@.str.7 = [7 x i8] c"IPIP/n\00"
@.str.8 = [4 x i8] c"%s,\00"
@.str.9 = [4 x i8] c"TCP\00"
@.str.10 = [4 x i8] c"UDP\00"
@.str.11 = [17 x i8] c"source port: %u,\00"
@.str.12 = [16 x i8] c"dest port: %u/n\00"
@.str.13 = [6 x i8] c"RAW/n\00"
@.str.14 = [45 x i8] c"Unkown, please query in include/linux/in.h/n\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
%9 = alloca [2048 x i8]
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%17 = load i32, i32* @PF_PACKET
%18 = load i32, i32* @SOCK_RAW
%19 = load i32, i32* @ETH_P_IP
%20 = call i32 @htons(i32 %19)
%21 = call i32 @socket(i32 %17, i32 %18, i32 %20)
store i32 %21, i32* %6
%22 = icmp slt i32 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %2
%24 = load i32, i32* @stdout
%25 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%26 = call i32 @exit(i32 0)
unreachable
27: ; preds = %2
br label %28
28: ; preds = %27, %34, %209
%29 = load i32, i32* %6
%30 = getelementptr inbounds [2048 x i8], [2048 x i8]* %9, i64 0, i64 0
%31 = call i32 @recvfrom(i32 %29, i8* %30, i32 2048, i32 0, i32* null, i32* null)
store i32 %31, i32* %7
%32 = load i32, i32* %7
%33 = icmp slt i32 %32, 42
br i1 %33, label %34, label %37
34: ; preds = %28
%35 = load i32, i32* @stdout
%36 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
br label %28
37: ; preds = %28
%38 = getelementptr inbounds [2048 x i8], [2048 x i8]* %9, i64 0, i64 0
store i8* %38, i8** %10
%39 = load i8*, i8** %10
store i8* %39, i8** %15
store i32 255, i32* %16
%40 = load i8*, i8** %15
%41 = getelementptr inbounds i8, i8* %40, i64 6
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = load i32, i32* %16
%45 = and i32 %43, %44
%46 = load i8*, i8** %15
%47 = getelementptr inbounds i8, i8* %46, i64 7
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = load i32, i32* %16
%51 = and i32 %49, %50
%52 = load i8*, i8** %15
%53 = getelementptr inbounds i8, i8* %52, i64 8
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = load i32, i32* %16
%57 = and i32 %55, %56
%58 = load i8*, i8** %15
%59 = getelementptr inbounds i8, i8* %58, i64 9
%60 = load i8, i8* %59
%61 = sext i8 %60 to i32
%62 = load i32, i32* %16
%63 = and i32 %61, %62
%64 = load i8*, i8** %15
%65 = getelementptr inbounds i8, i8* %64, i64 10
%66 = load i8, i8* %65
%67 = sext i8 %66 to i32
%68 = load i32, i32* %16
%69 = and i32 %67, %68
%70 = load i8*, i8** %15
%71 = getelementptr inbounds i8, i8* %70, i64 11
%72 = load i8, i8* %71
%73 = sext i8 %72 to i32
%74 = load i32, i32* %16
%75 = and i32 %73, %74
%76 = load i8*, i8** %15
%77 = getelementptr inbounds i8, i8* %76, i64 0
%78 = load i8, i8* %77
%79 = sext i8 %78 to i32
%80 = load i32, i32* %16
%81 = and i32 %79, %80
%82 = load i8*, i8** %15
%83 = getelementptr inbounds i8, i8* %82, i64 1
%84 = load i8, i8* %83
%85 = sext i8 %84 to i32
%86 = load i32, i32* %16
%87 = and i32 %85, %86
%88 = load i8*, i8** %15
%89 = getelementptr inbounds i8, i8* %88, i64 2
%90 = load i8, i8* %89
%91 = sext i8 %90 to i32
%92 = load i32, i32* %16
%93 = and i32 %91, %92
%94 = load i8*, i8** %15
%95 = getelementptr inbounds i8, i8* %94, i64 3
%96 = load i8, i8* %95
%97 = sext i8 %96 to i32
%98 = load i32, i32* %16
%99 = and i32 %97, %98
%100 = load i8*, i8** %15
%101 = getelementptr inbounds i8, i8* %100, i64 4
%102 = load i8, i8* %101
%103 = sext i8 %102 to i32
%104 = load i32, i32* %16
%105 = and i32 %103, %104
%106 = load i8*, i8** %15
%107 = getelementptr inbounds i8, i8* %106, i64 5
%108 = load i8, i8* %107
%109 = sext i8 %108 to i32
%110 = load i32, i32* %16
%111 = and i32 %109, %110
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.2, i64 0, i64 0), i32 %45, i32 %51, i32 %57, i32 %63, i32 %69, i32 %75, i32 %81, i32 %87, i32 %93, i32 %99, i32 %105, i32 %111)
%113 = load i8*, i8** %10
%114 = getelementptr inbounds i8, i8* %113, i64 14
store i8* %114, i8** %11
%115 = load i8*, i8** %11
%116 = getelementptr inbounds i8, i8* %115, i64 12
store i8* %116, i8** %15
%117 = load i8*, i8** %15
%118 = getelementptr inbounds i8, i8* %117, i64 0
%119 = load i8, i8* %118
%120 = sext i8 %119 to i32
%121 = and i32 %120, 255
%122 = load i8*, i8** %15
%123 = getelementptr inbounds i8, i8* %122, i64 1
%124 = load i8, i8* %123
%125 = sext i8 %124 to i32
%126 = and i32 %125, 255
%127 = load i8*, i8** %15
%128 = getelementptr inbounds i8, i8* %127, i64 2
%129 = load i8, i8* %128
%130 = sext i8 %129 to i32
%131 = and i32 %130, 255
%132 = load i8*, i8** %15
%133 = getelementptr inbounds i8, i8* %132, i64 3
%134 = load i8, i8* %133
%135 = sext i8 %134 to i32
%136 = and i32 %135, 255
%137 = load i8*, i8** %15
%138 = getelementptr inbounds i8, i8* %137, i64 4
%139 = load i8, i8* %138
%140 = sext i8 %139 to i32
%141 = and i32 %140, 255
%142 = load i8*, i8** %15
%143 = getelementptr inbounds i8, i8* %142, i64 5
%144 = load i8, i8* %143
%145 = sext i8 %144 to i32
%146 = and i32 %145, 255
%147 = load i8*, i8** %15
%148 = getelementptr inbounds i8, i8* %147, i64 6
%149 = load i8, i8* %148
%150 = sext i8 %149 to i32
%151 = and i32 %150, 255
%152 = load i8*, i8** %15
%153 = getelementptr inbounds i8, i8* %152, i64 7
%154 = load i8, i8* %153
%155 = sext i8 %154 to i32
%156 = and i32 %155, 255
%157 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 %121, i32 %126, i32 %131, i32 %136, i32 %141, i32 %146, i32 %151, i32 %156)
%158 = load i8*, i8** %11
%159 = getelementptr inbounds i8, i8* %158, i64 9
%160 = getelementptr inbounds i8, i8* %159, i64 0
%161 = load i8, i8* %160
%162 = sext i8 %161 to i32
store i32 %162, i32* %8
%163 = load i8*, i8** %11
%164 = getelementptr inbounds i8, i8* %163, i64 20
store i8* %164, i8** %15
%165 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%166 = load i32, i32* %8
switch i32 %166, label %207 [
i32 133, label %167
i32 132, label %169
i32 131, label %171
i32 129, label %173
i32 128, label %173
i32 130, label %205
]
167: ; preds = %37
%168 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
br label %209
169: ; preds = %37
%170 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
br label %209
171: ; preds = %37
%172 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
br label %209
173: ; preds = %37, %37
%174 = load i32, i32* %8
%175 = icmp eq i32 %174, 129
%176 = zext i1 %175 to i64
%177 = select i1 %175, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0)
%178 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* %177)
%179 = load i8*, i8** %15
%180 = getelementptr inbounds i8, i8* %179, i64 0
%181 = load i8, i8* %180
%182 = sext i8 %181 to i32
%183 = shl i32 %182, 8
%184 = and i32 %183, 65280
%185 = load i8*, i8** %15
%186 = getelementptr inbounds i8, i8* %185, i64 1
%187 = load i8, i8* %186
%188 = sext i8 %187 to i32
%189 = and i32 %188, 255
%190 = or i32 %184, %189
%191 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0), i32 %190)
%192 = load i8*, i8** %15
%193 = getelementptr inbounds i8, i8* %192, i64 2
%194 = load i8, i8* %193
%195 = sext i8 %194 to i32
%196 = shl i32 %195, 8
%197 = and i32 %196, 65280
%198 = load i8*, i8** %15
%199 = getelementptr inbounds i8, i8* %198, i64 3
%200 = load i8, i8* %199
%201 = sext i8 %200 to i32
%202 = and i32 %201, 255
%203 = or i32 %197, %202
%204 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.12, i64 0, i64 0), i32 %203)
br label %209
205: ; preds = %37
%206 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i64 0, i64 0))
br label %209
207: ; preds = %37
%208 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.14, i64 0, i64 0))
br label %209
209: ; preds = %207, %205, %173, %171, %169, %167
br label %28
}

LLVM IR (-O2):
@PF_PACKET = global i32 0
@SOCK_RAW = global i32 0
@ETH_P_IP = global i32 0
@stdout = global i32 0
@.str = [22 x i8] c"create socket error/n\00"
@.str.1 = [36 x i8] c"Incomplete header, packet corrupt/n\00"
@.str.2 = [69 x i8] c"MAC: %.2X:%02X:%02X:%02X:%02X:%02X==>%.2X:%.2X:%.2X:%.2X:%.2X:%.2X/n\00"
@.str.3 = [33 x i8] c"IP: %d.%d.%d.%d => %d.%d.%d.%d/n\00"
@.str.4 = [11 x i8] c"Protocol: \00"
@.str.14 = [45 x i8] c"Unkown, please query in include/linux/in.h/n\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [2048 x i8]
%4 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 0
%5 = load i32, i32* @PF_PACKET
%6 = load i32, i32* @SOCK_RAW
%7 = load i32, i32* @ETH_P_IP
%8 = tail call i32 @htons(i32 %7)
%9 = tail call i32 @socket(i32 %5, i32 %6, i32 %8)
%10 = icmp slt i32 %9, 0
br i1 %10, label %31, label %11
11: ; preds = %2
%12 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 6
%13 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 7
%14 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 8
%15 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 9
%16 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 10
%17 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 11
%18 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 1
%19 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 2
%20 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 3
%21 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 4
%22 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 5
%23 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 26
%24 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 27
%25 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 28
%26 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 29
%27 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 30
%28 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 31
%29 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 32
%30 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 33
br label %35
31: ; preds = %2
%32 = load i32, i32* @stdout
%33 = tail call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%34 = tail call i32 @exit(i32 0)
unreachable
35: ; preds = %41, %11
%36 = call i32 @recvfrom(i32 %9, i8* %4, i32 2048, i32 0, i32* null, i32* null)
%37 = icmp slt i32 %36, 42
br i1 %37, label %38, label %42
38: ; preds = %35
%39 = load i32, i32* @stdout
%40 = call i32 @fprintf(i32 %39, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
br label %41
41: ; preds = %38, %42
br label %35
42: ; preds = %35
%43 = load i8, i8* %12
%44 = zext i8 %43 to i32
%45 = load i8, i8* %13
%46 = zext i8 %45 to i32
%47 = load i8, i8* %14
%48 = zext i8 %47 to i32
%49 = load i8, i8* %15
%50 = zext i8 %49 to i32
%51 = load i8, i8* %16
%52 = zext i8 %51 to i32
%53 = load i8, i8* %17
%54 = zext i8 %53 to i32
%55 = load i8, i8* %4
%56 = zext i8 %55 to i32
%57 = load i8, i8* %18
%58 = zext i8 %57 to i32
%59 = load i8, i8* %19
%60 = zext i8 %59 to i32
%61 = load i8, i8* %20
%62 = zext i8 %61 to i32
%63 = load i8, i8* %21
%64 = zext i8 %63 to i32
%65 = load i8, i8* %22
%66 = zext i8 %65 to i32
%67 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @.str.2, i64 0, i64 0), i32 %44, i32 %46, i32 %48, i32 %50, i32 %52, i32 %54, i32 %56, i32 %58, i32 %60, i32 %62, i32 %64, i32 %66)
%68 = load i8, i8* %23
%69 = zext i8 %68 to i32
%70 = load i8, i8* %24
%71 = zext i8 %70 to i32
%72 = load i8, i8* %25
%73 = zext i8 %72 to i32
%74 = load i8, i8* %26
%75 = zext i8 %74 to i32
%76 = load i8, i8* %27
%77 = zext i8 %76 to i32
%78 = load i8, i8* %28
%79 = zext i8 %78 to i32
%80 = load i8, i8* %29
%81 = zext i8 %80 to i32
%82 = load i8, i8* %30
%83 = zext i8 %82 to i32
%84 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 %69, i32 %71, i32 %73, i32 %75, i32 %77, i32 %79, i32 %81, i32 %83)
%85 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%86 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.14, i64 0, i64 0))
br label %41
}