#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
typedef void *u_int32_t;
typedef int u_int16_t;
struct udphdr {
  void *len;
  void *dest;
  void *source;
};
struct TYPE_2__ {
  void *s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
  void *sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
struct iphdr {
  int ihl;
  int version;
  int tos;
  int tot_len;
  int ttl;
  int protocol;
  int /*<<< orphan*/ check;
  void *daddr;
  void *saddr;
  void *id;
};
typedef int /*<<< orphan*/ sin;
typedef int /*<<< orphan*/ one;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ AF_XDP;
int /*<<< orphan*/ IPPROTO_IP;
int /*<<< orphan*/ IPPROTO_UDP;
int /*<<< orphan*/ IP_HDRINCL;
int /*<<< orphan*/ SOCK_RAW;
int atoi(char const *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ csum(unsigned short *, int);
int /*<<< orphan*/ exit(int);
void *htons(int);
void *inet_addr(char const *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ sendto(int, char *, int, int /*<<< orphan*/, struct sockaddr *, int);
scalar_t__ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, int const *,
                      int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int main(int argc, char const *argv[]) {
  if (argc != 5) {
    printf("Error: Invalid parameters!\n");
    printf("Usage: %s <source hostname/IP> <source port> <target hostname/IP> "
           "<target port>\n",
           argv[0]);
    exit(1);
  }
  u_int16_t src_port, dst_port;
  u_int32_t src_addr, dst_addr;
  src_addr = inet_addr(argv[1]);
  dst_addr = inet_addr(argv[3]);
  src_port = atoi(argv[2]);
  dst_port = atoi(argv[4]);
  int sd;
  char buffer[8192];
  struct iphdr *ip = (struct iphdr *)buffer;
  struct udphdr *udp = (struct udphdr *)(buffer + sizeof(struct iphdr));
  struct sockaddr_in sin;
  int one = 1;
  const int *val = &one;
  memset(buffer, 0, 8192);
  sd = socket(AF_XDP, SOCK_RAW, IPPROTO_UDP);
  if (sd < 0) {
    perror("socket() error");
    exit(2);
  }
  printf("OK: a raw socket is created.\n");
  if (setsockopt(sd, IPPROTO_IP, IP_HDRINCL, val, sizeof(one)) < 0) {
    perror("setsockopt() error");
    exit(2);
  }
  printf("OK: socket option IP_HDRINCL is set.\n");
  sin.sin_family = AF_INET;
  sin.sin_port = htons(dst_port);
  sin.sin_addr.s_addr = dst_addr;
  ip->ihl = 5;
  ip->version = 4;
  ip->tos = 16;
  ip->tot_len = sizeof(struct iphdr) + sizeof(struct udphdr);
  ip->id = htons(54321);
  ip->ttl = 64;
  ip->protocol = 17;
  ip->saddr = src_addr;
  ip->daddr = dst_addr;
  udp->source = htons(src_port);
  udp->dest = htons(dst_port);
  udp->len = htons(sizeof(struct udphdr));
  ip->check = csum((unsigned short *)buffer,
                   sizeof(struct iphdr) + sizeof(struct udphdr));
  if (sendto(sd, buffer, ip->tot_len, 0, (struct sockaddr *)&sin, sizeof(sin)) <
      0) {
    perror("sendto()");
    exit(3);
  }
  printf("OK: one packet is sent.\n");
  close(sd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2070,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x5,-0x8(%rbp)
je     1210 <main+0x50>
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10a0 <inet_addr@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   10a0 <inet_addr@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x18(%rbp)
lea    -0x2030(%rbp),%rax
mov    %rax,-0x2038(%rbp)
lea    -0x2030(%rbp),%rax
add    $0x38,%rax
mov    %rax,-0x2040(%rbp)
movl   $0x1,-0x205c(%rbp)
lea    -0x205c(%rbp),%rax
mov    %rax,-0x2068(%rbp)
lea    -0x2030(%rbp),%rdi
xor    %esi,%esi
mov    $0x2000,%edx
call   1070 <memset@plt>
mov    0x2d1c(%rip),%rax
mov    (%rax),%edi
mov    0x2d2b(%rip),%rax
mov    (%rax),%esi
mov    0x2cfa(%rip),%rax
mov    (%rax),%edx
call   10e0 <socket@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    12e0 <main+0x120>
lea    0xd9c(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x2,%edi
call   10d0 <exit@plt>
lea    0xd95(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x2c(%rbp),%edi
mov    0x2cd8(%rip),%rax
mov    (%rax),%esi
mov    0x2cef(%rip),%rax
mov    (%rax),%edx
mov    -0x2068(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0x0,%rax
jge    1335 <main+0x175>
lea    0xd74(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x2,%edi
call   10d0 <exit@plt>
lea    0xd71(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2c96(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2048(%rbp)
mov    -0x18(%rbp),%edi
call   1050 <htons@plt>
mov    %rax,-0x2050(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x2058(%rbp)
mov    -0x2038(%rbp),%rax
movl   $0x5,(%rax)
mov    -0x2038(%rbp),%rax
movl   $0x4,0x4(%rax)
mov    -0x2038(%rbp),%rax
movl   $0x10,0x8(%rax)
mov    -0x2038(%rbp),%rax
movl   $0x50,0xc(%rax)
mov    $0xd431,%edi
call   1050 <htons@plt>
mov    %rax,%rcx
mov    -0x2038(%rbp),%rax
mov    %rcx,0x30(%rax)
mov    -0x2038(%rbp),%rax
movl   $0x40,0x10(%rax)
mov    -0x2038(%rbp),%rax
movl   $0x11,0x14(%rax)
mov    -0x20(%rbp),%rcx
mov    -0x2038(%rbp),%rax
mov    %rcx,0x28(%rax)
mov    -0x28(%rbp),%rcx
mov    -0x2038(%rbp),%rax
mov    %rcx,0x20(%rax)
mov    -0x14(%rbp),%edi
call   1050 <htons@plt>
mov    %rax,%rcx
mov    -0x2040(%rbp),%rax
mov    %rcx,0x10(%rax)
mov    -0x18(%rbp),%edi
call   1050 <htons@plt>
mov    %rax,%rcx
mov    -0x2040(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    $0x18,%edi
call   1050 <htons@plt>
mov    %rax,%rcx
mov    -0x2040(%rbp),%rax
mov    %rcx,(%rax)
lea    -0x2030(%rbp),%rdi
mov    $0x50,%esi
call   1040 <csum@plt>
mov    %eax,%ecx
mov    -0x2038(%rbp),%rax
mov    %ecx,0x18(%rax)
mov    -0x2c(%rbp),%edi
lea    -0x2030(%rbp),%rsi
mov    -0x2038(%rbp),%rax
mov    0xc(%rax),%edx
lea    -0x2058(%rbp),%r8
xor    %ecx,%ecx
mov    $0x18,%r9d
call   1080 <sendto@plt>
cmp    $0x0,%rax
jge    149d <main+0x2dd>
lea    0xc45(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x3,%edi
call   10d0 <exit@plt>
lea    0xc38(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x2c(%rbp),%edi
call   1090 <close@plt>
xor    %eax,%eax
add    $0x2070,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x2020,%rsp
mov    %rsi,%rbx
cmp    $0x5,%edi
jne    1377 <main+0x1a7>
mov    0x8(%rbx),%rdi
call   10b0 <inet_addr@plt>
mov    %rax,%r14
mov    0x18(%rbx),%rdi
call   10b0 <inet_addr@plt>
mov    %rax,%r15
mov    0x10(%rbx),%rdi
call   10d0 <atoi@plt>
mov    %eax,%r12d
mov    0x20(%rbx),%rdi
call   10d0 <atoi@plt>
mov    %eax,%ebp
movl   $0x1,0x4(%rsp)
lea    0x20(%rsp),%rdi
xor    %esi,%esi
mov    $0x2000,%edx
call   1080 <memset@plt>
mov    0x2d86(%rip),%rax
mov    (%rax),%edi
mov    0x2d95(%rip),%rax
mov    (%rax),%esi
mov    0x2d64(%rip),%rax
mov    (%rax),%edx
call   10f0 <socket@plt>
test   %eax,%eax
js     139e <main+0x1ce>
mov    %eax,%ebx
lea    0xe28(%rip),%rdi
call   1030 <puts@plt>
mov    0x2d60(%rip),%rax
mov    (%rax),%esi
mov    0x2d77(%rip),%rax
mov    (%rax),%edx
lea    0x4(%rsp),%rcx
mov    %ebx,%edi
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
test   %rax,%rax
js     13a7 <main+0x1d7>
lea    0xe0c(%rip),%rdi
call   1030 <puts@plt>
mov    0x2d37(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x18(%rsp)
mov    %ebp,%edi
call   1060 <htons@plt>
mov    %rax,0x10(%rsp)
mov    %r15,0x8(%rsp)
movaps 0xd39(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
mov    $0xd431,%edi
call   1060 <htons@plt>
mov    %rax,0x50(%rsp)
movabs $0x1100000040,%rax
mov    %rax,0x30(%rsp)
mov    %r14,0x48(%rsp)
mov    %r15,0x40(%rsp)
mov    %r12d,%edi
call   1060 <htons@plt>
mov    %rax,0x68(%rsp)
mov    %ebp,%edi
call   1060 <htons@plt>
mov    %rax,0x60(%rsp)
mov    $0x18,%edi
call   1060 <htons@plt>
mov    %rax,0x58(%rsp)
lea    0x20(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x50,%esi
call   1050 <csum@plt>
mov    %eax,0x38(%rsp)
mov    0x2c(%rsp),%edx
lea    0x8(%rsp),%r8
mov    %ebx,%edi
mov    %rbp,%rsi
xor    %ecx,%ecx
mov    $0x18,%r9d
call   1090 <sendto@plt>
test   %rax,%rax
js     13bd <main+0x1ed>
lea    0xd75(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%edi
call   10a0 <close@plt>
xor    %eax,%eax
add    $0x2020,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd68(%rip),%rdi
call   1030 <puts@plt>
mov    (%rbx),%rsi
lea    0xc83(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
lea    0xcbc(%rip),%rdi
jmp    13ae <main+0x1de>
lea    0xcc2(%rip),%rdi
call   10c0 <perror@plt>
mov    $0x2,%edi
call   10e0 <exit@plt>
lea    0xcbf(%rip),%rdi
call   10c0 <perror@plt>
mov    $0x3,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
%struct.iphdr = type { i32, i32, i32, i32, i32, i32, i32, i8*, i8*, i8* }
%struct.udphdr = type { i8*, i8*, i8* }
%struct.sockaddr_in = type { %struct.TYPE_2__, i8*, i32 }
%struct.TYPE_2__ = type { i8* }
%struct.sockaddr = type { i32 }
@.str = [28 x i8] c"Error: Invalid parameters!\0A\00"
@.str.1 = [81 x i8] c"Usage: %s <source hostname/IP> <source port> <target hostname/IP> <target port>\0A\00"
@AF_XDP = global i32 0
@SOCK_RAW = global i32 0
@IPPROTO_UDP = global i32 0
@.str.2 = [15 x i8] c"socket() error\00"
@.str.3 = [30 x i8] c"OK: a raw socket is created.\0A\00"
@IPPROTO_IP = global i32 0
@IP_HDRINCL = global i32 0
@.str.4 = [19 x i8] c"setsockopt() error\00"
@.str.5 = [38 x i8] c"OK: socket option IP_HDRINCL is set.\0A\00"
@AF_INET = global i32 0
@.str.6 = [9 x i8] c"sendto()\00"
@.str.7 = [25 x i8] c"OK: one packet is sent.\0A\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 i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca [8192 x i8]
%12 = alloca %struct.iphdr*
%13 = alloca %struct.udphdr*
%14 = alloca %struct.sockaddr_in
%15 = alloca i32
%16 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%17 = load i32, i32* %4
%18 = icmp ne i32 %17, 5
br i1 %18, label %19, label %26
19: ; preds = %2
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 0
%23 = load i8*, i8** %22
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.1, i64 0, i64 0), i8* %23)
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %2
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i8* @inet_addr(i8* %29)
store i8* %30, i8** %8
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 3
%33 = load i8*, i8** %32
%34 = call i8* @inet_addr(i8* %33)
store i8* %34, i8** %9
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 2
%37 = load i8*, i8** %36
%38 = call i32 @atoi(i8* %37)
store i32 %38, i32* %6
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 4
%41 = load i8*, i8** %40
%42 = call i32 @atoi(i8* %41)
store i32 %42, i32* %7
%43 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%44 = bitcast i8* %43 to %struct.iphdr*
store %struct.iphdr* %44, %struct.iphdr** %12
%45 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%46 = getelementptr inbounds i8, i8* %45, i64 56
%47 = bitcast i8* %46 to %struct.udphdr*
store %struct.udphdr* %47, %struct.udphdr** %13
store i32 1, i32* %15
store i32* %15, i32** %16
%48 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%49 = call i32 @memset(i8* %48, i32 0, i32 8192)
%50 = load i32, i32* @AF_XDP
%51 = load i32, i32* @SOCK_RAW
%52 = load i32, i32* @IPPROTO_UDP
%53 = call i32 @socket(i32 %50, i32 %51, i32 %52)
store i32 %53, i32* %10
%54 = load i32, i32* %10
%55 = icmp slt i32 %54, 0
br i1 %55, label %56, label %59
56: ; preds = %26
%57 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%58 = call i32 @exit(i32 2)
unreachable
59: ; preds = %26
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
%61 = load i32, i32* %10
%62 = load i32, i32* @IPPROTO_IP
%63 = load i32, i32* @IP_HDRINCL
%64 = load i32*, i32** %16
%65 = call i64 @setsockopt(i32 %61, i32 %62, i32 %63, i32* %64, i32 4)
%66 = icmp slt i64 %65, 0
br i1 %66, label %67, label %70
67: ; preds = %59
%68 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
%69 = call i32 @exit(i32 2)
unreachable
70: ; preds = %59
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0))
%72 = load i32, i32* @AF_INET
%73 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %14, i32 0, i32 2
store i32 %72, i32* %73
%74 = load i32, i32* %7
%75 = call i8* @htons(i32 %74)
%76 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %14, i32 0, i32 1
store i8* %75, i8** %76
%77 = load i8*, i8** %9
%78 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %14, i32 0, i32 0
%79 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %78, i32 0, i32 0
store i8* %77, i8** %79
%80 = load %struct.iphdr*, %struct.iphdr** %12
%81 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %80, i32 0, i32 0
store i32 5, i32* %81
%82 = load %struct.iphdr*, %struct.iphdr** %12
%83 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %82, i32 0, i32 1
store i32 4, i32* %83
%84 = load %struct.iphdr*, %struct.iphdr** %12
%85 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %84, i32 0, i32 2
store i32 16, i32* %85
%86 = load %struct.iphdr*, %struct.iphdr** %12
%87 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %86, i32 0, i32 3
store i32 80, i32* %87
%88 = call i8* @htons(i32 54321)
%89 = load %struct.iphdr*, %struct.iphdr** %12
%90 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %89, i32 0, i32 9
store i8* %88, i8** %90
%91 = load %struct.iphdr*, %struct.iphdr** %12
%92 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %91, i32 0, i32 4
store i32 64, i32* %92
%93 = load %struct.iphdr*, %struct.iphdr** %12
%94 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %93, i32 0, i32 5
store i32 17, i32* %94
%95 = load i8*, i8** %8
%96 = load %struct.iphdr*, %struct.iphdr** %12
%97 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %96, i32 0, i32 8
store i8* %95, i8** %97
%98 = load i8*, i8** %9
%99 = load %struct.iphdr*, %struct.iphdr** %12
%100 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %99, i32 0, i32 7
store i8* %98, i8** %100
%101 = load i32, i32* %6
%102 = call i8* @htons(i32 %101)
%103 = load %struct.udphdr*, %struct.udphdr** %13
%104 = getelementptr inbounds %struct.udphdr, %struct.udphdr* %103, i32 0, i32 2
store i8* %102, i8** %104
%105 = load i32, i32* %7
%106 = call i8* @htons(i32 %105)
%107 = load %struct.udphdr*, %struct.udphdr** %13
%108 = getelementptr inbounds %struct.udphdr, %struct.udphdr* %107, i32 0, i32 1
store i8* %106, i8** %108
%109 = call i8* @htons(i32 24)
%110 = load %struct.udphdr*, %struct.udphdr** %13
%111 = getelementptr inbounds %struct.udphdr, %struct.udphdr* %110, i32 0, i32 0
store i8* %109, i8** %111
%112 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%113 = bitcast i8* %112 to i16*
%114 = call i32 @csum(i16* %113, i32 80)
%115 = load %struct.iphdr*, %struct.iphdr** %12
%116 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %115, i32 0, i32 6
store i32 %114, i32* %116
%117 = load i32, i32* %10
%118 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%119 = load %struct.iphdr*, %struct.iphdr** %12
%120 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %119, i32 0, i32 3
%121 = load i32, i32* %120
%122 = bitcast %struct.sockaddr_in* %14 to %struct.sockaddr*
%123 = call i64 @sendto(i32 %117, i8* %118, i32 %121, i32 0, %struct.sockaddr* %122, i32 24)
%124 = icmp slt i64 %123, 0
br i1 %124, label %125, label %128
125: ; preds = %70
%126 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%127 = call i32 @exit(i32 3)
unreachable
128: ; preds = %70
%129 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0))
%130 = load i32, i32* %10
%131 = call i32 @close(i32 %130)
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i8*, i32 }
%struct.TYPE_2__ = type { i8* }
%struct.sockaddr = type { i32 }
@.str.1 = [81 x i8] c"Usage: %s <source hostname/IP> <source port> <target hostname/IP> <target port>\0A\00"
@AF_XDP = global i32 0
@SOCK_RAW = global i32 0
@IPPROTO_UDP = global i32 0
@.str.2 = [15 x i8] c"socket() error\00"
@IPPROTO_IP = global i32 0
@IP_HDRINCL = global i32 0
@.str.4 = [19 x i8] c"setsockopt() error\00"
@AF_INET = global i32 0
@.str.6 = [9 x i8] c"sendto()\00"
@str = [29 x i8] c"OK: a raw socket is created.\00"
@str.8 = [37 x i8] c"OK: socket option IP_HDRINCL is set.\00"
@str.9 = [24 x i8] c"OK: one packet is sent.\00"
@str.10 = [27 x i8] c"Error: Invalid parameters!\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [8192 x i8]
%4 = alloca %struct.sockaddr_in
%5 = alloca i32
%6 = icmp eq i32 %0, 5
br i1 %6, label %12, label %7
7: ; preds = %2
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.10, i64 0, i64 0))
%9 = load i8*, i8** %1
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([81 x i8], [81 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = tail call i8* @inet_addr(i8* %14)
%16 = getelementptr inbounds i8*, i8** %1, i64 3
%17 = load i8*, i8** %16
%18 = tail call i8* @inet_addr(i8* %17)
%19 = getelementptr inbounds i8*, i8** %1, i64 2
%20 = load i8*, i8** %19
%21 = tail call i32 @atoi(i8* %20)
%22 = getelementptr inbounds i8*, i8** %1, i64 4
%23 = load i8*, i8** %22
%24 = tail call i32 @atoi(i8* %23)
%25 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 0
%26 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 56
%27 = bitcast %struct.sockaddr_in* %4 to i8*
%28 = bitcast i32* %5 to i8*
store i32 1, i32* %5
%29 = call i32 @memset(i8* %25, i32 0, i32 8192)
%30 = load i32, i32* @AF_XDP
%31 = load i32, i32* @SOCK_RAW
%32 = load i32, i32* @IPPROTO_UDP
%33 = call i32 @socket(i32 %30, i32 %31, i32 %32)
%34 = icmp slt i32 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %12
%36 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%37 = call i32 @exit(i32 2)
unreachable
38: ; preds = %12
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%40 = load i32, i32* @IPPROTO_IP
%41 = load i32, i32* @IP_HDRINCL
%42 = call i64 @setsockopt(i32 %33, i32 %40, i32 %41, i32* %5, i32 4)
%43 = icmp slt i64 %42, 0
br i1 %43, label %44, label %47
44: ; preds = %38
%45 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
%46 = call i32 @exit(i32 2)
unreachable
47: ; preds = %38
%48 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.8, i64 0, i64 0))
%49 = load i32, i32* @AF_INET
%50 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 2
store i32 %49, i32* %50
%51 = call i8* @htons(i32 %24)
%52 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1
store i8* %51, i8** %52
%53 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0, i32 0
store i8* %18, i8** %53
%54 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 12
%55 = bitcast i8* %54 to i32*
%56 = bitcast [8192 x i8]* %3 to <4 x i32>*
store <4 x i32> <i32 5, i32 4, i32 16, i32 80>, <4 x i32>* %56
%57 = call i8* @htons(i32 54321)
%58 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 48
%59 = bitcast i8* %58 to i8**
store i8* %57, i8** %59
%60 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 16
%61 = bitcast i8* %60 to i32*
store i32 64, i32* %61
%62 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 20
%63 = bitcast i8* %62 to i32*
store i32 17, i32* %63
%64 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 40
%65 = bitcast i8* %64 to i8**
store i8* %15, i8** %65
%66 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 32
%67 = bitcast i8* %66 to i8**
store i8* %18, i8** %67
%68 = call i8* @htons(i32 %21)
%69 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 72
%70 = bitcast i8* %69 to i8**
store i8* %68, i8** %70
%71 = call i8* @htons(i32 %24)
%72 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 64
%73 = bitcast i8* %72 to i8**
store i8* %71, i8** %73
%74 = call i8* @htons(i32 24)
%75 = bitcast i8* %26 to i8**
store i8* %74, i8** %75
%76 = bitcast [8192 x i8]* %3 to i16*
%77 = call i32 @csum(i16* %76, i32 80)
%78 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 24
%79 = bitcast i8* %78 to i32*
store i32 %77, i32* %79
%80 = load i32, i32* %55
%81 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%82 = call i64 @sendto(i32 %33, i8* %25, i32 %80, i32 0, %struct.sockaddr* %81, i32 24)
%83 = icmp slt i64 %82, 0
br i1 %83, label %84, label %87
84: ; preds = %47
%85 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%86 = call i32 @exit(i32 3)
unreachable
87: ; preds = %47
%88 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.9, i64 0, i64 0))
%89 = call i32 @close(i32 %33)
ret i32 0
}