#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*/ time_t;
struct tm {
  int dummy;
};
struct timeval {
  unsigned int tv_usec;
  int /*<<< orphan*/ tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/);
struct tm *localtime(int /*<<< orphan*/ const *);
void getDateTime(struct tm *const tm, unsigned *const usec) {
  struct timeval tv;
  gettimeofday(&tv, 0);
  const time_t t = tv.tv_sec;
  *tm = *localtime(&t);
  *usec = tv.tv_usec;
}


x86 assembly (clang, -O0):
<getDateTime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    -0x1c(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
mov    (%rcx),%ecx
mov    %ecx,(%rax)
mov    -0x18(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getDateTime>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
mov    0x14(%rsp),%eax
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1030 <localtime@plt>
mov    (%rax),%eax
mov    %eax,(%rbx)
mov    0x10(%rsp),%eax
mov    %eax,(%r14)
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
%struct.timeval = type { i32, i32 }
define void @getDateTime(%struct.tm* %0, i32* %1) {
%3 = alloca %struct.tm*
%4 = alloca i32*
%5 = alloca %struct.timeval
%6 = alloca i32
store %struct.tm* %0, %struct.tm** %3
store i32* %1, i32** %4
%7 = call i32 @gettimeofday(%struct.timeval* %5, i32 0)
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 1
%9 = load i32, i32* %8
store i32 %9, i32* %6
%10 = load %struct.tm*, %struct.tm** %3
%11 = call %struct.tm* @localtime(i32* %6)
%12 = bitcast %struct.tm* %10 to i8*
%13 = bitcast %struct.tm* %11 to i8*
%14 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 0
%15 = load i32, i32* %14
%16 = load i32*, i32** %4
store i32 %15, i32* %16
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32 }
%struct.timeval = type { i32, i32 }
define void @getDateTime(%struct.tm* nocapture writeonly %0, i32* nocapture writeonly %1) {
%3 = alloca %struct.timeval
%4 = alloca i32
%5 = bitcast %struct.timeval* %3 to i8*
%6 = call i32 @gettimeofday(%struct.timeval* %3, i32 0)
%7 = bitcast i32* %4 to i8*
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%9 = load i32, i32* %8
store i32 %9, i32* %4
%10 = call %struct.tm* @localtime(i32* %4)
%11 = getelementptr %struct.tm, %struct.tm* %10, i64 0, i32 0
%12 = getelementptr %struct.tm, %struct.tm* %0, i64 0, i32 0
%13 = load i32, i32* %11
store i32 %13, i32* %12
%14 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%15 = load i32, i32* %14
store i32 %15, i32* %1
ret void
}