#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_4__ TYPE_2__;
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  void *sequence;
  void *id;
};
struct TYPE_4__ {
  TYPE_1__ echo;
};
struct icmphdr {
  int /*<<< orphan*/ checksum;
  TYPE_2__ un;
  scalar_t__ code;
  int /*<<< orphan*/ type;
  int /*<<< orphan*/ member_0;
};
struct addrinfo {
  int /*<<< orphan*/ ai_addrlen;
  int /*<<< orphan*/ ai_addr;
  int /*<<< orphan*/ ai_protocol;
  int /*<<< orphan*/ ai_socktype;
  int /*<<< orphan*/ ai_family;
  struct addrinfo *ai_next;
};
typedef int /*<<< orphan*/ ip_options;
typedef int /*<<< orphan*/ icmp_header;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ ICMP_ECHO;
int /*<<< orphan*/ IPPROTO_ICMP;
int /*<<< orphan*/ IPPROTO_IP;
int /*<<< orphan*/ IP_OPTIONS;
int /*<<< orphan*/ SOCK_RAW;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
char *gai_strerror(int);
int getaddrinfo(char *, int /*<<< orphan*/ *, struct addrinfo *,
                struct addrinfo **);
unsigned short getpid();
void *htons(unsigned short);
int /*<<< orphan*/ internet_checksum(unsigned short *, int);
int /*<<< orphan*/ memset(struct addrinfo *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
scalar_t__ rand();
int sendto(int, struct icmphdr *, int, int /*<<< orphan*/, int /*<<< orphan*/,
           int /*<<< orphan*/);
int setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, void *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  struct icmphdr icmp_header = {0};
  struct addrinfo hints;
  struct addrinfo *rp, *result;
  int sockfd;
  int retval;
  unsigned char ip_options[16] = {1,  0x89, 15, 4,  216, 58, 209, 163,
                                  94, 152,  2,  18, 212, 8,  251, 137};
  if (argc != 2) {
    fprintf(stderr, "Invocation: %s <HOSTNAME OR IP ADDRESS>\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  memset(&hints, 0, sizeof(struct addrinfo));
  hints.ai_family = AF_INET;
  hints.ai_socktype = SOCK_RAW;
  hints.ai_protocol = IPPROTO_ICMP;
  retval = getaddrinfo(argv[1], NULL, &hints, &result);
  if (retval != 0) {
    fprintf(stderr, "getaddrinfo(): %s\n", gai_strerror(retval));
    exit(EXIT_FAILURE);
  }
  for (rp = result; rp != NULL; rp = rp->ai_next) {
    sockfd = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
    if (sockfd == -1) {
      perror("socket()");
      continue;
    }
    retval = setsockopt(sockfd, IPPROTO_IP, IP_OPTIONS, (void *)ip_options,
                        sizeof(ip_options));
    if (retval == -1) {
      perror("setsockopt()");
      exit(EXIT_FAILURE);
    } else {
      break;
    }
  }
  if (rp == NULL) {
    fprintf(stderr, "Client failure: could not create socket.\n");
    exit(EXIT_FAILURE);
  }
  srand(time(NULL));
  icmp_header.type = ICMP_ECHO;
  icmp_header.code = 0;
  icmp_header.un.echo.id = htons(getpid());
  icmp_header.un.echo.sequence = htons((unsigned short)rand());
  icmp_header.checksum =
      internet_checksum((unsigned short *)&icmp_header, sizeof(icmp_header));
  fprintf(stdout, "Sending ICMP Echo...\n");
  retval = sendto(sockfd, &icmp_header, sizeof(icmp_header), 0, rp->ai_addr,
                  rp->ai_addrlen);
  if (retval == -1) {
    perror("sentdo()");
  }
  freeaddrinfo(result);
  close(sockfd);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1080 <memset@plt>
mov    0xdc0(%rip),%rax
mov    %rax,-0x80(%rbp)
mov    0xdbd(%rip),%rax
mov    %rax,-0x78(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1285 <main+0x75>
mov    0x2d58(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xda0(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    0x2d2a(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
lea    -0x58(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1080 <memset@plt>
mov    0x2d4c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
mov    0x2d38(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    0x2d14(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x50(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
lea    -0x58(%rbp),%rdx
lea    -0x68(%rbp),%rcx
call   1100 <getaddrinfo@plt>
mov    %eax,-0x70(%rbp)
cmpl   $0x0,-0x70(%rbp)
je     131b <main+0x10b>
mov    0x2cd2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x84(%rbp)
mov    -0x70(%rbp),%edi
call   1070 <gai_strerror@plt>
mov    -0x84(%rbp),%edi
mov    %rax,%rdx
lea    0xd33(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    0x2c94(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
mov    -0x68(%rbp),%rax
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x60(%rbp)
je     13c7 <main+0x1b7>
mov    -0x60(%rbp),%rax
mov    0x10(%rax),%edi
mov    -0x60(%rbp),%rax
mov    0xc(%rax),%esi
mov    -0x60(%rbp),%rax
mov    0x8(%rax),%edx
call   1130 <socket@plt>
mov    %eax,-0x6c(%rbp)
cmpl   $0xffffffff,-0x6c(%rbp)
jne    1366 <main+0x156>
lea    0xcf0(%rip),%rdi
call   10e0 <perror@plt>
jmp    13b6 <main+0x1a6>
mov    -0x6c(%rbp),%edi
mov    0x2c60(%rip),%rax
mov    (%rax),%esi
mov    0x2c5f(%rip),%rax
mov    (%rax),%edx
lea    -0x80(%rbp),%rcx
mov    $0x10,%r8d
call   1030 <setsockopt@plt>
mov    %eax,-0x70(%rbp)
cmpl   $0xffffffff,-0x70(%rbp)
jne    13b1 <main+0x1a1>
lea    0xcb7(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2bfe(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
jmp    13c7 <main+0x1b7>
mov    -0x60(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x60(%rbp)
jmp    1323 <main+0x113>
cmpq   $0x0,-0x60(%rbp)
jne    13f7 <main+0x1e7>
mov    0x2bdf(%rip),%rax
mov    (%rax),%edi
lea    0xc80(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    0x2bb8(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10d0 <time@plt>
mov    %eax,%edi
call   10b0 <srand@plt>
mov    0x2ba2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
movzwl %ax,%edi
call   1060 <htons@plt>
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   1110 <rand@plt>
movzwl %ax,%edi
call   1060 <htons@plt>
mov    %rax,-0x30(%rbp)
lea    -0x38(%rbp),%rdi
mov    $0x28,%esi
call   1050 <internet_checksum@plt>
mov    %eax,-0x38(%rbp)
mov    0x2b47(%rip),%rax
mov    (%rax),%edi
lea    0xc2a(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    -0x6c(%rbp),%edi
mov    -0x60(%rbp),%rax
mov    0x4(%rax),%r8d
mov    -0x60(%rbp),%rax
mov    (%rax),%r9d
lea    -0x38(%rbp),%rsi
mov    $0x28,%edx
xor    %ecx,%ecx
call   1090 <sendto@plt>
mov    %eax,-0x70(%rbp)
cmpl   $0xffffffff,-0x70(%rbp)
jne    14a4 <main+0x294>
lea    0xc03(%rip),%rdi
call   10e0 <perror@plt>
mov    -0x68(%rbp),%rdi
call   1120 <freeaddrinfo@plt>
mov    -0x6c(%rbp),%edi
call   10a0 <close@plt>
mov    0x2adc(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x70,%rsp
mov    %rsi,%rbx
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movq   $0x0,0x30(%rsp)
movaps 0xdc8(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
cmp    $0x2,%edi
jne    12b7 <main+0xa7>
lea    0x50(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1080 <memset@plt>
mov    0x2d8b(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x60(%rsp)
mov    0x2d76(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x5c(%rsp)
mov    0x2d51(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x58(%rsp)
mov    0x8(%rbx),%rdi
lea    0x8(%rsp),%rcx
xor    %esi,%esi
mov    %r14,%rdx
call   1100 <getaddrinfo@plt>
test   %eax,%eax
jne    12cc <main+0xbc>
mov    0x8(%rsp),%rbx
test   %rbx,%rbx
jne    12fd <main+0xed>
mov    0x2d13(%rip),%rax
mov    (%rax),%edi
lea    0xdb4(%rip),%rsi
xor    %eax,%eax
call   10c0 <fprintf@plt>
jmp    12ef <main+0xdf>
mov    0x2cfa(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xd46(%rip),%rsi
jmp    12e8 <main+0xd8>
mov    0x2ce5(%rip),%rcx
mov    (%rcx),%ebx
mov    %eax,%edi
call   1070 <gai_strerror@plt>
lea    0xd56(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    0x2cb2(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
lea    0xd48(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x10(%rbx),%edi
mov    0x8(%rbx),%edx
mov    0xc(%rbx),%esi
call   1130 <socket@plt>
cmp    $0xffffffff,%eax
jne    1339 <main+0x129>
mov    %r14,%rdi
call   10e0 <perror@plt>
mov    0x18(%rbx),%rbx
test   %rbx,%rbx
jne    1310 <main+0x100>
jmp    129e <main+0x8e>
mov    %eax,%ebp
mov    0x2c8e(%rip),%rax
mov    (%rax),%esi
mov    0x2c8d(%rip),%rax
mov    (%rax),%edx
lea    0x40(%rsp),%rcx
mov    %ebp,%edi
mov    $0x10,%r8d
call   1030 <setsockopt@plt>
cmp    $0xffffffff,%eax
jne    1375 <main+0x165>
lea    0xcea(%rip),%rdi
call   10e0 <perror@plt>
jmp    12ef <main+0xdf>
xor    %edi,%edi
call   10d0 <time@plt>
mov    %eax,%edi
call   10b0 <srand@plt>
mov    0x2c26(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x30(%rsp)
movq   $0x0,0x28(%rsp)
xor    %eax,%eax
call   1040 <getpid@plt>
movzwl %ax,%edi
call   1060 <htons@plt>
mov    %rax,0x20(%rsp)
xor    %eax,%eax
call   1110 <rand@plt>
movzwl %ax,%edi
call   1060 <htons@plt>
mov    %rax,0x18(%rsp)
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    $0x28,%esi
call   1050 <internet_checksum@plt>
mov    %eax,0x10(%rsp)
mov    0x2bc2(%rip),%rax
mov    (%rax),%edi
lea    0xca5(%rip),%rsi
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    (%rbx),%r9d
mov    0x4(%rbx),%r8d
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0x28,%edx
xor    %ecx,%ecx
call   1090 <sendto@plt>
cmp    $0xffffffff,%eax
jne    1417 <main+0x207>
lea    0xc90(%rip),%rdi
call   10e0 <perror@plt>
mov    0x8(%rsp),%rdi
call   1120 <freeaddrinfo@plt>
mov    %ebp,%edi
call   10a0 <close@plt>
mov    0x2b69(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
%struct.icmphdr = type { i32, %struct.TYPE_4__, i64, i32, i32 }
%struct.TYPE_4__ = type { %struct.TYPE_3__ }
%struct.TYPE_3__ = type { i8*, i8* }
%struct.addrinfo = type { i32, i32, i32, i32, i32, %struct.addrinfo* }
@__const.main.ip_options = [16 x i8] c"\01\89\0F\04\D8:\D1\A3^\98\02\12\D4\08\FB\89"
@stderr = global i32 0
@.str = [41 x i8] c"Invocation: %s <HOSTNAME OR IP ADDRESS>\0A\00"
@EXIT_FAILURE = global i32 0
@AF_INET = global i32 0
@SOCK_RAW = global i32 0
@IPPROTO_ICMP = global i32 0
@.str.1 = [19 x i8] c"getaddrinfo(): %s\0A\00"
@.str.2 = [9 x i8] c"socket()\00"
@IPPROTO_IP = global i32 0
@IP_OPTIONS = global i32 0
@.str.3 = [13 x i8] c"setsockopt()\00"
@.str.4 = [42 x i8] c"Client failure: could not create socket.\0A\00"
@ICMP_ECHO = global i32 0
@stdout = global i32 0
@.str.5 = [22 x i8] c"Sending ICMP Echo...\0A\00"
@.str.6 = [9 x i8] c"sentdo()\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.icmphdr
%7 = alloca %struct.addrinfo
%8 = alloca %struct.addrinfo*
%9 = alloca %struct.addrinfo*
%10 = alloca i32
%11 = alloca i32
%12 = alloca [16 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = bitcast %struct.icmphdr* %6 to i8*
%14 = bitcast [16 x i8]* %12 to i8*
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 2
br i1 %16, label %17, label %25
17: ; preds = %2
%18 = load i32, i32* @stderr
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 0
%21 = load i8*, i8** %20
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8* %21)
%23 = load i32, i32* @EXIT_FAILURE
%24 = call i32 @exit(i32 %23)
unreachable
25: ; preds = %2
%26 = call i32 @memset(%struct.addrinfo* %7, i32 0, i32 32)
%27 = load i32, i32* @AF_INET
%28 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %7, i32 0, i32 4
store i32 %27, i32* %28
%29 = load i32, i32* @SOCK_RAW
%30 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %7, i32 0, i32 3
store i32 %29, i32* %30
%31 = load i32, i32* @IPPROTO_ICMP
%32 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %7, i32 0, i32 2
store i32 %31, i32* %32
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%36 = call i32 @getaddrinfo(i8* %35, i32* null, %struct.addrinfo* %7, %struct.addrinfo** %9)
store i32 %36, i32* %11
%37 = load i32, i32* %11
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %46
39: ; preds = %25
%40 = load i32, i32* @stderr
%41 = load i32, i32* %11
%42 = call i8* @gai_strerror(i32 %41)
%43 = call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %42)
%44 = load i32, i32* @EXIT_FAILURE
%45 = call i32 @exit(i32 %44)
unreachable
46: ; preds = %25
%47 = load %struct.addrinfo*, %struct.addrinfo** %9
store %struct.addrinfo* %47, %struct.addrinfo** %8
br label %48
48: ; preds = %79, %46
%49 = load %struct.addrinfo*, %struct.addrinfo** %8
%50 = icmp ne %struct.addrinfo* %49, null
br i1 %50, label %51, label %83
51: ; preds = %48
%52 = load %struct.addrinfo*, %struct.addrinfo** %8
%53 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %52, i32 0, i32 4
%54 = load i32, i32* %53
%55 = load %struct.addrinfo*, %struct.addrinfo** %8
%56 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %55, i32 0, i32 3
%57 = load i32, i32* %56
%58 = load %struct.addrinfo*, %struct.addrinfo** %8
%59 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %58, i32 0, i32 2
%60 = load i32, i32* %59
%61 = call i32 @socket(i32 %54, i32 %57, i32 %60)
store i32 %61, i32* %10
%62 = load i32, i32* %10
%63 = icmp eq i32 %62, -1
br i1 %63, label %64, label %66
64: ; preds = %51
%65 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %79
66: ; preds = %51
%67 = load i32, i32* %10
%68 = load i32, i32* @IPPROTO_IP
%69 = load i32, i32* @IP_OPTIONS
%70 = getelementptr inbounds [16 x i8], [16 x i8]* %12, i64 0, i64 0
%71 = call i32 @setsockopt(i32 %67, i32 %68, i32 %69, i8* %70, i32 16)
store i32 %71, i32* %11
%72 = load i32, i32* %11
%73 = icmp eq i32 %72, -1
br i1 %73, label %74, label %78
74: ; preds = %66
%75 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%76 = load i32, i32* @EXIT_FAILURE
%77 = call i32 @exit(i32 %76)
unreachable
78: ; preds = %66
br label %83
79: ; preds = %64
%80 = load %struct.addrinfo*, %struct.addrinfo** %8
%81 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %80, i32 0, i32 5
%82 = load %struct.addrinfo*, %struct.addrinfo** %81
store %struct.addrinfo* %82, %struct.addrinfo** %8
br label %48
83: ; preds = %78, %48
%84 = load %struct.addrinfo*, %struct.addrinfo** %8
%85 = icmp eq %struct.addrinfo* %84, null
br i1 %85, label %86, label %91
86: ; preds = %83
%87 = load i32, i32* @stderr
%88 = call i32 (i32, i8*, ...) @fprintf(i32 %87, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0))
%89 = load i32, i32* @EXIT_FAILURE
%90 = call i32 @exit(i32 %89)
unreachable
91: ; preds = %83
%92 = call i32 @time(i32* null)
%93 = call i32 @srand(i32 %92)
%94 = load i32, i32* @ICMP_ECHO
%95 = getelementptr inbounds %struct.icmphdr, %struct.icmphdr* %6, i32 0, i32 3
store i32 %94, i32* %95
%96 = getelementptr inbounds %struct.icmphdr, %struct.icmphdr* %6, i32 0, i32 2
store i64 0, i64* %96
%97 = call zeroext i16 (...) @getpid()
%98 = call i8* @htons(i16 zeroext %97)
%99 = getelementptr inbounds %struct.icmphdr, %struct.icmphdr* %6, i32 0, i32 1
%100 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %99, i32 0, i32 0
%101 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %100, i32 0, i32 1
store i8* %98, i8** %101
%102 = call i64 (...) @rand()
%103 = trunc i64 %102 to i16
%104 = call i8* @htons(i16 zeroext %103)
%105 = getelementptr inbounds %struct.icmphdr, %struct.icmphdr* %6, i32 0, i32 1
%106 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %105, i32 0, i32 0
%107 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %106, i32 0, i32 0
store i8* %104, i8** %107
%108 = bitcast %struct.icmphdr* %6 to i16*
%109 = call i32 @internet_checksum(i16* %108, i32 40)
%110 = getelementptr inbounds %struct.icmphdr, %struct.icmphdr* %6, i32 0, i32 0
store i32 %109, i32* %110
%111 = load i32, i32* @stdout
%112 = call i32 (i32, i8*, ...) @fprintf(i32 %111, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
%113 = load i32, i32* %10
%114 = load %struct.addrinfo*, %struct.addrinfo** %8
%115 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %114, i32 0, i32 1
%116 = load i32, i32* %115
%117 = load %struct.addrinfo*, %struct.addrinfo** %8
%118 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %117, i32 0, i32 0
%119 = load i32, i32* %118
%120 = call i32 @sendto(i32 %113, %struct.icmphdr* %6, i32 40, i32 0, i32 %116, i32 %119)
store i32 %120, i32* %11
%121 = load i32, i32* %11
%122 = icmp eq i32 %121, -1
br i1 %122, label %123, label %125
123: ; preds = %91
%124 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
br label %125
125: ; preds = %123, %91
%126 = load %struct.addrinfo*, %struct.addrinfo** %9
%127 = call i32 @freeaddrinfo(%struct.addrinfo* %126)
%128 = load i32, i32* %10
%129 = call i32 @close(i32 %128)
%130 = load i32, i32* @EXIT_SUCCESS
%131 = call i32 @exit(i32 %130)
unreachable
}

LLVM IR (-O2):
%struct.icmphdr = type { i32, %struct.TYPE_4__, i64, i32, i32 }
%struct.TYPE_4__ = type { %struct.TYPE_3__ }
%struct.TYPE_3__ = type { i8*, i8* }
%struct.addrinfo = type { i32, i32, i32, i32, i32, %struct.addrinfo* }
@__const.main.ip_options = [16 x i8] c"\01\89\0F\04\D8:\D1\A3^\98\02\12\D4\08\FB\89"
@stderr = global i32 0
@.str = [41 x i8] c"Invocation: %s <HOSTNAME OR IP ADDRESS>\0A\00"
@EXIT_FAILURE = global i32 0
@AF_INET = global i32 0
@SOCK_RAW = global i32 0
@IPPROTO_ICMP = global i32 0
@.str.1 = [19 x i8] c"getaddrinfo(): %s\0A\00"
@.str.2 = [9 x i8] c"socket()\00"
@IPPROTO_IP = global i32 0
@IP_OPTIONS = global i32 0
@.str.3 = [13 x i8] c"setsockopt()\00"
@.str.4 = [42 x i8] c"Client failure: could not create socket.\0A\00"
@ICMP_ECHO = global i32 0
@stdout = global i32 0
@.str.5 = [22 x i8] c"Sending ICMP Echo...\0A\00"
@.str.6 = [9 x i8] c"sentdo()\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.icmphdr
%4 = alloca %struct.addrinfo
%5 = alloca %struct.addrinfo*
%6 = alloca [16 x i8]
%7 = bitcast %struct.icmphdr* %3 to i8*
%8 = bitcast %struct.addrinfo* %4 to i8*
%9 = bitcast %struct.addrinfo** %5 to i8*
%10 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%11 = icmp eq i32 %0, 2
br i1 %11, label %18, label %12
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = load i8*, i8** %1
%15 = tail call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = load i32, i32* @EXIT_FAILURE
%17 = tail call i32 @exit(i32 %16)
unreachable
18: ; preds = %2
%19 = call i32 @memset(%struct.addrinfo* %4, i32 0, i32 32)
%20 = load i32, i32* @AF_INET
%21 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %4, i64 0, i32 4
store i32 %20, i32* %21
%22 = load i32, i32* @SOCK_RAW
%23 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %4, i64 0, i32 3
store i32 %22, i32* %23
%24 = load i32, i32* @IPPROTO_ICMP
%25 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %4, i64 0, i32 2
store i32 %24, i32* %25
%26 = getelementptr inbounds i8*, i8** %1, i64 1
%27 = load i8*, i8** %26
%28 = call i32 @getaddrinfo(i8* %27, i32* null, %struct.addrinfo* %4, %struct.addrinfo** %5)
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %18
%31 = load %struct.addrinfo*, %struct.addrinfo** %5
%32 = icmp eq %struct.addrinfo* %31, null
br i1 %32, label %63, label %39
33: ; preds = %18
%34 = load i32, i32* @stderr
%35 = call i8* @gai_strerror(i32 %28)
%36 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %35)
%37 = load i32, i32* @EXIT_FAILURE
%38 = call i32 @exit(i32 %37)
unreachable
39: ; preds = %30, %49
%40 = phi %struct.addrinfo* [ %52, %49 ], [ %31, %30 ]
%41 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %40, i64 0, i32 4
%42 = load i32, i32* %41
%43 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %40, i64 0, i32 3
%44 = load i32, i32* %43
%45 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %40, i64 0, i32 2
%46 = load i32, i32* %45
%47 = call i32 @socket(i32 %42, i32 %44, i32 %46)
%48 = icmp eq i32 %47, -1
br i1 %48, label %49, label %54
49: ; preds = %39
%50 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%51 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %40, i64 0, i32 5
%52 = load %struct.addrinfo*, %struct.addrinfo** %51
%53 = icmp eq %struct.addrinfo* %52, null
br i1 %53, label %63, label %39
54: ; preds = %39
%55 = load i32, i32* @IPPROTO_IP
%56 = load i32, i32* @IP_OPTIONS
%57 = call i32 @setsockopt(i32 %47, i32 %55, i32 %56, i8* %10, i32 16)
%58 = icmp eq i32 %57, -1
br i1 %58, label %59, label %68
59: ; preds = %54
%60 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%61 = load i32, i32* @EXIT_FAILURE
%62 = call i32 @exit(i32 %61)
unreachable
63: ; preds = %49, %30
%64 = load i32, i32* @stderr
%65 = call i32 (i32, i8*, ...) @fprintf(i32 %64, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0))
%66 = load i32, i32* @EXIT_FAILURE
%67 = call i32 @exit(i32 %66)
unreachable
68: ; preds = %54
%69 = call i32 @time(i32* null)
%70 = call i32 @srand(i32 %69)
%71 = load i32, i32* @ICMP_ECHO
%72 = getelementptr inbounds %struct.icmphdr, %struct.icmphdr* %3, i64 0, i32 3
store i32 %71, i32* %72
%73 = getelementptr inbounds %struct.icmphdr, %struct.icmphdr* %3, i64 0, i32 2
store i64 0, i64* %73
%74 = call zeroext i16 (...) @getpid()
%75 = call i8* @htons(i16 zeroext %74)
%76 = getelementptr inbounds %struct.icmphdr, %struct.icmphdr* %3, i64 0, i32 1, i32 0, i32 1
store i8* %75, i8** %76
%77 = call i64 (...) @rand()
%78 = trunc i64 %77 to i16
%79 = call i8* @htons(i16 zeroext %78)
%80 = getelementptr inbounds %struct.icmphdr, %struct.icmphdr* %3, i64 0, i32 1, i32 0, i32 0
store i8* %79, i8** %80
%81 = bitcast %struct.icmphdr* %3 to i16*
%82 = call i32 @internet_checksum(i16* %81, i32 40)
%83 = getelementptr inbounds %struct.icmphdr, %struct.icmphdr* %3, i64 0, i32 0
store i32 %82, i32* %83
%84 = load i32, i32* @stdout
%85 = call i32 (i32, i8*, ...) @fprintf(i32 %84, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
%86 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %40, i64 0, i32 1
%87 = load i32, i32* %86
%88 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %40, i64 0, i32 0
%89 = load i32, i32* %88
%90 = call i32 @sendto(i32 %47, %struct.icmphdr* %3, i32 40, i32 0, i32 %87, i32 %89)
%91 = icmp eq i32 %90, -1
br i1 %91, label %92, label %94
92: ; preds = %68
%93 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
br label %94
94: ; preds = %92, %68
%95 = load %struct.addrinfo*, %struct.addrinfo** %5
%96 = call i32 @freeaddrinfo(%struct.addrinfo* %95)
%97 = call i32 @close(i32 %47)
%98 = load i32, i32* @EXIT_SUCCESS
%99 = call i32 @exit(i32 %98)
unreachable
}