#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 */
struct timeval {
  long tv_sec;
  double tv_usec;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_addr;
};
struct ip {
  int ip_hl;
  int ip_ttl;
};
struct icmp {
  int icmp_seq;
  scalar_t__ icmp_data;
};
typedef int pid_t;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
char *inet_ntoa(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int, int, char *, int, int, double);
int /*<<< orphan*/ stderr;
int echoReplyProcessing(pid_t pid, char *ipDatagram, int ipLen,
                        struct timeval *recvTime,
                        struct sockaddr_in remoteHostAddr) {
  int ipLenRead;
  int icmpLenRead;
  struct ip *ip;
  struct icmp *icmp;
  struct timeval *tvsend;
  ip = (struct ip *)ipDatagram;
  ipLenRead = ip->ip_hl << 2;
  icmp = (struct icmp *)(ipDatagram + ipLenRead);
  if ((icmpLenRead = ipLen - ipLenRead) < 8)
    fprintf(stderr, "icmplen (%d) < 8\n", icmpLenRead);
  tvsend = (struct timeval *)icmp->icmp_data;
  double rtt = ((double)((recvTime->tv_sec - tvsend->tv_sec) * 1000000L +
                         recvTime->tv_usec) -
                tvsend->tv_usec) /
               1000;
  printf("pid: %d, %d bytes from %s: icmp_seq=%u, ttl=%d, time=%.1f ms\n", pid,
         ipLen, inet_ntoa(remoteHostAddr.sin_addr), icmp->icmp_seq, ip->ip_ttl,
         rtt);
  return 0;
}


x86 assembly (clang, -O0):
<echoReplyProcessing>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %r8d,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    (%rax),%eax
shl    $0x2,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x40(%rbp)
mov    -0x1c(%rbp),%eax
sub    -0x2c(%rbp),%eax
mov    %eax,-0x30(%rbp)
cmp    $0x8,%eax
jge    1197 <echoReplyProcessing+0x67>
mov    0x2e5a(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%edx
lea    0xe76(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x40(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x48(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
mov    -0x48(%rbp),%rcx
sub    (%rcx),%rax
imul   $0xf4240,%rax,%rax
cvtsi2sd %rax,%xmm0
mov    -0x28(%rbp),%rax
addsd  0x8(%rax),%xmm0
mov    -0x48(%rbp),%rax
subsd  0x8(%rax),%xmm0
movsd  0xe29(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x58(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <inet_ntoa@plt>
mov    -0x58(%rbp),%esi
mov    -0x54(%rbp),%edx
mov    %rax,%rcx
mov    -0x40(%rbp),%rax
mov    (%rax),%r8d
mov    -0x38(%rbp),%rax
mov    0x4(%rax),%r9d
movsd  -0x50(%rbp),%xmm0
lea    0xe02(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<echoReplyProcessing>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%r15d
mov    %rcx,%r13
mov    %edx,%r12d
mov    %rsi,%rbp
mov    %edi,%r14d
mov    (%rsi),%eax
shl    $0x2,%eax
movslq %eax,%rbx
sub    %ebx,%edx
cmp    $0x7,%edx
jg     116e <echoReplyProcessing+0x3e>
mov    0x2e80(%rip),%rax
mov    (%rax),%edi
lea    0xe9f(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x8(%rbp,%rbx,1),%rax
mov    0x0(%r13),%rcx
sub    (%rax),%rcx
imul   $0xf4240,%rcx,%rcx
cvtsi2sd %rcx,%xmm0
addsd  0x8(%r13),%xmm0
subsd  0x8(%rax),%xmm0
divsd  0xe67(%rip),%xmm0
movsd  %xmm0,(%rsp)
mov    %r15d,%edi
call   1030 <inet_ntoa@plt>
mov    0x0(%rbp,%rbx,1),%r8d
mov    0x4(%rbp),%r9d
lea    0xe64(%rip),%rdi
mov    %r14d,%esi
mov    %r12d,%edx
mov    %rax,%rcx
movsd  (%rsp),%xmm0
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { i64, double }
%struct.sockaddr_in = type { i32 }
%struct.ip = type { i32, i32 }
%struct.icmp = type { i32, i64 }
@stderr = global i32 0
@.str = [18 x i8] c"icmplen (%d) < 8\0A\00"
@.str.1 = [62 x i8] c"pid: %d, %d bytes from %s: icmp_seq=%u, ttl=%d, time=%.1f ms\0A\00"
define i32 @echoReplyProcessing(i32 %0, i8* %1, i32 %2, %struct.timeval* %3, i32 %4) {
%6 = alloca %struct.sockaddr_in
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca %struct.timeval*
%11 = alloca i32
%12 = alloca i32
%13 = alloca %struct.ip*
%14 = alloca %struct.icmp*
%15 = alloca %struct.timeval*
%16 = alloca double
%17 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 0
store i32 %4, i32* %17
store i32 %0, i32* %7
store i8* %1, i8** %8
store i32 %2, i32* %9
store %struct.timeval* %3, %struct.timeval** %10
%18 = load i8*, i8** %8
%19 = bitcast i8* %18 to %struct.ip*
store %struct.ip* %19, %struct.ip** %13
%20 = load %struct.ip*, %struct.ip** %13
%21 = getelementptr inbounds %struct.ip, %struct.ip* %20, i32 0, i32 0
%22 = load i32, i32* %21
%23 = shl i32 %22, 2
store i32 %23, i32* %11
%24 = load i8*, i8** %8
%25 = load i32, i32* %11
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
%28 = bitcast i8* %27 to %struct.icmp*
store %struct.icmp* %28, %struct.icmp** %14
%29 = load i32, i32* %9
%30 = load i32, i32* %11
%31 = sub nsw i32 %29, %30
store i32 %31, i32* %12
%32 = icmp slt i32 %31, 8
br i1 %32, label %33, label %37
33: ; preds = %5
%34 = load i32, i32* @stderr
%35 = load i32, i32* %12
%36 = call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %35)
br label %37
37: ; preds = %33, %5
%38 = load %struct.icmp*, %struct.icmp** %14
%39 = getelementptr inbounds %struct.icmp, %struct.icmp* %38, i32 0, i32 1
%40 = load i64, i64* %39
%41 = inttoptr i64 %40 to %struct.timeval*
store %struct.timeval* %41, %struct.timeval** %15
%42 = load %struct.timeval*, %struct.timeval** %10
%43 = getelementptr inbounds %struct.timeval, %struct.timeval* %42, i32 0, i32 0
%44 = load i64, i64* %43
%45 = load %struct.timeval*, %struct.timeval** %15
%46 = getelementptr inbounds %struct.timeval, %struct.timeval* %45, i32 0, i32 0
%47 = load i64, i64* %46
%48 = sub nsw i64 %44, %47
%49 = mul nsw i64 %48, 1000000
%50 = sitofp i64 %49 to double
%51 = load %struct.timeval*, %struct.timeval** %10
%52 = getelementptr inbounds %struct.timeval, %struct.timeval* %51, i32 0, i32 1
%53 = load double, double* %52
%54 = fadd double %50, %53
%55 = load %struct.timeval*, %struct.timeval** %15
%56 = getelementptr inbounds %struct.timeval, %struct.timeval* %55, i32 0, i32 1
%57 = load double, double* %56
%58 = fsub double %54, %57
%59 = fdiv double %58, 1.000000e+03
store double %59, double* %16
%60 = load i32, i32* %7
%61 = load i32, i32* %9
%62 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 0
%63 = load i32, i32* %62
%64 = call i8* @inet_ntoa(i32 %63)
%65 = load %struct.icmp*, %struct.icmp** %14
%66 = getelementptr inbounds %struct.icmp, %struct.icmp* %65, i32 0, i32 0
%67 = load i32, i32* %66
%68 = load %struct.ip*, %struct.ip** %13
%69 = getelementptr inbounds %struct.ip, %struct.ip* %68, i32 0, i32 1
%70 = load i32, i32* %69
%71 = load double, double* %16
%72 = call i32 @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0), i32 %60, i32 %61, i8* %64, i32 %67, i32 %70, double %71)
ret i32 0
}

LLVM IR (-O2):
%struct.timeval = type { i64, double }
@stderr = global i32 0
@.str = [18 x i8] c"icmplen (%d) < 8\0A\00"
@.str.1 = [62 x i8] c"pid: %d, %d bytes from %s: icmp_seq=%u, ttl=%d, time=%.1f ms\0A\00"
define i32 @echoReplyProcessing(i32 %0, i8* nocapture %1, i32 %2, %struct.timeval* nocapture %3, i32 %4) {
%6 = bitcast i8* %1 to i32*
%7 = load i32, i32* %6
%8 = shl i32 %7, 2
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %1, i64 %9
%11 = sub nsw i32 %2, %8
%12 = icmp slt i32 %11, 8
br i1 %12, label %13, label %16
13: ; preds = %5
%14 = load i32, i32* @stderr
%15 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %11)
br label %16
16: ; preds = %13, %5
%17 = getelementptr inbounds i8, i8* %10, i64 8
%18 = bitcast i8* %17 to i64*
%19 = load i64, i64* %18
%20 = inttoptr i64 %19 to %struct.timeval*
%21 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%22 = load i64, i64* %21
%23 = getelementptr inbounds %struct.timeval, %struct.timeval* %20, i64 0, i32 0
%24 = load i64, i64* %23
%25 = sub nsw i64 %22, %24
%26 = mul nsw i64 %25, 1000000
%27 = sitofp i64 %26 to double
%28 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%29 = load double, double* %28
%30 = fadd double %29, %27
%31 = getelementptr inbounds %struct.timeval, %struct.timeval* %20, i64 0, i32 1
%32 = load double, double* %31
%33 = fsub double %30, %32
%34 = fdiv double %33, 1.000000e+03
%35 = tail call i8* @inet_ntoa(i32 %4)
%36 = bitcast i8* %10 to i32*
%37 = load i32, i32* %36
%38 = getelementptr inbounds i8, i8* %1, i64 4
%39 = bitcast i8* %38 to i32*
%40 = load i32, i32* %39
%41 = tail call i32 @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0), i32 %0, i32 %2, i8* %35, i32 %37, i32 %40, double %34)
ret i32 0
}