#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 timezone {
  scalar_t__ tz_dsttime;
  scalar_t__ tz_minuteswest;
};
struct timeval {
  int /*<<< orphan*/ tv_sec;
  scalar_t__ tv_usec;
};

/* Variables and functions */
int /*<<< orphan*/ time(int /*<<< orphan*/);
int gettimeofday(struct timeval *tv, void *tzvp) {
  struct timezone *tz = tzvp;
  if (tz)
    tz->tz_minuteswest = tz->tz_dsttime = 0;
  tv->tv_usec = 0;
  tv->tv_sec = time(0);
  return 0;
}


x86 assembly (clang, -O0):
<gettimeofday>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     114a <gettimeofday+0x3a>
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movq   $0x0,0x8(%rax)
mov    -0x8(%rbp),%rax
movq   $0x0,0x8(%rax)
xor    %edi,%edi
call   1030 <time@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gettimeofday>:
push   %rbx
mov    %rdi,%rbx
test   %rsi,%rsi
je     111f <gettimeofday+0xf>
xorps  %xmm0,%xmm0
movups %xmm0,(%rsi)
movq   $0x0,0x8(%rbx)
xor    %edi,%edi
call   1030 <time@plt>
mov    %eax,(%rbx)
xor    %eax,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
%struct.timeval = type { i32, i64 }
define i32 @gettimeofday(%struct.timeval* nocapture writeonly %0, i8* writeonly %1) {
%3 = icmp eq i8* %1, null
br i1 %3, label %5, label %4
4: ; preds = %2
br label %5
5: ; preds = %4, %2
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 1
store i64 0, i64* %6
%7 = tail call i32 @time(i32 0)
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 0
store i32 %7, i32* %8
ret i32 0
}