#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 */
struct TYPE_2__ {
  unsigned long s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
struct iphdr {
  int ihl;
  int version;
  int ttl;
  unsigned long saddr;
  unsigned long daddr;
  void *check;
  int /*<<< orphan*/ protocol;
  scalar_t__ frag_off;
  scalar_t__ id;
  int /*<<< orphan*/ tot_len;
  scalar_t__ tos;
};
struct icmp {
  int icmp_id;
  int icmp_seq;
  void *icmp_cksum;
  scalar_t__ icmp_code;
  int /*<<< orphan*/ icmp_type;
};
typedef int /*<<< orphan*/ server_address;
typedef int /*<<< orphan*/ send_buffer;
typedef int /*<<< orphan*/ on;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ ICMP_ECHO;
int /*<<< orphan*/ IPPROTO_ICMP;
int /*<<< orphan*/ IPPROTO_IP;
int /*<<< orphan*/ IP_HDRINCL;
int /*<<< orphan*/ PF_INET;
int /*<<< orphan*/ SOCK_RAW;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_BROADCAST;
int atoi(char *);
int /*<<< orphan*/ bzero(struct sockaddr_in *, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ htons(int);
void *in_cksum(unsigned short *, int);
int /*<<< orphan*/ perror(char *);
unsigned long resolve(char *);
scalar_t__ sendto(int, char *, int, int /*<<< orphan*/, struct sockaddr *, int);
scalar_t__ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, char *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  int socket_descriptor;
  int ttl = 1;
  const int on = 1;
  unsigned long destination_address, source_address;
  struct sockaddr_in server_address;
  char send_buffer[sizeof(struct iphdr) + sizeof(struct icmp) + 1400];
  struct iphdr *ip_header = (struct iphdr *)send_buffer;
  struct icmp *icmp_header =
      (struct icmp *)(send_buffer + sizeof(struct iphdr));
  if (argc != 5 || strcmp(argv[3], "-t") != 0) {
    fprintf(
        stderr,
        "Usage: %s <source address | random> <destination address> -t <ttl>\n",
        argv[0]);
    exit(-10);
  }
  if ((socket_descriptor = socket(PF_INET, SOCK_RAW, IPPROTO_ICMP)) < 0) {
    perror("socket() failed");
    exit(-1);
  }
  if (setsockopt(socket_descriptor, IPPROTO_IP, IP_HDRINCL, (char *)&on,
                 sizeof(on)) < 0) {
    perror("setsockopt() failed");
    exit(-1);
  }
  if (setsockopt(socket_descriptor, SOL_SOCKET, SO_BROADCAST, (char *)&on,
                 sizeof(on)) < 0) {
    perror("setsockopt() failed");
    exit(-1);
  }
  source_address = resolve(argv[1]);
  destination_address = resolve(argv[2]);
  bzero(&server_address, sizeof(server_address));
  server_address.sin_family = AF_INET;
  server_address.sin_addr.s_addr = destination_address;
  ttl = atoi(argv[4]);
  ip_header->ihl = 5;
  ip_header->version = 4;
  ip_header->tos = 0;
  ip_header->tot_len = htons(sizeof(struct iphdr) + sizeof(struct icmp) + 1400);
  ip_header->id = 0;
  ip_header->frag_off = 0;
  ip_header->ttl = ttl;
  ip_header->protocol = IPPROTO_ICMP;
  ip_header->check = 0;
  ip_header->check =
      in_cksum((unsigned short *)ip_header, sizeof(struct iphdr));
  ip_header->saddr = source_address;
  ip_header->daddr = destination_address;
  icmp_header->icmp_type = ICMP_ECHO;
  icmp_header->icmp_code = 0;
  icmp_header->icmp_id = 1;
  icmp_header->icmp_seq = 1;
  icmp_header->icmp_cksum = 0;
  icmp_header->icmp_cksum =
      in_cksum((unsigned short *)icmp_header, sizeof(struct icmp) + 1400);
  while (1) {
    if (sendto(socket_descriptor, send_buffer, sizeof(send_buffer), 0,
               (struct sockaddr *)&server_address,
               sizeof(server_address)) < 0) {
      perror("sendto() failed");
      exit(-1);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x640,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
lea    -0x630(%rbp),%rax
mov    %rax,-0x638(%rbp)
lea    -0x630(%rbp),%rax
add    $0x50,%rax
mov    %rax,-0x640(%rbp)
cmpl   $0x5,-0x8(%rbp)
jne    122f <main+0x6f>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xde0(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
je     1255 <main+0x95>
mov    0x2d72(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdbd(%rip),%rsi
call   1090 <fprintf@plt>
mov    $0xfffffff6,%edi
call   10d0 <exit@plt>
mov    0x2d3c(%rip),%rax
mov    (%rax),%edi
mov    0x2d6b(%rip),%rax
mov    (%rax),%esi
mov    0x2d4a(%rip),%rax
mov    (%rax),%edx
call   10e0 <socket@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    1297 <main+0xd7>
lea    0xdbf(%rip),%rdi
call   10a0 <perror@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
mov    -0x14(%rbp),%edi
mov    0x2d27(%rip),%rax
mov    (%rax),%esi
mov    0x2d46(%rip),%rax
mov    (%rax),%edx
lea    -0x1c(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0x0,%rax
jge    12db <main+0x11b>
lea    0xd8b(%rip),%rdi
call   10a0 <perror@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
mov    -0x14(%rbp),%edi
mov    0x2cfb(%rip),%rax
mov    (%rax),%esi
mov    0x2cd2(%rip),%rax
mov    (%rax),%edx
lea    -0x1c(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0x0,%rax
jge    131f <main+0x15f>
lea    0xd47(%rip),%rdi
call   10a0 <perror@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <resolve@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <resolve@plt>
mov    %rax,-0x28(%rbp)
lea    -0x40(%rbp),%rdi
mov    $0x10,%esi
call   10b0 <bzero@plt>
mov    0x2c82(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x638(%rbp),%rax
movl   $0x5,(%rax)
mov    -0x638(%rbp),%rax
movl   $0x4,0x4(%rax)
mov    -0x638(%rbp),%rax
movq   $0x0,0x48(%rax)
mov    $0x5e8,%edi
call   1050 <htons@plt>
mov    %eax,%ecx
mov    -0x638(%rbp),%rax
mov    %ecx,0x40(%rax)
mov    -0x638(%rbp),%rax
movq   $0x0,0x38(%rax)
mov    -0x638(%rbp),%rax
movq   $0x0,0x30(%rax)
mov    -0x18(%rbp),%ecx
mov    -0x638(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    0x2bd3(%rip),%rax
mov    (%rax),%ecx
mov    -0x638(%rbp),%rax
mov    %ecx,0x28(%rax)
mov    -0x638(%rbp),%rax
movq   $0x0,0x20(%rax)
mov    -0x638(%rbp),%rdi
mov    $0x50,%esi
call   1040 <in_cksum@plt>
mov    %rax,%rcx
mov    -0x638(%rbp),%rax
mov    %rcx,0x20(%rax)
mov    -0x30(%rbp),%rcx
mov    -0x638(%rbp),%rax
mov    %rcx,0x10(%rax)
mov    -0x28(%rbp),%rcx
mov    -0x638(%rbp),%rax
mov    %rcx,0x18(%rax)
mov    0x2b5c(%rip),%rax
mov    (%rax),%ecx
mov    -0x640(%rbp),%rax
mov    %ecx,0x18(%rax)
mov    -0x640(%rbp),%rax
movq   $0x0,0x10(%rax)
mov    -0x640(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x640(%rbp),%rax
movl   $0x1,0x4(%rax)
mov    -0x640(%rbp),%rax
movq   $0x0,0x8(%rax)
mov    -0x640(%rbp),%rdi
mov    $0x598,%esi
call   1040 <in_cksum@plt>
mov    %rax,%rcx
mov    -0x640(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x14(%rbp),%edi
lea    -0x630(%rbp),%rsi
lea    -0x40(%rbp),%r8
mov    $0x5e8,%edx
xor    %ecx,%ecx
mov    $0x10,%r9d
call   1070 <sendto@plt>
cmp    $0x0,%rax
jge    14e8 <main+0x328>
lea    0xb92(%rip),%rdi
call   10a0 <perror@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
jmp    14a8 <main+0x2e8>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x608,%rsp
mov    %rsi,%r14
movl   $0x1,0x4(%rsp)
cmp    $0x5,%edi
jne    1228 <main+0x68>
mov    0x18(%r14),%rdi
lea    0xe24(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    1228 <main+0x68>
mov    0x2d9b(%rip),%rax
mov    (%rax),%edi
mov    0x2dca(%rip),%rax
mov    (%rax),%esi
mov    0x2da9(%rip),%r13
mov    0x0(%r13),%edx
call   10e0 <socket@plt>
test   %eax,%eax
jns    124a <main+0x8a>
lea    0xe34(%rip),%rdi
jmp    13c6 <main+0x206>
mov    0x2d79(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xdd8(%rip),%rsi
call   1090 <fprintf@plt>
mov    $0xfffffff6,%edi
call   10d0 <exit@plt>
mov    %eax,%ebx
mov    0x2d75(%rip),%rax
mov    (%rax),%esi
mov    0x2d94(%rip),%rax
mov    (%rax),%edx
lea    0x4(%rsp),%rcx
mov    %ebx,%edi
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
test   %rax,%rax
js     129e <main+0xde>
mov    0x2d64(%rip),%rax
mov    (%rax),%esi
mov    0x2d3b(%rip),%rax
mov    (%rax),%edx
lea    0x4(%rsp),%rcx
mov    %ebx,%edi
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
test   %rax,%rax
jns    12aa <main+0xea>
lea    0xdc2(%rip),%rdi
jmp    13c6 <main+0x206>
mov    0x8(%r14),%rdi
call   1060 <resolve@plt>
mov    %rax,0x8(%rsp)
mov    0x10(%r14),%rdi
call   1060 <resolve@plt>
mov    %rax,%r12
lea    0x10(%rsp),%r15
mov    %r15,%rdi
mov    $0x10,%esi
call   10b0 <bzero@plt>
mov    0x2cfb(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x18(%rsp)
mov    %r12,0x10(%rsp)
mov    0x20(%r14),%rdi
call   10c0 <atoi@plt>
mov    %eax,%ebp
movabs $0x400000005,%rax
mov    %rax,0x20(%rsp)
movq   $0x0,0x68(%rsp)
mov    $0x5e8,%edi
call   1050 <htons@plt>
mov    %eax,0x60(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x50(%rsp)
mov    %ebp,0x28(%rsp)
mov    0x0(%r13),%eax
mov    %eax,0x48(%rsp)
movq   $0x0,0x40(%rsp)
lea    0x20(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x50,%esi
call   1040 <in_cksum@plt>
mov    %rax,0x40(%rsp)
mov    0x8(%rsp),%rax
mov    %rax,0x30(%rsp)
mov    %r12,0x38(%rsp)
mov    0x2c3d(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x88(%rsp)
movabs $0x100000001,%rax
mov    %rax,0x70(%rsp)
xorps  %xmm0,%xmm0
movups %xmm0,0x78(%rsp)
lea    0x70(%rsp),%rdi
mov    $0x598,%esi
call   1040 <in_cksum@plt>
mov    %rax,0x78(%rsp)
nopw   0x0(%rax,%rax,1)
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x5e8,%edx
xor    %ecx,%ecx
mov    %r15,%r8
mov    $0x10,%r9d
call   1070 <sendto@plt>
test   %rax,%rax
jns    13a0 <main+0x1e0>
lea    0xcb5(%rip),%rdi
call   10a0 <perror@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i64 }
%struct.iphdr = type { i32, i32, i32, i64, i64, i8*, i32, i64, i64, i32, i64 }
%struct.icmp = type { i32, i32, i8*, i64, i32 }
%struct.sockaddr = type { i32 }
@.str = [3 x i8] c"-t\00"
@stderr = global i32 0
@.str.1 = [68 x i8] c"Usage: %s <source address | random> <destination address> -t <ttl>\0A\00"
@PF_INET = global i32 0
@SOCK_RAW = global i32 0
@IPPROTO_ICMP = global i32 0
@.str.2 = [16 x i8] c"socket() failed\00"
@IPPROTO_IP = global i32 0
@IP_HDRINCL = global i32 0
@.str.3 = [20 x i8] c"setsockopt() failed\00"
@SOL_SOCKET = global i32 0
@SO_BROADCAST = global i32 0
@AF_INET = global i32 0
@ICMP_ECHO = global i32 0
@.str.4 = [16 x i8] c"sendto() failed\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 i64
%10 = alloca i64
%11 = alloca %struct.sockaddr_in
%12 = alloca [1512 x i8]
%13 = alloca %struct.iphdr*
%14 = alloca %struct.icmp*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %7
store i32 1, i32* %8
%15 = getelementptr inbounds [1512 x i8], [1512 x i8]* %12, i64 0, i64 0
%16 = bitcast i8* %15 to %struct.iphdr*
store %struct.iphdr* %16, %struct.iphdr** %13
%17 = getelementptr inbounds [1512 x i8], [1512 x i8]* %12, i64 0, i64 0
%18 = getelementptr inbounds i8, i8* %17, i64 80
%19 = bitcast i8* %18 to %struct.icmp*
store %struct.icmp* %19, %struct.icmp** %14
%20 = load i32, i32* %4
%21 = icmp ne i32 %20, 5
br i1 %21, label %28, label %22
22: ; preds = %2
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 3
%25 = load i8*, i8** %24
%26 = call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %35
28: ; preds = %22, %2
%29 = load i32, i32* @stderr
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 0
%32 = load i8*, i8** %31
%33 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.1, i64 0, i64 0), i8* %32)
%34 = call i32 @exit(i32 -10)
unreachable
35: ; preds = %22
%36 = load i32, i32* @PF_INET
%37 = load i32, i32* @SOCK_RAW
%38 = load i32, i32* @IPPROTO_ICMP
%39 = call i32 @socket(i32 %36, i32 %37, i32 %38)
store i32 %39, i32* %6
%40 = icmp slt i32 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %35
%42 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%43 = call i32 @exit(i32 -1)
unreachable
44: ; preds = %35
%45 = load i32, i32* %6
%46 = load i32, i32* @IPPROTO_IP
%47 = load i32, i32* @IP_HDRINCL
%48 = bitcast i32* %8 to i8*
%49 = call i64 @setsockopt(i32 %45, i32 %46, i32 %47, i8* %48, i32 4)
%50 = icmp slt i64 %49, 0
br i1 %50, label %51, label %54
51: ; preds = %44
%52 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%53 = call i32 @exit(i32 -1)
unreachable
54: ; preds = %44
%55 = load i32, i32* %6
%56 = load i32, i32* @SOL_SOCKET
%57 = load i32, i32* @SO_BROADCAST
%58 = bitcast i32* %8 to i8*
%59 = call i64 @setsockopt(i32 %55, i32 %56, i32 %57, i8* %58, i32 4)
%60 = icmp slt i64 %59, 0
br i1 %60, label %61, label %64
61: ; preds = %54
%62 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%63 = call i32 @exit(i32 -1)
unreachable
64: ; preds = %54
%65 = load i8**, i8*** %5
%66 = getelementptr inbounds i8*, i8** %65, i64 1
%67 = load i8*, i8** %66
%68 = call i64 @resolve(i8* %67)
store i64 %68, i64* %10
%69 = load i8**, i8*** %5
%70 = getelementptr inbounds i8*, i8** %69, i64 2
%71 = load i8*, i8** %70
%72 = call i64 @resolve(i8* %71)
store i64 %72, i64* %9
%73 = call i32 @bzero(%struct.sockaddr_in* %11, i32 16)
%74 = load i32, i32* @AF_INET
%75 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 1
store i32 %74, i32* %75
%76 = load i64, i64* %9
%77 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 0
%78 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %77, i32 0, i32 0
store i64 %76, i64* %78
%79 = load i8**, i8*** %5
%80 = getelementptr inbounds i8*, i8** %79, i64 4
%81 = load i8*, i8** %80
%82 = call i32 @atoi(i8* %81)
store i32 %82, i32* %7
%83 = load %struct.iphdr*, %struct.iphdr** %13
%84 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %83, i32 0, i32 0
store i32 5, i32* %84
%85 = load %struct.iphdr*, %struct.iphdr** %13
%86 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %85, i32 0, i32 1
store i32 4, i32* %86
%87 = load %struct.iphdr*, %struct.iphdr** %13
%88 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %87, i32 0, i32 10
store i64 0, i64* %88
%89 = call i32 @htons(i32 1512)
%90 = load %struct.iphdr*, %struct.iphdr** %13
%91 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %90, i32 0, i32 9
store i32 %89, i32* %91
%92 = load %struct.iphdr*, %struct.iphdr** %13
%93 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %92, i32 0, i32 8
store i64 0, i64* %93
%94 = load %struct.iphdr*, %struct.iphdr** %13
%95 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %94, i32 0, i32 7
store i64 0, i64* %95
%96 = load i32, i32* %7
%97 = load %struct.iphdr*, %struct.iphdr** %13
%98 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %97, i32 0, i32 2
store i32 %96, i32* %98
%99 = load i32, i32* @IPPROTO_ICMP
%100 = load %struct.iphdr*, %struct.iphdr** %13
%101 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %100, i32 0, i32 6
store i32 %99, i32* %101
%102 = load %struct.iphdr*, %struct.iphdr** %13
%103 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %102, i32 0, i32 5
store i8* null, i8** %103
%104 = load %struct.iphdr*, %struct.iphdr** %13
%105 = bitcast %struct.iphdr* %104 to i16*
%106 = call i8* @in_cksum(i16* %105, i32 80)
%107 = load %struct.iphdr*, %struct.iphdr** %13
%108 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %107, i32 0, i32 5
store i8* %106, i8** %108
%109 = load i64, i64* %10
%110 = load %struct.iphdr*, %struct.iphdr** %13
%111 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %110, i32 0, i32 3
store i64 %109, i64* %111
%112 = load i64, i64* %9
%113 = load %struct.iphdr*, %struct.iphdr** %13
%114 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %113, i32 0, i32 4
store i64 %112, i64* %114
%115 = load i32, i32* @ICMP_ECHO
%116 = load %struct.icmp*, %struct.icmp** %14
%117 = getelementptr inbounds %struct.icmp, %struct.icmp* %116, i32 0, i32 4
store i32 %115, i32* %117
%118 = load %struct.icmp*, %struct.icmp** %14
%119 = getelementptr inbounds %struct.icmp, %struct.icmp* %118, i32 0, i32 3
store i64 0, i64* %119
%120 = load %struct.icmp*, %struct.icmp** %14
%121 = getelementptr inbounds %struct.icmp, %struct.icmp* %120, i32 0, i32 0
store i32 1, i32* %121
%122 = load %struct.icmp*, %struct.icmp** %14
%123 = getelementptr inbounds %struct.icmp, %struct.icmp* %122, i32 0, i32 1
store i32 1, i32* %123
%124 = load %struct.icmp*, %struct.icmp** %14
%125 = getelementptr inbounds %struct.icmp, %struct.icmp* %124, i32 0, i32 2
store i8* null, i8** %125
%126 = load %struct.icmp*, %struct.icmp** %14
%127 = bitcast %struct.icmp* %126 to i16*
%128 = call i8* @in_cksum(i16* %127, i32 1432)
%129 = load %struct.icmp*, %struct.icmp** %14
%130 = getelementptr inbounds %struct.icmp, %struct.icmp* %129, i32 0, i32 2
store i8* %128, i8** %130
br label %131
131: ; preds = %64, %140
%132 = load i32, i32* %6
%133 = getelementptr inbounds [1512 x i8], [1512 x i8]* %12, i64 0, i64 0
%134 = bitcast %struct.sockaddr_in* %11 to %struct.sockaddr*
%135 = call i64 @sendto(i32 %132, i8* %133, i32 1512, i32 0, %struct.sockaddr* %134, i32 16)
%136 = icmp slt i64 %135, 0
br i1 %136, label %137, label %140
137: ; preds = %131
%138 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%139 = call i32 @exit(i32 -1)
unreachable
140: ; preds = %131
br label %131
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i64 }
%struct.sockaddr = type { i32 }
@.str = [3 x i8] c"-t\00"
@stderr = global i32 0
@.str.1 = [68 x i8] c"Usage: %s <source address | random> <destination address> -t <ttl>\0A\00"
@PF_INET = global i32 0
@SOCK_RAW = global i32 0
@IPPROTO_ICMP = global i32 0
@.str.2 = [16 x i8] c"socket() failed\00"
@IPPROTO_IP = global i32 0
@IP_HDRINCL = global i32 0
@.str.3 = [20 x i8] c"setsockopt() failed\00"
@SOL_SOCKET = global i32 0
@SO_BROADCAST = global i32 0
@AF_INET = global i32 0
@ICMP_ECHO = global i32 0
@.str.4 = [16 x i8] c"sendto() failed\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca %struct.sockaddr_in
%5 = alloca [1512 x i8]
%6 = bitcast i32* %3 to i8*
store i32 1, i32* %3
%7 = bitcast %struct.sockaddr_in* %4 to i8*
%8 = getelementptr inbounds [1512 x i8], [1512 x i8]* %5, i64 0, i64 0
%9 = getelementptr inbounds [1512 x i8], [1512 x i8]* %5, i64 0, i64 80
%10 = icmp eq i32 %0, 5
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 3
%13 = load i8*, i8** %12
%14 = tail call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %21, label %16
16: ; preds = %11, %2
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %1
%19 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%20 = tail call i32 @exit(i32 -10)
unreachable
21: ; preds = %11
%22 = load i32, i32* @PF_INET
%23 = load i32, i32* @SOCK_RAW
%24 = load i32, i32* @IPPROTO_ICMP
%25 = tail call i32 @socket(i32 %22, i32 %23, i32 %24)
%26 = icmp slt i32 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %21
%28 = tail call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%29 = tail call i32 @exit(i32 -1)
unreachable
30: ; preds = %21
%31 = load i32, i32* @IPPROTO_IP
%32 = load i32, i32* @IP_HDRINCL
%33 = call i64 @setsockopt(i32 %25, i32 %31, i32 %32, i8* %6, i32 4)
%34 = icmp slt i64 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %30
%36 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%37 = call i32 @exit(i32 -1)
unreachable
38: ; preds = %30
%39 = load i32, i32* @SOL_SOCKET
%40 = load i32, i32* @SO_BROADCAST
%41 = call i64 @setsockopt(i32 %25, i32 %39, i32 %40, i8* %6, i32 4)
%42 = icmp slt i64 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %38
%44 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%45 = call i32 @exit(i32 -1)
unreachable
46: ; preds = %38
%47 = getelementptr inbounds i8*, i8** %1, i64 1
%48 = load i8*, i8** %47
%49 = call i64 @resolve(i8* %48)
%50 = getelementptr inbounds i8*, i8** %1, i64 2
%51 = load i8*, i8** %50
%52 = call i64 @resolve(i8* %51)
%53 = call i32 @bzero(%struct.sockaddr_in* %4, i32 16)
%54 = load i32, i32* @AF_INET
%55 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1
store i32 %54, i32* %55
%56 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0, i32 0
store i64 %52, i64* %56
%57 = getelementptr inbounds i8*, i8** %1, i64 4
%58 = load i8*, i8** %57
%59 = call i32 @atoi(i8* %58)
%60 = bitcast [1512 x i8]* %5 to i32*
store i32 5, i32* %60
%61 = getelementptr inbounds [1512 x i8], [1512 x i8]* %5, i64 0, i64 4
%62 = bitcast i8* %61 to i32*
store i32 4, i32* %62
%63 = getelementptr inbounds [1512 x i8], [1512 x i8]* %5, i64 0, i64 72
%64 = bitcast i8* %63 to i64*
store i64 0, i64* %64
%65 = call i32 @htons(i32 1512)
%66 = getelementptr inbounds [1512 x i8], [1512 x i8]* %5, i64 0, i64 64
%67 = bitcast i8* %66 to i32*
store i32 %65, i32* %67
%68 = getelementptr inbounds [1512 x i8], [1512 x i8]* %5, i64 0, i64 48
%69 = getelementptr inbounds [1512 x i8], [1512 x i8]* %5, i64 0, i64 8
%70 = bitcast i8* %69 to i32*
store i32 %59, i32* %70
%71 = load i32, i32* @IPPROTO_ICMP
%72 = getelementptr inbounds [1512 x i8], [1512 x i8]* %5, i64 0, i64 40
%73 = bitcast i8* %72 to i32*
store i32 %71, i32* %73
%74 = getelementptr inbounds [1512 x i8], [1512 x i8]* %5, i64 0, i64 32
%75 = bitcast i8* %74 to i8**
store i8* null, i8** %75
%76 = bitcast [1512 x i8]* %5 to i16*
%77 = call i8* @in_cksum(i16* %76, i32 80)
store i8* %77, i8** %75
%78 = getelementptr inbounds [1512 x i8], [1512 x i8]* %5, i64 0, i64 16
%79 = bitcast i8* %78 to i64*
store i64 %49, i64* %79
%80 = getelementptr inbounds [1512 x i8], [1512 x i8]* %5, i64 0, i64 24
%81 = bitcast i8* %80 to i64*
store i64 %52, i64* %81
%82 = load i32, i32* @ICMP_ECHO
%83 = getelementptr inbounds [1512 x i8], [1512 x i8]* %5, i64 0, i64 104
%84 = bitcast i8* %83 to i32*
store i32 %82, i32* %84
%85 = getelementptr inbounds [1512 x i8], [1512 x i8]* %5, i64 0, i64 96
%86 = bitcast i8* %85 to i64*
store i64 0, i64* %86
%87 = bitcast i8* %9 to i32*
store i32 1, i32* %87
%88 = getelementptr inbounds [1512 x i8], [1512 x i8]* %5, i64 0, i64 84
%89 = bitcast i8* %88 to i32*
store i32 1, i32* %89
%90 = getelementptr inbounds [1512 x i8], [1512 x i8]* %5, i64 0, i64 88
%91 = bitcast i8* %90 to i8**
store i8* null, i8** %91
%92 = bitcast i8* %9 to i16*
%93 = call i8* @in_cksum(i16* %92, i32 1432)
store i8* %93, i8** %91
%94 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
br label %95
95: ; preds = %95, %46
%96 = call i64 @sendto(i32 %25, i8* %8, i32 1512, i32 0, %struct.sockaddr* %94, i32 16)
%97 = icmp slt i64 %96, 0
br i1 %97, label %98, label %95
98: ; preds = %95
%99 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%100 = call i32 @exit(i32 -1)
unreachable
}