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

/* Variables and functions */
int /*<<< orphan*/ get_time(int *);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ sendto(int, int **, int, int /*<<< orphan*/,
                          struct sockaddr *, int);
struct timeval send_packet(int *sock, struct sockaddr_in *client) {
  int data[2];
  get_time(data);
  printf("sending: %d %d\n", data[0], data[1]);
  struct timeval tv;
  sendto(*sock, &data, sizeof(data), 0, (struct sockaddr *)client,
         sizeof(*client));
  gettimeofday(&tv, NULL);
  return tv;
}


x86 assembly (clang, -O0):
<send_packet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x20(%rbp),%rdi
call   1060 <get_time@plt>
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
lea    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%r8
mov    $0x8,%edx
xor    %ecx,%ecx
mov    $0x4,%r9d
call   1050 <sendto@plt>
lea    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
mov    -0x8(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_packet>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x8(%rsp),%r15
mov    %r15,%rdi
call   1060 <get_time@plt>
mov    0x8(%rsp),%esi
mov    0xc(%rsp),%edx
lea    0xe95(%rip),%rdi
call   1030 <printf@plt>
mov    (%rbx),%edi
mov    %r15,%rsi
mov    $0x8,%edx
xor    %ecx,%ecx
mov    %r14,%r8
mov    $0x4,%r9d
call   1050 <sendto@plt>
mov    %rsp,%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
mov    (%rsp),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32 }
%struct.timeval = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [16 x i8] c"sending: %d %d\0A\00"
define i32 @send_packet(i32* %0, %struct.sockaddr_in* %1) {
%3 = alloca %struct.timeval
%4 = alloca i32*
%5 = alloca %struct.sockaddr_in*
%6 = alloca [2 x i32]
store i32* %0, i32** %4
store %struct.sockaddr_in* %1, %struct.sockaddr_in** %5
%7 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%8 = call i32 @get_time(i32* %7)
%9 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%10 = load i32, i32* %9
%11 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%12 = load i32, i32* %11
%13 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %12)
%14 = load i32*, i32** %4
%15 = load i32, i32* %14
%16 = bitcast [2 x i32]* %6 to i32**
%17 = load %struct.sockaddr_in*, %struct.sockaddr_in** %5
%18 = bitcast %struct.sockaddr_in* %17 to %struct.sockaddr*
%19 = call i32 @sendto(i32 %15, i32** %16, i32 8, i32 0, %struct.sockaddr* %18, i32 4)
%20 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%21 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 0
%22 = load i32, i32* %21
ret i32 %22
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32 }
%struct.timeval = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [16 x i8] c"sending: %d %d\0A\00"
define i32 @send_packet(i32* nocapture %0, %struct.sockaddr_in* %1) {
%3 = alloca %struct.timeval
%4 = alloca i32*
%5 = bitcast i32** %4 to [2 x i32]*
%6 = bitcast i32** %4 to i8*
%7 = bitcast i32** %4 to i32*
%8 = call i32 @get_time(i32* %7)
%9 = load i32, i32* %7
%10 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%11 = load i32, i32* %10
%12 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %11)
%13 = load i32, i32* %0
%14 = bitcast %struct.sockaddr_in* %1 to %struct.sockaddr*
%15 = call i32 @sendto(i32 %13, i32** %4, i32 8, i32 0, %struct.sockaddr* %14, i32 4)
%16 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%17 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%18 = load i32, i32* %17
ret i32 %18
}