#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 */
scalar_t__ ENOTTY;
int /*<<< orphan*/ RTC_AIE_OFF;
int /*<<< orphan*/ RTC_AIE_ON;
int /*<<< orphan*/ RTC_ALM_READ;
int /*<<< orphan*/ RTC_ALM_SET;
int do_read_time(int, struct rtc_time *);
scalar_t__ errno;
int /*<<< orphan*/ exit(scalar_t__);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int ioctl(int, int /*<<< orphan*/, struct rtc_time *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ print_tm(struct rtc_time *);
int /*<<< orphan*/ printf(char *, ...);
int read(int, unsigned long *, int);
int /*<<< orphan*/ stderr;
char *strerror(scalar_t__);
int test_alarm(int fd) {
  struct rtc_time rtc_tm;
  int ret = 0;
  unsigned long data;
  ret = do_read_time(fd, &rtc_tm);
  if (ret) {
    printf("get time failed: %s\n", strerror(errno));
    return ret;
  }
  printf("Now time is: \n");
  print_tm(&rtc_tm);
  rtc_tm.tm_sec += 5;
  if (rtc_tm.tm_sec >= 60) {
    rtc_tm.tm_sec %= 60;
    rtc_tm.tm_min++;
  }
  if (rtc_tm.tm_min == 60) {
    rtc_tm.tm_min = 0;
    rtc_tm.tm_hour++;
  }
  if (rtc_tm.tm_hour == 24)
    rtc_tm.tm_hour = 0;
  ret = ioctl(fd, RTC_ALM_SET, &rtc_tm);
  if (ret == -1) {
    if (errno == ENOTTY) {
      fprintf(stderr, "\n...Alarm IRQs not supported.\n");
      return 0;
    }
    perror("RTC_ALM_SET ioctl");
    exit(errno);
  }
  ret = ioctl(fd, RTC_ALM_READ, &rtc_tm);
  if (ret == -1) {
    perror("RTC_ALM_READ ioctl");
    exit(errno);
  }
  fprintf(stderr, "Alarm time now set to %02d:%02d:%02d.\n", rtc_tm.tm_hour,
          rtc_tm.tm_min, rtc_tm.tm_sec);
  ret = ioctl(fd, RTC_AIE_ON, 0);
  if (ret == -1) {
    perror("RTC_AIE_ON ioctl");
    exit(errno);
  }
  fprintf(stderr, "Waiting 5 seconds for alarm...");
  fflush(stderr);
  ret = read(fd, &data, sizeof(unsigned long));
  if (ret == -1) {
    perror("read");
    exit(errno);
  }
  fprintf(stderr, " okay. Alarm rang.\n");
  ret = ioctl(fd, RTC_AIE_OFF, 0);
  if (ret == -1) {
    perror("RTC_AIE_OFF ioctl");
    exit(errno);
  }
  return 0;
}


x86 assembly (clang, -O0):
<test_alarm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x18(%rbp),%rsi
call   1090 <do_read_time@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     11f6 <test_alarm+0x56>
mov    0x2df6(%rip),%rax
mov    (%rax),%rdi
call   10c0 <strerror@plt>
mov    %rax,%rsi
lea    0xe1c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1430 <test_alarm+0x290>
lea    0xe18(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x18(%rbp),%rdi
call   1070 <print_tm@plt>
mov    -0x18(%rbp),%eax
add    $0x5,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x3c,-0x18(%rbp)
jl     1237 <test_alarm+0x97>
mov    -0x18(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x3c,-0x14(%rbp)
jne    1251 <test_alarm+0xb1>
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x18,-0x10(%rbp)
jne    1262 <test_alarm+0xc2>
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2d74(%rip),%rax
mov    (%rax),%esi
lea    -0x18(%rbp),%rdx
call   1040 <ioctl@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    12dc <test_alarm+0x13c>
mov    0x2d3d(%rip),%rax
mov    (%rax),%rax
mov    0x2d53(%rip),%rcx
cmp    (%rcx),%rax
jne    12c1 <test_alarm+0x121>
mov    0x2d2b(%rip),%rax
mov    (%rax),%edi
lea    0xd76(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1430 <test_alarm+0x290>
lea    0xd7b(%rip),%rdi
call   10a0 <perror@plt>
mov    0x2cf4(%rip),%rax
mov    (%rax),%rdi
call   10b0 <exit@plt>
mov    -0x8(%rbp),%edi
mov    0x2cda(%rip),%rax
mov    (%rax),%esi
lea    -0x18(%rbp),%rdx
call   1040 <ioctl@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    1319 <test_alarm+0x179>
lea    0xd50(%rip),%rdi
call   10a0 <perror@plt>
mov    0x2cb7(%rip),%rax
mov    (%rax),%rdi
call   10b0 <exit@plt>
mov    0x2cb0(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
lea    0xd35(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x8(%rbp),%edi
mov    0x2c64(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
mov    %eax,%edx
call   1040 <ioctl@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    1377 <test_alarm+0x1d7>
lea    0xd2c(%rip),%rdi
call   10a0 <perror@plt>
mov    0x2c59(%rip),%rax
mov    (%rax),%rdi
call   10b0 <exit@plt>
mov    0x2c52(%rip),%rax
mov    (%rax),%edi
lea    0xd19(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2c3b(%rip),%rax
mov    (%rax),%edi
call   1080 <fflush@plt>
mov    -0x8(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    $0x8,%edx
call   1050 <read@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    13d5 <test_alarm+0x235>
lea    0xcfe(%rip),%rdi
call   10a0 <perror@plt>
mov    0x2bfb(%rip),%rax
mov    (%rax),%rdi
call   10b0 <exit@plt>
mov    0x2bf4(%rip),%rax
mov    (%rax),%edi
lea    0xcdf(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x8(%rbp),%edi
mov    0x2bc2(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
mov    %eax,%edx
call   1040 <ioctl@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    1429 <test_alarm+0x289>
lea    0xcc3(%rip),%rdi
call   10a0 <perror@plt>
mov    0x2ba7(%rip),%rax
mov    (%rax),%rdi
call   10b0 <exit@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_alarm>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %edi,%ebp
lea    0x8(%rsp),%rsi
call   10a0 <do_read_time@plt>
mov    %eax,%ebx
test   %eax,%eax
je     11ef <test_alarm+0x3f>
mov    0x2df7(%rip),%rax
mov    (%rax),%rdi
call   10d0 <strerror@plt>
lea    0xe20(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    137b <test_alarm+0x1cb>
lea    0xee5(%rip),%rdi
call   1030 <puts@plt>
lea    0x8(%rsp),%rdi
call   1080 <print_tm@plt>
mov    0x8(%rsp),%ecx
lea    0x5(%rcx),%eax
mov    %eax,0x8(%rsp)
cmp    $0x36,%ecx
jle    1248 <test_alarm+0x98>
mov    %eax,%ecx
mov    $0x88888889,%edx
imul   %rcx,%rdx
shr    $0x25,%rdx
imul   $0x3c,%edx,%ecx
sub    %ecx,%eax
mov    %eax,0x8(%rsp)
mov    0xc(%rsp),%eax
add    $0x1,%eax
mov    %eax,0xc(%rsp)
cmp    $0x3c,%eax
je     1251 <test_alarm+0xa1>
mov    0x10(%rsp),%eax
cmp    $0x18,%eax
je     1269 <test_alarm+0xb9>
jmp    1271 <test_alarm+0xc1>
mov    0xc(%rsp),%eax
cmp    $0x3c,%eax
jne    123d <test_alarm+0x8d>
movl   $0x0,0xc(%rsp)
mov    0x10(%rsp),%eax
add    $0x1,%eax
mov    %eax,0x10(%rsp)
cmp    $0x18,%eax
jne    1271 <test_alarm+0xc1>
movl   $0x0,0x10(%rsp)
mov    0x2d68(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdx
mov    %ebp,%edi
call   1050 <ioctl@plt>
cmp    $0xffffffff,%eax
je     134d <test_alarm+0x19d>
mov    0x2d2a(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdx
mov    %ebp,%edi
call   1050 <ioctl@plt>
cmp    $0xffffffff,%eax
je     1386 <test_alarm+0x1d6>
mov    0x2d1c(%rip),%r14
mov    (%r14),%edi
mov    0x10(%rsp),%edx
mov    0x8(%rsp),%r8d
mov    0xc(%rsp),%ecx
lea    0xd8e(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x2ccf(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
xor    %edx,%edx
call   1050 <ioctl@plt>
cmp    $0xffffffff,%eax
je     138f <test_alarm+0x1df>
mov    (%r14),%edi
lea    0xd9a(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    (%r14),%edi
call   1090 <fflush@plt>
lea    0x18(%rsp),%rsi
mov    %ebp,%edi
mov    $0x8,%edx
call   1060 <read@plt>
cmp    $0xffffffff,%eax
je     1398 <test_alarm+0x1e8>
mov    (%r14),%edi
lea    0xd8f(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x2c84(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
xor    %edx,%edx
call   1050 <ioctl@plt>
cmp    $0xffffffff,%eax
jne    137b <test_alarm+0x1cb>
lea    0xd7e(%rip),%rdi
jmp    139f <test_alarm+0x1ef>
mov    0x2c74(%rip),%rbp
mov    0x0(%rbp),%rax
mov    0x2c89(%rip),%rcx
cmp    (%rcx),%rax
jne    13b3 <test_alarm+0x203>
mov    0x2c65(%rip),%rax
mov    (%rax),%edi
lea    0xca1(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    %ebx,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xcb9(%rip),%rdi
jmp    139f <test_alarm+0x1ef>
lea    0xcea(%rip),%rdi
jmp    139f <test_alarm+0x1ef>
lea    0xd11(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2c1d(%rip),%rax
mov    (%rax),%rdi
call   10c0 <exit@plt>
lea    0xc7a(%rip),%rdi
call   10b0 <perror@plt>
mov    0x0(%rbp),%rdi
call   10c0 <exit@plt>

LLVM IR (-O0):
%struct.rtc_time = type { i32, i32, i32 }
@.str = [21 x i8] c"get time failed: %s\0A\00"
@errno = global i64 0
@.str.1 = [15 x i8] c"Now time is: \0A\00"
@RTC_ALM_SET = global i32 0
@ENOTTY = global i64 0
@stderr = global i32 0
@.str.2 = [31 x i8] c"\0A...Alarm IRQs not supported.\0A\00"
@.str.3 = [18 x i8] c"RTC_ALM_SET ioctl\00"
@RTC_ALM_READ = global i32 0
@.str.4 = [19 x i8] c"RTC_ALM_READ ioctl\00"
@.str.5 = [39 x i8] c"Alarm time now set to %02d:%02d:%02d.\0A\00"
@RTC_AIE_ON = global i32 0
@.str.6 = [17 x i8] c"RTC_AIE_ON ioctl\00"
@.str.7 = [31 x i8] c"Waiting 5 seconds for alarm...\00"
@.str.8 = [5 x i8] c"read\00"
@.str.9 = [20 x i8] c" okay. Alarm rang.\0A\00"
@RTC_AIE_OFF = global i32 0
@.str.10 = [18 x i8] c"RTC_AIE_OFF ioctl\00"
define i32 @test_alarm(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.rtc_time
%5 = alloca i32
%6 = alloca i64
store i32 %0, i32* %3
store i32 0, i32* %5
%7 = load i32, i32* %3
%8 = call i32 @do_read_time(i32 %7, %struct.rtc_time* %4)
store i32 %8, i32* %5
%9 = load i32, i32* %5
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %1
%12 = load i64, i64* @errno
%13 = call i8* @strerror(i64 %12)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = load i32, i32* %5
store i32 %15, i32* %2
br label %118
16: ; preds = %1
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%18 = call i32 @print_tm(%struct.rtc_time* %4)
%19 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %4, i32 0, i32 0
%20 = load i32, i32* %19
%21 = add nsw i32 %20, 5
store i32 %21, i32* %19
%22 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %4, i32 0, i32 0
%23 = load i32, i32* %22
%24 = icmp sge i32 %23, 60
br i1 %24, label %25, label %32
25: ; preds = %16
%26 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %4, i32 0, i32 0
%27 = load i32, i32* %26
%28 = srem i32 %27, 60
store i32 %28, i32* %26
%29 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %4, i32 0, i32 1
%30 = load i32, i32* %29
%31 = add nsw i32 %30, 1
store i32 %31, i32* %29
br label %32
32: ; preds = %25, %16
%33 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %4, i32 0, i32 1
%34 = load i32, i32* %33
%35 = icmp eq i32 %34, 60
br i1 %35, label %36, label %41
36: ; preds = %32
%37 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %4, i32 0, i32 1
store i32 0, i32* %37
%38 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %4, i32 0, i32 2
%39 = load i32, i32* %38
%40 = add nsw i32 %39, 1
store i32 %40, i32* %38
br label %41
41: ; preds = %36, %32
%42 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %4, i32 0, i32 2
%43 = load i32, i32* %42
%44 = icmp eq i32 %43, 24
br i1 %44, label %45, label %47
45: ; preds = %41
%46 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %4, i32 0, i32 2
store i32 0, i32* %46
br label %47
47: ; preds = %45, %41
%48 = load i32, i32* %3
%49 = load i32, i32* @RTC_ALM_SET
%50 = call i32 @ioctl(i32 %48, i32 %49, %struct.rtc_time* %4)
store i32 %50, i32* %5
%51 = load i32, i32* %5
%52 = icmp eq i32 %51, -1
br i1 %52, label %53, label %64
53: ; preds = %47
%54 = load i64, i64* @errno
%55 = load i64, i64* @ENOTTY
%56 = icmp eq i64 %54, %55
br i1 %56, label %57, label %60
57: ; preds = %53
%58 = load i32, i32* @stderr
%59 = call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %2
br label %118
60: ; preds = %53
%61 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%62 = load i64, i64* @errno
%63 = call i32 @exit(i64 %62)
unreachable
64: ; preds = %47
%65 = load i32, i32* %3
%66 = load i32, i32* @RTC_ALM_READ
%67 = call i32 @ioctl(i32 %65, i32 %66, %struct.rtc_time* %4)
store i32 %67, i32* %5
%68 = load i32, i32* %5
%69 = icmp eq i32 %68, -1
br i1 %69, label %70, label %74
70: ; preds = %64
%71 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
%72 = load i64, i64* @errno
%73 = call i32 @exit(i64 %72)
unreachable
74: ; preds = %64
%75 = load i32, i32* @stderr
%76 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %4, i32 0, i32 2
%77 = load i32, i32* %76
%78 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %4, i32 0, i32 1
%79 = load i32, i32* %78
%80 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %4, i32 0, i32 0
%81 = load i32, i32* %80
%82 = call i32 (i32, i8*, ...) @fprintf(i32 %75, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0), i32 %77, i32 %79, i32 %81)
%83 = load i32, i32* %3
%84 = load i32, i32* @RTC_AIE_ON
%85 = call i32 @ioctl(i32 %83, i32 %84, %struct.rtc_time* null)
store i32 %85, i32* %5
%86 = load i32, i32* %5
%87 = icmp eq i32 %86, -1
br i1 %87, label %88, label %92
88: ; preds = %74
%89 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
%90 = load i64, i64* @errno
%91 = call i32 @exit(i64 %90)
unreachable
92: ; preds = %74
%93 = load i32, i32* @stderr
%94 = call i32 (i32, i8*, ...) @fprintf(i32 %93, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0))
%95 = load i32, i32* @stderr
%96 = call i32 @fflush(i32 %95)
%97 = load i32, i32* %3
%98 = call i32 @read(i32 %97, i64* %6, i32 8)
store i32 %98, i32* %5
%99 = load i32, i32* %5
%100 = icmp eq i32 %99, -1
br i1 %100, label %101, label %105
101: ; preds = %92
%102 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%103 = load i64, i64* @errno
%104 = call i32 @exit(i64 %103)
unreachable
105: ; preds = %92
%106 = load i32, i32* @stderr
%107 = call i32 (i32, i8*, ...) @fprintf(i32 %106, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0))
%108 = load i32, i32* %3
%109 = load i32, i32* @RTC_AIE_OFF
%110 = call i32 @ioctl(i32 %108, i32 %109, %struct.rtc_time* null)
store i32 %110, i32* %5
%111 = load i32, i32* %5
%112 = icmp eq i32 %111, -1
br i1 %112, label %113, label %117
113: ; preds = %105
%114 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0))
%115 = load i64, i64* @errno
%116 = call i32 @exit(i64 %115)
unreachable
117: ; preds = %105
store i32 0, i32* %2
br label %118
118: ; preds = %117, %57, %11
%119 = load i32, i32* %2
ret i32 %119
}

LLVM IR (-O2):
%struct.rtc_time = type { i32, i32, i32 }
@.str = [21 x i8] c"get time failed: %s\0A\00"
@errno = global i64 0
@RTC_ALM_SET = global i32 0
@ENOTTY = global i64 0
@stderr = global i32 0
@.str.2 = [31 x i8] c"\0A...Alarm IRQs not supported.\0A\00"
@.str.3 = [18 x i8] c"RTC_ALM_SET ioctl\00"
@RTC_ALM_READ = global i32 0
@.str.4 = [19 x i8] c"RTC_ALM_READ ioctl\00"
@.str.5 = [39 x i8] c"Alarm time now set to %02d:%02d:%02d.\0A\00"
@RTC_AIE_ON = global i32 0
@.str.6 = [17 x i8] c"RTC_AIE_ON ioctl\00"
@.str.7 = [31 x i8] c"Waiting 5 seconds for alarm...\00"
@.str.8 = [5 x i8] c"read\00"
@.str.9 = [20 x i8] c" okay. Alarm rang.\0A\00"
@RTC_AIE_OFF = global i32 0
@.str.10 = [18 x i8] c"RTC_AIE_OFF ioctl\00"
@str = [14 x i8] c"Now time is: \00"
define i32 @test_alarm(i32 %0) {
%2 = alloca %struct.rtc_time
%3 = alloca i64
%4 = bitcast %struct.rtc_time* %2 to i8*
%5 = bitcast i64* %3 to i8*
%6 = call i32 @do_read_time(i32 %0, %struct.rtc_time* %2)
%7 = icmp eq i32 %6, 0
br i1 %7, label %12, label %8
8: ; preds = %1
%9 = load i64, i64* @errno
%10 = call i8* @strerror(i64 %9)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %100
12: ; preds = %1
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
%14 = call i32 @print_tm(%struct.rtc_time* %2)
%15 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %2, i64 0, i32 0
%16 = load i32, i32* %15
%17 = add nsw i32 %16, 5
store i32 %17, i32* %15
%18 = icmp sgt i32 %16, 54
br i1 %18, label %22, label %19
19: ; preds = %12
%20 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %2, i64 0, i32 1
%21 = load i32, i32* %20
br label %27
22: ; preds = %12
%23 = urem i32 %17, 60
store i32 %23, i32* %15
%24 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %2, i64 0, i32 1
%25 = load i32, i32* %24
%26 = add nsw i32 %25, 1
store i32 %26, i32* %24
br label %27
27: ; preds = %19, %22
%28 = phi i32 [ %21, %19 ], [ %26, %22 ]
%29 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %2, i64 0, i32 1
%30 = icmp eq i32 %28, 60
br i1 %30, label %34, label %31
31: ; preds = %27
%32 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %2, i64 0, i32 2
%33 = load i32, i32* %32
br label %38
34: ; preds = %27
store i32 0, i32* %29
%35 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %2, i64 0, i32 2
%36 = load i32, i32* %35
%37 = add nsw i32 %36, 1
store i32 %37, i32* %35
br label %38
38: ; preds = %31, %34
%39 = phi i32 [ %33, %31 ], [ %37, %34 ]
%40 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %2, i64 0, i32 2
%41 = icmp eq i32 %39, 24
br i1 %41, label %42, label %43
42: ; preds = %38
store i32 0, i32* %40
br label %43
43: ; preds = %42, %38
%44 = load i32, i32* @RTC_ALM_SET
%45 = call i32 @ioctl(i32 %0, i32 %44, %struct.rtc_time* %2)
%46 = icmp eq i32 %45, -1
br i1 %46, label %47, label %58
47: ; preds = %43
%48 = load i64, i64* @errno
%49 = load i64, i64* @ENOTTY
%50 = icmp eq i64 %48, %49
br i1 %50, label %51, label %54
51: ; preds = %47
%52 = load i32, i32* @stderr
%53 = call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
br label %100
54: ; preds = %47
%55 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%56 = load i64, i64* @errno
%57 = call i32 @exit(i64 %56)
unreachable
58: ; preds = %43
%59 = load i32, i32* @RTC_ALM_READ
%60 = call i32 @ioctl(i32 %0, i32 %59, %struct.rtc_time* %2)
%61 = icmp eq i32 %60, -1
br i1 %61, label %62, label %66
62: ; preds = %58
%63 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
%64 = load i64, i64* @errno
%65 = call i32 @exit(i64 %64)
unreachable
66: ; preds = %58
%67 = load i32, i32* @stderr
%68 = load i32, i32* %40
%69 = load i32, i32* %29
%70 = load i32, i32* %15
%71 = call i32 (i32, i8*, ...) @fprintf(i32 %67, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0), i32 %68, i32 %69, i32 %70)
%72 = load i32, i32* @RTC_AIE_ON
%73 = call i32 @ioctl(i32 %0, i32 %72, %struct.rtc_time* null)
%74 = icmp eq i32 %73, -1
br i1 %74, label %75, label %79
75: ; preds = %66
%76 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
%77 = load i64, i64* @errno
%78 = call i32 @exit(i64 %77)
unreachable
79: ; preds = %66
%80 = load i32, i32* @stderr
%81 = call i32 (i32, i8*, ...) @fprintf(i32 %80, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0))
%82 = load i32, i32* @stderr
%83 = call i32 @fflush(i32 %82)
%84 = call i32 @read(i32 %0, i64* %3, i32 8)
%85 = icmp eq i32 %84, -1
br i1 %85, label %86, label %90
86: ; preds = %79
%87 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%88 = load i64, i64* @errno
%89 = call i32 @exit(i64 %88)
unreachable
90: ; preds = %79
%91 = load i32, i32* @stderr
%92 = call i32 (i32, i8*, ...) @fprintf(i32 %91, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0))
%93 = load i32, i32* @RTC_AIE_OFF
%94 = call i32 @ioctl(i32 %0, i32 %93, %struct.rtc_time* null)
%95 = icmp eq i32 %94, -1
br i1 %95, label %96, label %100
96: ; preds = %90
%97 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0))
%98 = load i64, i64* @errno
%99 = call i32 @exit(i64 %98)
unreachable
100: ; preds = %90, %51, %8
ret i32 %6
}