#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;
};

/* Variables and functions */
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
struct tm *rtc_get_time();
int /*<<< orphan*/ stderr;
int stime(int /*<<< orphan*/ *);
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ timegm(struct tm *);
int rtc_hctosys() {
  struct tm *t = rtc_get_time();
  time_t s = timegm(t);
  int r = stime(&s);
  if (r != 0) {
    fprintf(stderr, "rtc_hctosys error: %s\n", strerror(errno));
  }
  return r;
}


x86 assembly (clang, -O0):
<rtc_hctosys>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1060 <rtc_get_time@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <timegm@plt>
mov    %eax,-0xc(%rbp)
lea    -0xc(%rbp),%rdi
call   1030 <stime@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     11b1 <rtc_hctosys+0x61>
mov    0x2e54(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    0x2e40(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x14(%rbp),%edi
mov    %rax,%rdx
lea    0xe54(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rtc_hctosys>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1060 <rtc_get_time@plt>
mov    %rax,%rdi
call   1050 <timegm@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1030 <stime@plt>
mov    %eax,%ebx
test   %eax,%eax
je     119e <rtc_hctosys+0x4e>
mov    0x2e63(%rip),%rax
mov    (%rax),%ebp
mov    0x2e52(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xe6c(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
call   1040 <fprintf@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@stderr = global i32 0
@.str = [23 x i8] c"rtc_hctosys error: %s\0A\00"
@errno = global i32 0
define i32 @rtc_hctosys() {
%1 = alloca %struct.tm*
%2 = alloca i32
%3 = alloca i32
%4 = call %struct.tm* (...) @rtc_get_time()
store %struct.tm* %4, %struct.tm** %1
%5 = load %struct.tm*, %struct.tm** %1
%6 = call i32 @timegm(%struct.tm* %5)
store i32 %6, i32* %2
%7 = call i32 @stime(i32* %2)
store i32 %7, i32* %3
%8 = load i32, i32* %3
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %0
%11 = load i32, i32* @stderr
%12 = load i32, i32* @errno
%13 = call i8* @strerror(i32 %12)
%14 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %13)
br label %15
15: ; preds = %10, %0
%16 = load i32, i32* %3
ret i32 %16
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@stderr = global i32 0
@.str = [23 x i8] c"rtc_hctosys error: %s\0A\00"
@errno = global i32 0
define i32 @rtc_hctosys() {
%1 = alloca i32
%2 = tail call %struct.tm* (...) @rtc_get_time()
%3 = bitcast i32* %1 to i8*
%4 = tail call i32 @timegm(%struct.tm* %2)
store i32 %4, i32* %1
%5 = call i32 @stime(i32* %1)
%6 = icmp eq i32 %5, 0
br i1 %6, label %12, label %7
7: ; preds = %0
%8 = load i32, i32* @stderr
%9 = load i32, i32* @errno
%10 = call i8* @strerror(i32 %9)
%11 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %12
12: ; preds = %7, %0
ret i32 %5
}