#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_hour;
  int tm_min;
  int tm_sec;
};

/* Variables and functions */
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void gettim(int *hour, int *minute, int *second, int *hsec) {
  time_t time_val;
  struct tm *now;
  time_val = time(NULL);
  now = localtime((time_t *)&time_val);
  *hour = now->tm_hour;
  *minute = now->tm_min;
  *second = now->tm_sec;
  *hsec = 0;
}


x86 assembly (clang, -O0):
<gettim>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,-0x24(%rbp)
lea    -0x24(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x30(%rbp),%rax
mov    0x4(%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x30(%rbp),%rax
mov    0x8(%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gettim>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1030 <localtime@plt>
mov    (%rax),%ecx
mov    %ecx,(%rbx)
mov    0x4(%rax),%ecx
mov    %ecx,(%r12)
mov    0x8(%rax),%eax
mov    %eax,(%r15)
movl   $0x0,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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