#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 tm_wday;
  int tm_year;
  int tm_mon;
  int tm_mday;
  int tm_hour;
  int tm_min;
  int tm_sec;
  long tm_gmtoff;
};
struct timezone {
  int dummy;
};
struct timeval {
  long tv_usec;
};
typedef int /*<<< orphan*/ s_err;

/* Variables and functions */
int /*<<< orphan*/ fatal_error(char *, int /*<<< orphan*/);
int gettimeofday(struct timeval *, struct timezone *);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ os_last_err_desc(char *, int);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void get_datetime_of_day(int *wday, int *year, int *month, int *day, int *hour,
                         int *minute, int *second, long int *usec,
                         long int *gmtoff) {
  time_t ltime = time(NULL);
  struct tm ts;
  ts = *localtime(&ltime);
  struct timeval tv;
  struct timezone tz;
  if (gettimeofday(&tv, &tz) == -1) {
    char s_err[200];
    fatal_error("gettimeofday() error, %s",
                os_last_err_desc(s_err, sizeof(s_err)));
  }
  *wday = ts.tm_wday;
  *year = ts.tm_year + 1900;
  *month = ts.tm_mon + 1;
  *day = ts.tm_mday;
  *hour = ts.tm_hour;
  *minute = ts.tm_min;
  *second = ts.tm_sec;
  *usec = tv.tv_usec;
  *gmtoff = ts.tm_gmtoff;
}


x86 assembly (clang, -O0):
<get_datetime_of_day>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,-0x34(%rbp)
lea    -0x34(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,%rsi
lea    -0x60(%rbp),%rdi
mov    $0x28,%edx
call   1060 <memcpy@plt>
lea    -0x68(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1050 <gettimeofday@plt>
cmp    $0xffffffff,%eax
jne    11ea <get_datetime_of_day+0x8a>
lea    -0x140(%rbp),%rdi
mov    $0xc8,%esi
call   1040 <os_last_err_desc@plt>
mov    %eax,%esi
lea    0xe1b(%rip),%rdi
call   1080 <fatal_error@plt>
mov    -0x60(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x5c(%rbp),%ecx
add    $0x76c,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x58(%rbp),%ecx
add    $0x1,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x54(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x50(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x4c(%rbp),%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x48(%rbp),%ecx
mov    0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x68(%rbp),%rcx
mov    0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x40(%rbp),%rcx
mov    0x20(%rbp),%rax
mov    %rcx,(%rax)
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_datetime_of_day>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
mov    %r9,0x38(%rsp)
mov    %r8,0x30(%rsp)
mov    %rcx,0x28(%rsp)
mov    %rdx,0x20(%rsp)
mov    %rsi,0x18(%rsp)
mov    %rdi,0x10(%rsp)
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1030 <localtime@plt>
mov    (%rax),%ebx
mov    0x4(%rax),%r14d
mov    0x8(%rax),%ebp
mov    0xc(%rax),%r15d
mov    0x10(%rax),%r12d
mov    0x14(%rax),%r13d
mov    0x18(%rax),%ecx
mov    %ecx,(%rsp)
mov    0x20(%rax),%rax
mov    %rax,0x8(%rsp)
lea    0x48(%rsp),%rdi
lea    0x40(%rsp),%rsi
call   1050 <gettimeofday@plt>
cmp    $0xffffffff,%eax
jne    11e9 <get_datetime_of_day+0x99>
lea    0x50(%rsp),%rdi
mov    $0xc8,%esi
call   1040 <os_last_err_desc@plt>
lea    0xe1e(%rip),%rdi
mov    %eax,%esi
call   1070 <fatal_error@plt>
mov    0x10(%rsp),%rax
mov    %ebx,(%rax)
add    $0x76c,%r14d
mov    0x18(%rsp),%rax
mov    %r14d,(%rax)
add    $0x1,%ebp
mov    0x20(%rsp),%rax
mov    %ebp,(%rax)
mov    0x28(%rsp),%rax
mov    %r15d,(%rax)
mov    0x30(%rsp),%rax
mov    %r12d,(%rax)
mov    0x38(%rsp),%rax
mov    %r13d,(%rax)
mov    0x150(%rsp),%rax
mov    (%rsp),%ecx
mov    %ecx,(%rax)
mov    0x48(%rsp),%rax
mov    0x158(%rsp),%rcx
mov    %rax,(%rcx)
mov    0x160(%rsp),%rax
mov    0x8(%rsp),%rcx
mov    %rcx,(%rax)
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32, i32, i64 }
%struct.timeval = type { i64 }
%struct.timezone = type { i32 }
@.str = [25 x i8] c"gettimeofday() error, %s\00"
define void @get_datetime_of_day(i32* %0, i32* %1, i32* %2, i32* %3, i32* %4, i32* %5, i32* %6, i64* %7, i64* %8) {
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca i32*
%16 = alloca i32*
%17 = alloca i64*
%18 = alloca i64*
%19 = alloca i32
%20 = alloca %struct.tm
%21 = alloca %struct.timeval
%22 = alloca %struct.timezone
%23 = alloca [200 x i8]
store i32* %0, i32** %10
store i32* %1, i32** %11
store i32* %2, i32** %12
store i32* %3, i32** %13
store i32* %4, i32** %14
store i32* %5, i32** %15
store i32* %6, i32** %16
store i64* %7, i64** %17
store i64* %8, i64** %18
%24 = call i32 @time(i32* null)
store i32 %24, i32* %19
%25 = call %struct.tm* @localtime(i32* %19)
%26 = bitcast %struct.tm* %20 to i8*
%27 = bitcast %struct.tm* %25 to i8*
%28 = call i32 @gettimeofday(%struct.timeval* %21, %struct.timezone* %22)
%29 = icmp eq i32 %28, -1
br i1 %29, label %30, label %34
30: ; preds = %9
%31 = getelementptr inbounds [200 x i8], [200 x i8]* %23, i64 0, i64 0
%32 = call i32 @os_last_err_desc(i8* %31, i32 200)
%33 = call i32 @fatal_error(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %32)
br label %34
34: ; preds = %30, %9
%35 = getelementptr inbounds %struct.tm, %struct.tm* %20, i32 0, i32 0
%36 = load i32, i32* %35
%37 = load i32*, i32** %10
store i32 %36, i32* %37
%38 = getelementptr inbounds %struct.tm, %struct.tm* %20, i32 0, i32 1
%39 = load i32, i32* %38
%40 = add nsw i32 %39, 1900
%41 = load i32*, i32** %11
store i32 %40, i32* %41
%42 = getelementptr inbounds %struct.tm, %struct.tm* %20, i32 0, i32 2
%43 = load i32, i32* %42
%44 = add nsw i32 %43, 1
%45 = load i32*, i32** %12
store i32 %44, i32* %45
%46 = getelementptr inbounds %struct.tm, %struct.tm* %20, i32 0, i32 3
%47 = load i32, i32* %46
%48 = load i32*, i32** %13
store i32 %47, i32* %48
%49 = getelementptr inbounds %struct.tm, %struct.tm* %20, i32 0, i32 4
%50 = load i32, i32* %49
%51 = load i32*, i32** %14
store i32 %50, i32* %51
%52 = getelementptr inbounds %struct.tm, %struct.tm* %20, i32 0, i32 5
%53 = load i32, i32* %52
%54 = load i32*, i32** %15
store i32 %53, i32* %54
%55 = getelementptr inbounds %struct.tm, %struct.tm* %20, i32 0, i32 6
%56 = load i32, i32* %55
%57 = load i32*, i32** %16
store i32 %56, i32* %57
%58 = getelementptr inbounds %struct.timeval, %struct.timeval* %21, i32 0, i32 0
%59 = load i64, i64* %58
%60 = load i64*, i64** %17
store i64 %59, i64* %60
%61 = getelementptr inbounds %struct.tm, %struct.tm* %20, i32 0, i32 7
%62 = load i64, i64* %61
%63 = load i64*, i64** %18
store i64 %62, i64* %63
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i64 }
%struct.timezone = type { i32 }
%struct.tm = type { i32, i32, i32, i32, i32, i32, i32, i64 }
@.str = [25 x i8] c"gettimeofday() error, %s\00"
define void @get_datetime_of_day(i32* nocapture writeonly %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2, i32* nocapture writeonly %3, i32* nocapture writeonly %4, i32* nocapture writeonly %5, i32* nocapture writeonly %6, i64* nocapture writeonly %7, i64* nocapture writeonly %8) {
%10 = alloca i32
%11 = alloca %struct.timeval
%12 = alloca %struct.timezone
%13 = alloca [200 x i8]
%14 = bitcast i32* %10 to i8*
%15 = tail call i32 @time(i32* null)
store i32 %15, i32* %10
%16 = call %struct.tm* @localtime(i32* %10)
%17 = getelementptr inbounds %struct.tm, %struct.tm* %16, i64 0, i32 0
%18 = load i32, i32* %17
%19 = getelementptr inbounds %struct.tm, %struct.tm* %16, i64 0, i32 1
%20 = load i32, i32* %19
%21 = getelementptr inbounds %struct.tm, %struct.tm* %16, i64 0, i32 2
%22 = load i32, i32* %21
%23 = getelementptr inbounds %struct.tm, %struct.tm* %16, i64 0, i32 3
%24 = load i32, i32* %23
%25 = getelementptr inbounds %struct.tm, %struct.tm* %16, i64 0, i32 4
%26 = load i32, i32* %25
%27 = getelementptr inbounds %struct.tm, %struct.tm* %16, i64 0, i32 5
%28 = load i32, i32* %27
%29 = getelementptr inbounds %struct.tm, %struct.tm* %16, i64 0, i32 6
%30 = load i32, i32* %29
%31 = getelementptr inbounds %struct.tm, %struct.tm* %16, i64 0, i32 7
%32 = load i64, i64* %31
%33 = bitcast %struct.timeval* %11 to i8*
%34 = bitcast %struct.timezone* %12 to i8*
%35 = call i32 @gettimeofday(%struct.timeval* %11, %struct.timezone* %12)
%36 = icmp eq i32 %35, -1
br i1 %36, label %37, label %41
37: ; preds = %9
%38 = getelementptr inbounds [200 x i8], [200 x i8]* %13, i64 0, i64 0
%39 = call i32 @os_last_err_desc(i8* %38, i32 200)
%40 = call i32 @fatal_error(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %39)
br label %41
41: ; preds = %37, %9
store i32 %18, i32* %0
%42 = add nsw i32 %20, 1900
store i32 %42, i32* %1
%43 = add nsw i32 %22, 1
store i32 %43, i32* %2
store i32 %24, i32* %3
store i32 %26, i32* %4
store i32 %28, i32* %5
store i32 %30, i32* %6
%44 = getelementptr inbounds %struct.timeval, %struct.timeval* %11, i64 0, i32 0
%45 = load i64, i64* %44
store i64 %45, i64* %7
store i64 %32, i64* %8
ret void
}