#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 */
int errno;
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int get_current_time(int *hour, int *min, int *sec) {
  time_t time_since_epoch;
  struct tm *time_vals;
  int ret_err;
  time(&time_since_epoch);
  time_vals = localtime(&time_since_epoch);
  if (time_vals != NULL) {
    if (hour != NULL)
      *hour = time_vals->tm_hour;
    if (min != NULL)
      *min = time_vals->tm_min;
    if (sec != NULL)
      *sec = time_vals->tm_sec;
    ret_err = 0;
  } else
    ret_err = errno;
  return (ret_err);
}


x86 assembly (clang, -O0):
<get_current_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x1c(%rbp),%rdi
call   1040 <time@plt>
lea    -0x1c(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11a8 <get_current_time+0x88>
cmpq   $0x0,-0x8(%rbp)
je     116c <get_current_time+0x4c>
mov    -0x28(%rbp),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
cmpq   $0x0,-0x10(%rbp)
je     1184 <get_current_time+0x64>
mov    -0x28(%rbp),%rax
mov    0x4(%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
cmpq   $0x0,-0x18(%rbp)
je     119c <get_current_time+0x7c>
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x2c(%rbp)
jmp    11b4 <get_current_time+0x94>
mov    0x2e31(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_current_time>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
lea    0x4(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <time@plt>
mov    %rbx,%rdi
call   1030 <localtime@plt>
test   %rax,%rax
je     1170 <get_current_time+0x50>
test   %r12,%r12
je     1156 <get_current_time+0x36>
mov    (%rax),%ecx
mov    %ecx,(%r12)
test   %r15,%r15
je     1161 <get_current_time+0x41>
mov    0x4(%rax),%ecx
mov    %ecx,(%r15)
xor    %ecx,%ecx
test   %r14,%r14
je     1179 <get_current_time+0x59>
mov    0x8(%rax),%eax
mov    %eax,(%r14)
jmp    1179 <get_current_time+0x59>
mov    0x2e69(%rip),%rax
mov    (%rax),%ecx
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32 }
@errno = global i32 0
define i32 @get_current_time(i32* %0, i32* %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca %struct.tm*
%9 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%10 = call i32 @time(i32* %7)
%11 = call %struct.tm* @localtime(i32* %7)
store %struct.tm* %11, %struct.tm** %8
%12 = load %struct.tm*, %struct.tm** %8
%13 = icmp ne %struct.tm* %12, null
br i1 %13, label %14, label %39
14: ; preds = %3
%15 = load i32*, i32** %4
%16 = icmp ne i32* %15, null
br i1 %16, label %17, label %22
17: ; preds = %14
%18 = load %struct.tm*, %struct.tm** %8
%19 = getelementptr inbounds %struct.tm, %struct.tm* %18, i32 0, i32 0
%20 = load i32, i32* %19
%21 = load i32*, i32** %4
store i32 %20, i32* %21
br label %22
22: ; preds = %17, %14
%23 = load i32*, i32** %5
%24 = icmp ne i32* %23, null
br i1 %24, label %25, label %30
25: ; preds = %22
%26 = load %struct.tm*, %struct.tm** %8
%27 = getelementptr inbounds %struct.tm, %struct.tm* %26, i32 0, i32 1
%28 = load i32, i32* %27
%29 = load i32*, i32** %5
store i32 %28, i32* %29
br label %30
30: ; preds = %25, %22
%31 = load i32*, i32** %6
%32 = icmp ne i32* %31, null
br i1 %32, label %33, label %38
33: ; preds = %30
%34 = load %struct.tm*, %struct.tm** %8
%35 = getelementptr inbounds %struct.tm, %struct.tm* %34, i32 0, i32 2
%36 = load i32, i32* %35
%37 = load i32*, i32** %6
store i32 %36, i32* %37
br label %38
38: ; preds = %33, %30
store i32 0, i32* %9
br label %41
39: ; preds = %3
%40 = load i32, i32* @errno
store i32 %40, i32* %9
br label %41
41: ; preds = %39, %38
%42 = load i32, i32* %9
ret i32 %42
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32 }
@errno = global i32 0
define i32 @get_current_time(i32* writeonly %0, i32* writeonly %1, i32* writeonly %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
%6 = call i32 @time(i32* %4)
%7 = call %struct.tm* @localtime(i32* %4)
%8 = icmp eq %struct.tm* %7, null
br i1 %8, label %24, label %9
9: ; preds = %3
%10 = icmp eq i32* %0, null
br i1 %10, label %14, label %11
11: ; preds = %9
%12 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 0
%13 = load i32, i32* %12
store i32 %13, i32* %0
br label %14
14: ; preds = %11, %9
%15 = icmp eq i32* %1, null
br i1 %15, label %19, label %16
16: ; preds = %14
%17 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 1
%18 = load i32, i32* %17
store i32 %18, i32* %1
br label %19
19: ; preds = %16, %14
%20 = icmp eq i32* %2, null
br i1 %20, label %26, label %21
21: ; preds = %19
%22 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 2
%23 = load i32, i32* %22
store i32 %23, i32* %2
br label %26
24: ; preds = %3
%25 = load i32, i32* @errno
br label %26
26: ; preds = %19, %21, %24
%27 = phi i32 [ %25, %24 ], [ 0, %21 ], [ 0, %19 ]
ret i32 %27
}