#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 /*<<< orphan*/ tm_sec;
  int /*<<< orphan*/ tm_min;
  int /*<<< orphan*/ tm_hour;
  int /*<<< orphan*/ tm_mday;
  int /*<<< orphan*/ tm_mon;
  int /*<<< orphan*/ tm_year;
};

/* Variables and functions */
int /*<<< orphan*/ my_mktime(int /*<<< orphan*/, int /*<<< orphan*/,
                             int /*<<< orphan*/, int /*<<< orphan*/,
                             int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ rtc_gettime(struct tm *);
time_t time(time_t *t) {
  struct tm tm;
  time_t val;
  rtc_gettime(&tm);
  val = my_mktime(tm.tm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min,
                  tm.tm_sec);
  if (t)
    *t = val;
  return val;
}


x86 assembly (clang, -O0):
<time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x20(%rbp),%rdi
call   1030 <rtc_gettime@plt>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
mov    -0x20(%rbp),%r9d
call   1040 <my_mktime@plt>
mov    %eax,-0x24(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1165 <time+0x45>
mov    -0x24(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<time>:
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbx
lea    0x8(%rsp),%rdi
call   1030 <rtc_gettime@plt>
mov    0x1c(%rsp),%edi
mov    0x18(%rsp),%esi
mov    0x14(%rsp),%edx
mov    0x10(%rsp),%ecx
mov    0x8(%rsp),%r9d
mov    0xc(%rsp),%r8d
call   1040 <my_mktime@plt>
test   %rbx,%rbx
je     1158 <time+0x38>
mov    %eax,(%rbx)
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
define i32 @time(i32* %0) {
%2 = alloca i32*
%3 = alloca %struct.tm
%4 = alloca i32
store i32* %0, i32** %2
%5 = call i32 @rtc_gettime(%struct.tm* %3)
%6 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 5
%7 = load i32, i32* %6
%8 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 4
%9 = load i32, i32* %8
%10 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 3
%11 = load i32, i32* %10
%12 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 2
%13 = load i32, i32* %12
%14 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 1
%15 = load i32, i32* %14
%16 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 0
%17 = load i32, i32* %16
%18 = call i32 @my_mktime(i32 %7, i32 %9, i32 %11, i32 %13, i32 %15, i32 %17)
store i32 %18, i32* %4
%19 = load i32*, i32** %2
%20 = icmp ne i32* %19, null
br i1 %20, label %21, label %24
21: ; preds = %1
%22 = load i32, i32* %4
%23 = load i32*, i32** %2
store i32 %22, i32* %23
br label %24
24: ; preds = %21, %1
%25 = load i32, i32* %4
ret i32 %25
}

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