#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 {
  scalar_t__ tv_usec;
  scalar_t__ tv_sec;
  int /*<<< orphan*/ member_0;
};

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
void get_time(int in[2]) {
  if (in != NULL) {
    struct timeval tv = {0};
    gettimeofday(&tv, NULL);
    in[0] = (int)tv.tv_sec;
    in[1] = (int)tv.tv_usec * 1000;
  }
}


x86 assembly (clang, -O0):
<get_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1171 <get_time+0x51>
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1040 <memset@plt>
lea    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
mov    -0x18(%rbp),%rax
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
imul   $0x3e8,%eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x4(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_time>:
test   %rdi,%rdi
je     114c <get_time+0x3c>
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbx
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movq   $0x0,0x10(%rsp)
mov    %rsp,%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    0x8(%rsp),%eax
mov    %eax,(%rbx)
imul   $0x3e8,(%rsp),%eax
mov    %eax,0x4(%rbx)
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timeval = type { i64, i64, i32 }
define void @get_time(i32* %0) {
%2 = alloca i32*
%3 = alloca %struct.timeval
store i32* %0, i32** %2
%4 = load i32*, i32** %2
%5 = icmp ne i32* %4, null
br i1 %5, label %6, label %20
6: ; preds = %1
%7 = bitcast %struct.timeval* %3 to i8*
%8 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 1
%10 = load i64, i64* %9
%11 = trunc i64 %10 to i32
%12 = load i32*, i32** %2
%13 = getelementptr inbounds i32, i32* %12, i64 0
store i32 %11, i32* %13
%14 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 0
%15 = load i64, i64* %14
%16 = trunc i64 %15 to i32
%17 = mul nsw i32 %16, 1000
%18 = load i32*, i32** %2
%19 = getelementptr inbounds i32, i32* %18, i64 1
store i32 %17, i32* %19
br label %20
20: ; preds = %6, %1
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i64, i64, i32 }
define void @get_time(i32* writeonly %0) {
%2 = alloca %struct.timeval
%3 = icmp eq i32* %0, null
br i1 %3, label %15, label %4
4: ; preds = %1
%5 = bitcast %struct.timeval* %2 to i8*
%6 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%7 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 1
%8 = load i64, i64* %7
%9 = trunc i64 %8 to i32
store i32 %9, i32* %0
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 0
%11 = load i64, i64* %10
%12 = trunc i64 %11 to i32
%13 = mul nsw i32 %12, 1000
%14 = getelementptr inbounds i32, i32* %0, i64 1
store i32 %13, i32* %14
br label %15
15: ; preds = %4, %1
ret void
}