#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 */
typedef int /*<<< orphan*/ t3;
struct sockaddr_in {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ receive_packet(int *, int *, int, int *,
                                  int /*<<< orphan*/ *);
int /*<<< orphan*/ send_packet(int *, char *, int, int /*<<< orphan*/ *,
                               struct sockaddr_in *);
long delay_packet(int *sock, struct sockaddr_in *slave) {
  int t3[2], t4[2];
  send_packet(sock, "delay_packet", 12, NULL, slave);
  receive_packet(sock, t3, sizeof(t3), t4, NULL);
  return ((((long)t4[0] * 1000000000L) + t4[1]) -
          (((long)t3[0] * 1000000000L) + t3[1]));
}


x86 assembly (clang, -O0):
<delay_packet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%r8
lea    0xec1(%rip),%rsi
mov    $0xc,%edx
xor    %eax,%eax
mov    %eax,%ecx
call   1040 <send_packet@plt>
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x20(%rbp),%rcx
mov    $0x8,%edx
xor    %eax,%eax
mov    %eax,%r8d
call   1030 <receive_packet@plt>
movslq -0x20(%rbp),%rax
imul   $0x3b9aca00,%rax,%rax
movslq -0x1c(%rbp),%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
imul   $0x3b9aca00,%rcx,%rcx
movslq -0x14(%rbp),%rdx
add    %rdx,%rcx
sub    %rcx,%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<delay_packet>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r8
mov    %rdi,%rbx
lea    0xece(%rip),%rsi
mov    $0xc,%edx
xor    %ecx,%ecx
call   1040 <send_packet@plt>
lea    0x8(%rsp),%rsi
mov    %rsp,%rcx
mov    %rbx,%rdi
mov    $0x8,%edx
xor    %r8d,%r8d
call   1030 <receive_packet@plt>
movslq (%rsp),%rax
movslq 0x4(%rsp),%rcx
movslq 0x8(%rsp),%rdx
sub    %rdx,%rax
movslq 0xc(%rsp),%rdx
sub    %rdx,%rcx
imul   $0x3b9aca00,%rax,%rax
add    %rcx,%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32 }
@.str = [13 x i8] c"delay_packet\00"
define i64 @delay_packet(i32* %0, %struct.sockaddr_in* %1) {
%3 = alloca i32*
%4 = alloca %struct.sockaddr_in*
%5 = alloca [2 x i32]
%6 = alloca [2 x i32]
store i32* %0, i32** %3
store %struct.sockaddr_in* %1, %struct.sockaddr_in** %4
%7 = load i32*, i32** %3
%8 = load %struct.sockaddr_in*, %struct.sockaddr_in** %4
%9 = call i32 @send_packet(i32* %7, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 12, i32* null, %struct.sockaddr_in* %8)
%10 = load i32*, i32** %3
%11 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%12 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%13 = call i32 @receive_packet(i32* %10, i32* %11, i32 8, i32* %12, i32* null)
%14 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%15 = load i32, i32* %14
%16 = sext i32 %15 to i64
%17 = mul nsw i64 %16, 1000000000
%18 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%19 = load i32, i32* %18
%20 = sext i32 %19 to i64
%21 = add nsw i64 %17, %20
%22 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%23 = load i32, i32* %22
%24 = sext i32 %23 to i64
%25 = mul nsw i64 %24, 1000000000
%26 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%27 = load i32, i32* %26
%28 = sext i32 %27 to i64
%29 = add nsw i64 %25, %28
%30 = sub nsw i64 %21, %29
ret i64 %30
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32 }
@.str = [13 x i8] c"delay_packet\00"
define i64 @delay_packet(i32* %0, %struct.sockaddr_in* %1) {
%3 = alloca [2 x i32]
%4 = alloca [2 x i32]
%5 = bitcast [2 x i32]* %3 to i8*
%6 = bitcast [2 x i32]* %4 to i8*
%7 = tail call i32 @send_packet(i32* %0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 12, i32* null, %struct.sockaddr_in* %1)
%8 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%9 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%10 = call i32 @receive_packet(i32* %0, i32* %8, i32 8, i32* %9, i32* null)
%11 = load i32, i32* %9
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%14 = load i32, i32* %13
%15 = sext i32 %14 to i64
%16 = load i32, i32* %8
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%19 = load i32, i32* %18
%20 = sext i32 %19 to i64
%21 = sub nsw i64 %12, %17
%22 = mul nsw i64 %21, 1000000000
%23 = sub nsw i64 %15, %20
%24 = add nsw i64 %23, %22
ret i64 %24
}