#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 */
struct rtc_time {
  int tm_sec;
  int tm_min;
  int tm_hour;
};

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ RTC_RD_TIME;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int ioctl(int, int /*<<< orphan*/, struct rtc_time *);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int, int, int);
int main(int argc, char *argv[]) {
  int retval, fd;
  struct rtc_time rtc_tm;
  fd = open("/dev/rtc", O_RDONLY);
  if (fd == -1) {
    perror("error open /dev/rtc");
    exit(EXIT_FAILURE);
  }
  retval = ioctl(fd, RTC_RD_TIME, &rtc_tm);
  if (retval == -1) {
    perror("error RTC_RD_TIME ioctl");
    exit(EXIT_FAILURE);
  }
  printf("sec=%d,min=%d,hour=%d\n", rtc_tm.tm_sec, rtc_tm.tm_min,
         rtc_tm.tm_hour);
  close(fd);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e6b(%rip),%rax
mov    (%rax),%esi
lea    0xe85(%rip),%rdi
call   1060 <open@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    11b2 <main+0x52>
lea    0xe61(%rip),%rdi
call   1070 <perror@plt>
mov    0x2e2d(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x18(%rbp),%edi
mov    0x2e04(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdx
call   1040 <ioctl@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    11ee <main+0x8e>
lea    0xe39(%rip),%rdi
call   1070 <perror@plt>
mov    0x2df1(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x28(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x20(%rbp),%ecx
lea    0xe2e(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%edi
call   1050 <close@plt>
mov    0x2dbe(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    0x2e7c(%rip),%rax
mov    (%rax),%esi
lea    0xe96(%rip),%rdi
call   1060 <open@plt>
cmp    $0xffffffff,%eax
jne    1188 <main+0x28>
lea    0xe7a(%rip),%rdi
jmp    11a9 <main+0x49>
mov    %eax,%ebx
mov    0x2e2f(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdx
mov    %ebx,%edi
call   1040 <ioctl@plt>
cmp    $0xffffffff,%eax
jne    11bc <main+0x5c>
lea    0xe6b(%rip),%rdi
call   1070 <perror@plt>
mov    0x2e23(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    (%rsp),%esi
mov    0x4(%rsp),%edx
mov    0x8(%rsp),%ecx
lea    0xe5e(%rip),%rdi
call   1030 <printf@plt>
mov    %ebx,%edi
call   1050 <close@plt>
mov    0x2def(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.rtc_time = type { i32, i32, i32 }
@.str = [9 x i8] c"/dev/rtc\00"
@O_RDONLY = global i32 0
@.str.1 = [20 x i8] c"error open /dev/rtc\00"
@EXIT_FAILURE = global i32 0
@RTC_RD_TIME = global i32 0
@.str.2 = [24 x i8] c"error RTC_RD_TIME ioctl\00"
@.str.3 = [23 x i8] c"sec=%d,min=%d,hour=%d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.rtc_time
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* @O_RDONLY
%10 = call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %9)
store i32 %10, i32* %7
%11 = load i32, i32* %7
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %17
13: ; preds = %2
%14 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%15 = load i32, i32* @EXIT_FAILURE
%16 = call i32 @exit(i32 %15)
unreachable
17: ; preds = %2
%18 = load i32, i32* %7
%19 = load i32, i32* @RTC_RD_TIME
%20 = call i32 @ioctl(i32 %18, i32 %19, %struct.rtc_time* %8)
store i32 %20, i32* %6
%21 = load i32, i32* %6
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %27
23: ; preds = %17
%24 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%25 = load i32, i32* @EXIT_FAILURE
%26 = call i32 @exit(i32 %25)
unreachable
27: ; preds = %17
%28 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %8, i32 0, i32 0
%29 = load i32, i32* %28
%30 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %8, i32 0, i32 1
%31 = load i32, i32* %30
%32 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %8, i32 0, i32 2
%33 = load i32, i32* %32
%34 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %29, i32 %31, i32 %33)
%35 = load i32, i32* %7
%36 = call i32 @close(i32 %35)
%37 = load i32, i32* @EXIT_SUCCESS
%38 = call i32 @exit(i32 %37)
unreachable
}

LLVM IR (-O2):
%struct.rtc_time = type { i32, i32, i32 }
@.str = [9 x i8] c"/dev/rtc\00"
@O_RDONLY = global i32 0
@.str.1 = [20 x i8] c"error open /dev/rtc\00"
@EXIT_FAILURE = global i32 0
@RTC_RD_TIME = global i32 0
@.str.2 = [24 x i8] c"error RTC_RD_TIME ioctl\00"
@.str.3 = [23 x i8] c"sec=%d,min=%d,hour=%d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.rtc_time
%4 = bitcast %struct.rtc_time* %3 to i8*
%5 = load i32, i32* @O_RDONLY
%6 = tail call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = tail call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %2
%13 = load i32, i32* @RTC_RD_TIME
%14 = call i32 @ioctl(i32 %6, i32 %13, %struct.rtc_time* %3)
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %20
16: ; preds = %12
%17 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%18 = load i32, i32* @EXIT_FAILURE
%19 = call i32 @exit(i32 %18)
unreachable
20: ; preds = %12
%21 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %3, i64 0, i32 0
%22 = load i32, i32* %21
%23 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %3, i64 0, i32 1
%24 = load i32, i32* %23
%25 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %3, i64 0, i32 2
%26 = load i32, i32* %25
%27 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %22, i32 %24, i32 %26)
%28 = call i32 @close(i32 %6)
%29 = load i32, i32* @EXIT_SUCCESS
%30 = call i32 @exit(i32 %29)
unreachable
}