#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 time_t;
struct rtc_time {
  int tm_mday;
  int tm_mon;
  int tm_year;
  int tm_hour;
  int tm_min;
  int tm_sec;
};
typedef int /*<<< orphan*/ data;

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ RTC_AIE_OFF;
int /*<<< orphan*/ RTC_AIE_ON;
int /*<<< orphan*/ RTC_ALM_READ;
int /*<<< orphan*/ RTC_ALM_SET;
int /*<<< orphan*/ RTC_RD_TIME;
int /*<<< orphan*/ RTC_SET_TIME;
int /*<<< orphan*/ RTC_UIE_OFF;
int /*<<< orphan*/ RTC_UIE_ON;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int ioctl(int, int /*<<< orphan*/, struct rtc_time *);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int read(int, unsigned long *, int);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  int rtc_fd;
  unsigned long data;
  int ret, i;
  struct rtc_time rtc_tm;
  char *rtc_dev = "/dev/rtc0";
  time_t t1, t2;
  if (argc > 1)
    rtc_dev = argv[1];
  printf("====== RTC Test  ====\n");
  printf("0. open and release\n");
  rtc_fd = open(rtc_dev, O_RDONLY);
  if (rtc_fd == -1) {
    printf("failed to open '%s': %s\n", rtc_dev, strerror(errno));
    exit(1);
  } else
    printf("opened '%s': fd = %d\n", rtc_dev, rtc_fd);
  printf("1. ioctl RTC_UIE_ON\n");
  ret = ioctl(rtc_fd, RTC_UIE_ON, 0);
  if (ret == -1) {
    perror("rtc ioctl RTC_UIE_ON error");
  }
  printf("2. RTC read 5 times\n");
  for (i = 1; i < 6; i++) {
    ret = read(rtc_fd, &data, sizeof(data));
    if (ret == -1) {
      perror("rtc read error");
    }
    printf("RTC read %d\n", i);
  }
  printf("3. ioctl RTC_UIE_OFF\n");
  ret = ioctl(rtc_fd, RTC_UIE_OFF, 0);
  if (ret == -1) {
    perror("rtc ioctl RTC_UIE_OFF error");
  }
  printf("4. Get RTC Time\n");
  ret = ioctl(rtc_fd, RTC_RD_TIME, &rtc_tm);
  if (ret == -1) {
    perror("rtc ioctl RTC_RD_TIME error");
  }
  printf("Current RTC date/time is %d-%d-%d, %02d:%02d:%02d\n", rtc_tm.tm_mday,
         rtc_tm.tm_mon + 1, rtc_tm.tm_year, rtc_tm.tm_hour, rtc_tm.tm_min,
         rtc_tm.tm_sec);
  rtc_tm.tm_mday = 31;
  rtc_tm.tm_mon = 4;
  rtc_tm.tm_year = 104;
  rtc_tm.tm_hour = 2;
  rtc_tm.tm_min = 30;
  rtc_tm.tm_sec = 0;
  printf("5. Set RTC Time\n");
  ret = ioctl(rtc_fd, RTC_SET_TIME, &rtc_tm);
  if (ret == -1) {
    perror("rtc ioctl RTC_SET_TIME error");
  }
  printf("Set Current RTC date/time to %d-%d-%d, %02d:%02d:%02d\n",
         rtc_tm.tm_mday, rtc_tm.tm_mon + 1, rtc_tm.tm_year, rtc_tm.tm_hour,
         rtc_tm.tm_min, rtc_tm.tm_sec);
  printf("Get RTC time\n");
  ret = ioctl(rtc_fd, RTC_RD_TIME, &rtc_tm);
  if (ret == -1) {
    perror("rtc ioctl RTC_RD_TIME error");
  }
  printf("Current RTC date/time is %d-%d-%d, %02d:%02d:%02d\n", rtc_tm.tm_mday,
         rtc_tm.tm_mon + 1, rtc_tm.tm_year, rtc_tm.tm_hour, rtc_tm.tm_min,
         rtc_tm.tm_sec);
  rtc_tm.tm_sec += 50;
  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;
  printf("6. Set alarm Time\n");
  ret = ioctl(rtc_fd, RTC_ALM_SET, &rtc_tm);
  if (ret == -1) {
    perror("rtc ioctl RTC_ALM_SET error");
  }
  printf("7. Get alarm Time\n");
  ret = ioctl(rtc_fd, RTC_ALM_READ, &rtc_tm);
  if (ret == -1) {
    perror("rtc ioctl RTC_ALM_READ error");
  }
  t1 = time(NULL);
  printf("Alarm time now set to %02d:%02d:%02d\n", rtc_tm.tm_hour,
         rtc_tm.tm_min, rtc_tm.tm_sec);
  ret = ioctl(rtc_fd, RTC_AIE_ON, 0);
  if (ret == -1) {
    perror("rtc ioctl RTC_ALE_ON error");
  }
  printf("Waiting 50 seconds for alarm...\n");
  ret = read(rtc_fd, &data, sizeof(data));
  if (ret == -1) {
    perror("rtc read error");
  }
  t2 = time(NULL);
  if (t2 - t1 < 40)
    fprintf(stderr,
            " Fail!  Alarm rang too fast ... took %i seconds instead of 50!\n",
            (int)(t2 - t1));
  else
    printf(" Okay. Alarm rang.\n");
  ret = ioctl(rtc_fd, RTC_RD_TIME, &rtc_tm);
  if (ret == -1) {
    perror("rtc ioctl RTC_RD_TIME error");
  }
  printf("Current RTC date/time is %d-%d-%d, %02d:%02d:%02d\n", rtc_tm.tm_mday,
         rtc_tm.tm_mon + 1, rtc_tm.tm_year, rtc_tm.tm_hour, rtc_tm.tm_min,
         rtc_tm.tm_sec);
  printf("8. ioctl RTC_AIE_OFF\n");
  ret = ioctl(rtc_fd, RTC_AIE_OFF, 0);
  if (ret == -1) {
    perror("ioctl RTC_ALE_OFF error");
  }
  printf("8.5 test sleep 10\n");
  sleep(10);
  ret = ioctl(rtc_fd, RTC_RD_TIME, &rtc_tm);
  if (ret == -1) {
    perror("rtc ioctl RTC_RD_TIME error");
  }
  printf("Current RTC date/time is %d-%d-%d, %02d:%02d:%02d\n", rtc_tm.tm_mday,
         rtc_tm.tm_mon + 1, rtc_tm.tm_year, rtc_tm.tm_hour, rtc_tm.tm_min,
         rtc_tm.tm_sec);
  ret = ioctl(rtc_fd, RTC_RD_TIME, &rtc_tm);
  if (ret == -1) {
    perror("rtc ioctl RTC_RD_TIME error");
  }
  printf("Current RTC date/time is %d-%d-%d, %02d:%02d:%02d\n", rtc_tm.tm_mday,
         rtc_tm.tm_mon + 1, rtc_tm.tm_year, rtc_tm.tm_hour, rtc_tm.tm_min,
         rtc_tm.tm_sec);
  printf("RTC Tests done !!\n");
  close(rtc_fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe33(%rip),%rax
mov    %rax,-0x48(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    11e7 <main+0x37>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x48(%rbp)
lea    0xe1c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x48(%rbp),%rdi
mov    0x2dda(%rip),%rax
mov    (%rax),%esi
call   1090 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    1257 <main+0xa7>
mov    -0x48(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    0x2d87(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    -0x58(%rbp),%rsi
mov    %rax,%rdx
lea    0xdf0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x48(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    0xdea(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdf2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
mov    0x2d5c(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
mov    %eax,%edx
call   1040 <ioctl@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    12a8 <main+0xf8>
lea    0xdd7(%rip),%rdi
call   10a0 <perror@plt>
lea    0xde6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x28(%rbp)
cmpl   $0x6,-0x28(%rbp)
jge    1310 <main+0x160>
mov    -0x14(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0x8,%edx
call   1060 <read@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    12f1 <main+0x141>
lea    0xdbe(%rip),%rdi
call   10a0 <perror@plt>
mov    -0x28(%rbp),%esi
lea    0xdbe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    12bd <main+0x10d>
lea    0xdaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
mov    0x2c78(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
mov    %eax,%edx
call   1040 <ioctl@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    134c <main+0x19c>
lea    0xd95(%rip),%rdi
call   10a0 <perror@plt>
lea    0xda5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
mov    0x2c24(%rip),%rax
mov    (%rax),%esi
lea    -0x40(%rbp),%rdx
call   1040 <ioctl@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    1388 <main+0x1d8>
lea    0xd86(%rip),%rdi
call   10a0 <perror@plt>
mov    -0x40(%rbp),%esi
mov    -0x3c(%rbp),%edx
add    $0x1,%edx
mov    -0x38(%rbp),%ecx
mov    -0x34(%rbp),%r8d
mov    -0x30(%rbp),%r9d
mov    -0x2c(%rbp),%eax
lea    0xd7f(%rip),%rdi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1f,-0x40(%rbp)
movl   $0x4,-0x3c(%rbp)
movl   $0x68,-0x38(%rbp)
movl   $0x2,-0x34(%rbp)
movl   $0x1e,-0x30(%rbp)
movl   $0x0,-0x2c(%rbp)
lea    0xd77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
mov    0x2bde(%rip),%rax
mov    (%rax),%esi
lea    -0x40(%rbp),%rdx
call   1040 <ioctl@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    1416 <main+0x266>
lea    0xd58(%rip),%rdi
call   10a0 <perror@plt>
mov    -0x40(%rbp),%esi
mov    -0x3c(%rbp),%edx
add    $0x1,%edx
mov    -0x38(%rbp),%ecx
mov    -0x34(%rbp),%r8d
mov    -0x30(%rbp),%r9d
mov    -0x2c(%rbp),%eax
lea    0xd52(%rip),%rdi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd78(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
mov    0x2b32(%rip),%rax
mov    (%rax),%esi
lea    -0x40(%rbp),%rdx
call   1040 <ioctl@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    147a <main+0x2ca>
lea    0xc94(%rip),%rdi
call   10a0 <perror@plt>
mov    -0x40(%rbp),%esi
mov    -0x3c(%rbp),%edx
add    $0x1,%edx
mov    -0x38(%rbp),%ecx
mov    -0x34(%rbp),%r8d
mov    -0x30(%rbp),%r9d
mov    -0x2c(%rbp),%eax
lea    0xc8d(%rip),%rdi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x32,%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0x3c,-0x2c(%rbp)
jl     14cc <main+0x31c>
mov    -0x2c(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %edx,-0x2c(%rbp)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
cmpl   $0x3c,-0x30(%rbp)
jne    14e6 <main+0x336>
movl   $0x0,-0x30(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
cmpl   $0x18,-0x34(%rbp)
jne    14f7 <main+0x347>
movl   $0x0,-0x34(%rbp)
lea    0xccd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
mov    0x2ac9(%rip),%rax
mov    (%rax),%esi
lea    -0x40(%rbp),%rdx
call   1040 <ioctl@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    1533 <main+0x383>
lea    0xcb0(%rip),%rdi
call   10a0 <perror@plt>
lea    0xcc0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
mov    0x2a65(%rip),%rax
mov    (%rax),%esi
lea    -0x40(%rbp),%rdx
call   1040 <ioctl@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    156f <main+0x3bf>
lea    0xca3(%rip),%rdi
call   10a0 <perror@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1080 <time@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x34(%rbp),%esi
mov    -0x30(%rbp),%edx
mov    -0x2c(%rbp),%ecx
lea    0xc9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
mov    0x29f4(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
mov    %eax,%edx
call   1040 <ioctl@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    15c0 <main+0x410>
lea    0xc95(%rip),%rdi
call   10a0 <perror@plt>
lea    0xca4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0x8,%edx
call   1060 <read@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    15f8 <main+0x448>
lea    0xab7(%rip),%rdi
call   10a0 <perror@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1080 <time@plt>
mov    %eax,-0x50(%rbp)
mov    -0x50(%rbp),%eax
sub    -0x4c(%rbp),%eax
cmp    $0x28,%eax
jge    1633 <main+0x483>
mov    0x29a6(%rip),%rax
mov    (%rax),%edi
mov    -0x50(%rbp),%edx
sub    -0x4c(%rbp),%edx
lea    0xc63(%rip),%rsi
call   1070 <fprintf@plt>
jmp    1641 <main+0x491>
lea    0xc92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
mov    0x293d(%rip),%rax
mov    (%rax),%esi
lea    -0x40(%rbp),%rdx
call   1040 <ioctl@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    166f <main+0x4bf>
lea    0xa9f(%rip),%rdi
call   10a0 <perror@plt>
mov    -0x40(%rbp),%esi
mov    -0x3c(%rbp),%edx
add    $0x1,%edx
mov    -0x38(%rbp),%ecx
mov    -0x34(%rbp),%r8d
mov    -0x30(%rbp),%r9d
mov    -0x2c(%rbp),%eax
lea    0xa98(%rip),%rdi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xc42(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
mov    0x28f9(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
mov    %eax,%edx
call   1040 <ioctl@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    16d3 <main+0x523>
lea    0xc28(%rip),%rdi
call   10a0 <perror@plt>
lea    0xc34(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0xa,%edi
call   10d0 <sleep@plt>
mov    -0x14(%rbp),%edi
mov    0x2893(%rip),%rax
mov    (%rax),%esi
lea    -0x40(%rbp),%rdx
call   1040 <ioctl@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    1719 <main+0x569>
lea    0x9f5(%rip),%rdi
call   10a0 <perror@plt>
mov    -0x40(%rbp),%esi
mov    -0x3c(%rbp),%edx
add    $0x1,%edx
mov    -0x38(%rbp),%ecx
mov    -0x34(%rbp),%r8d
mov    -0x30(%rbp),%r9d
mov    -0x2c(%rbp),%eax
lea    0x9ee(%rip),%rdi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
mov    0x283d(%rip),%rax
mov    (%rax),%esi
lea    -0x40(%rbp),%rdx
call   1040 <ioctl@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    176f <main+0x5bf>
lea    0x99f(%rip),%rdi
call   10a0 <perror@plt>
mov    -0x40(%rbp),%esi
mov    -0x3c(%rbp),%edx
add    $0x1,%edx
mov    -0x38(%rbp),%ecx
mov    -0x34(%rbp),%r8d
mov    -0x30(%rbp),%r9d
mov    -0x2c(%rbp),%eax
lea    0x998(%rip),%rdi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xb83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
call   1050 <close@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
cmp    $0x2,%edi
jl     11d3 <main+0x13>
mov    0x8(%rsi),%rbp
jmp    11da <main+0x1a>
lea    0xe36(%rip),%rbp
lea    0x1030(%rip),%rdi
call   1030 <puts@plt>
lea    0x103a(%rip),%rdi
call   1030 <puts@plt>
mov    0x2def(%rip),%rax
mov    (%rax),%esi
mov    %rbp,%rdi
call   10a0 <open@plt>
cmp    $0xffffffff,%eax
je     182a <main+0x66a>
mov    %eax,%ebx
lea    0xe1e(%rip),%rdi
mov    %rbp,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x1013(%rip),%rdi
call   1030 <puts@plt>
mov    0x2dac(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
xor    %edx,%edx
call   1050 <ioctl@plt>
cmp    $0xffffffff,%eax
je     16f8 <main+0x538>
lea    0x1000(%rip),%rdi
call   1030 <puts@plt>
lea    0x28(%rsp),%rsi
mov    %ebx,%edi
mov    $0x8,%edx
call   1070 <read@plt>
cmp    $0xffffffff,%eax
je     1709 <main+0x549>
lea    0xdfe(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x28(%rsp),%rsi
mov    %ebx,%edi
mov    $0x8,%edx
call   1070 <read@plt>
cmp    $0xffffffff,%eax
je     171a <main+0x55a>
lea    0xdd1(%rip),%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x28(%rsp),%rsi
mov    %ebx,%edi
mov    $0x8,%edx
call   1070 <read@plt>
cmp    $0xffffffff,%eax
je     172b <main+0x56b>
lea    0xda4(%rip),%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x28(%rsp),%rsi
mov    %ebx,%edi
mov    $0x8,%edx
call   1070 <read@plt>
cmp    $0xffffffff,%eax
je     173c <main+0x57c>
lea    0xd77(%rip),%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x28(%rsp),%rsi
mov    %ebx,%edi
mov    $0x8,%edx
call   1070 <read@plt>
cmp    $0xffffffff,%eax
je     174d <main+0x58d>
lea    0xd4a(%rip),%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf27(%rip),%rdi
call   1030 <puts@plt>
mov    0x2c58(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
xor    %edx,%edx
call   1050 <ioctl@plt>
cmp    $0xffffffff,%eax
je     175e <main+0x59e>
lea    0xf15(%rip),%rdi
call   1030 <puts@plt>
mov    0x2c19(%rip),%r14
mov    (%r14),%esi
lea    0x10(%rsp),%rdx
mov    %ebx,%edi
call   1050 <ioctl@plt>
cmp    $0xffffffff,%eax
je     176f <main+0x5af>
mov    0x10(%rsp),%esi
mov    0x14(%rsp),%edx
add    $0x1,%edx
mov    0x18(%rsp),%ecx
mov    0x1c(%rsp),%r8d
mov    0x20(%rsp),%r9d
mov    0x24(%rsp),%eax
mov    %eax,(%rsp)
lea    0xd0a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movaps 0xc44(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movq   $0x1e,0x20(%rsp)
lea    0xeb7(%rip),%rdi
call   1030 <puts@plt>
mov    0x2bf3(%rip),%rax
mov    (%rax),%esi
lea    0x10(%rsp),%rdx
mov    %ebx,%edi
call   1050 <ioctl@plt>
cmp    $0xffffffff,%eax
je     1780 <main+0x5c0>
mov    0x10(%rsp),%esi
mov    0x14(%rsp),%edx
add    $0x1,%edx
mov    0x18(%rsp),%ecx
mov    0x1c(%rsp),%r8d
mov    0x20(%rsp),%r9d
mov    0x24(%rsp),%eax
mov    %eax,(%rsp)
lea    0xced(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe6f(%rip),%rdi
call   1030 <puts@plt>
mov    (%r14),%esi
lea    0x10(%rsp),%rdx
mov    %ebx,%edi
call   1050 <ioctl@plt>
cmp    $0xffffffff,%eax
je     1791 <main+0x5d1>
mov    0x10(%rsp),%esi
mov    0x14(%rsp),%edx
add    $0x1,%edx
mov    0x18(%rsp),%ecx
mov    0x1c(%rsp),%r8d
mov    0x20(%rsp),%r9d
mov    0x24(%rsp),%eax
mov    %eax,(%rsp)
lea    0xc4b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x24(%rsp),%ecx
lea    0x32(%rcx),%eax
mov    %eax,0x24(%rsp)
cmp    $0xa,%ecx
jl     14b7 <main+0x2f7>
mov    %eax,%ecx
mov    $0x88888889,%edx
imul   %rcx,%rdx
shr    $0x25,%rdx
imul   $0x3c,%edx,%ecx
sub    %ecx,%eax
mov    %eax,0x24(%rsp)
mov    0x20(%rsp),%eax
add    $0x1,%eax
mov    %eax,0x20(%rsp)
cmp    $0x3c,%eax
je     14c0 <main+0x300>
mov    0x1c(%rsp),%eax
cmp    $0x18,%eax
je     14d8 <main+0x318>
jmp    14e0 <main+0x320>
mov    0x20(%rsp),%eax
cmp    $0x3c,%eax
jne    14ac <main+0x2ec>
movl   $0x0,0x20(%rsp)
mov    0x1c(%rsp),%eax
add    $0x1,%eax
mov    %eax,0x1c(%rsp)
cmp    $0x18,%eax
jne    14e0 <main+0x320>
movl   $0x0,0x1c(%rsp)
lea    0xdbe(%rip),%rdi
call   1030 <puts@plt>
mov    0x2ae5(%rip),%rax
mov    (%rax),%esi
lea    0x10(%rsp),%rdx
mov    %ebx,%edi
call   1050 <ioctl@plt>
cmp    $0xffffffff,%eax
je     17a2 <main+0x5e2>
lea    0xda6(%rip),%rdi
call   1030 <puts@plt>
mov    0x2a93(%rip),%rax
mov    (%rax),%esi
lea    0x10(%rsp),%rdx
mov    %ebx,%edi
call   1050 <ioctl@plt>
cmp    $0xffffffff,%eax
je     17b3 <main+0x5f3>
xor    %edi,%edi
call   1090 <time@plt>
mov    %eax,%ebp
mov    0x1c(%rsp),%esi
mov    0x20(%rsp),%edx
mov    0x24(%rsp),%ecx
lea    0xc28(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2a32(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
xor    %edx,%edx
call   1050 <ioctl@plt>
cmp    $0xffffffff,%eax
je     17c4 <main+0x604>
lea    0xd50(%rip),%rdi
call   1030 <puts@plt>
lea    0x28(%rsp),%rsi
mov    %ebx,%edi
mov    $0x8,%edx
call   1070 <read@plt>
cmp    $0xffffffff,%eax
je     17d5 <main+0x615>
xor    %edi,%edi
call   1090 <time@plt>
sub    %ebp,%eax
cmp    $0x27,%eax
jg     15bf <main+0x3ff>
mov    0x2a13(%rip),%rcx
mov    (%rcx),%edi
lea    0xc03(%rip),%rsi
mov    %eax,%edx
call   1080 <fprintf@plt>
jmp    15cb <main+0x40b>
lea    0xd23(%rip),%rdi
call   1030 <puts@plt>
mov    (%r14),%esi
lea    0x10(%rsp),%rdx
mov    %ebx,%edi
call   1050 <ioctl@plt>
cmp    $0xffffffff,%eax
je     17e6 <main+0x626>
mov    0x10(%rsp),%esi
mov    0x14(%rsp),%edx
add    $0x1,%edx
mov    0x18(%rsp),%ecx
mov    0x1c(%rsp),%r8d
mov    0x20(%rsp),%r9d
mov    0x24(%rsp),%eax
mov    %eax,(%rsp)
lea    0xaae(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xce4(%rip),%rdi
call   1030 <puts@plt>
mov    0x2984(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
xor    %edx,%edx
call   1050 <ioctl@plt>
cmp    $0xffffffff,%eax
je     17f7 <main+0x637>
lea    0xcd2(%rip),%rdi
call   1030 <puts@plt>
mov    $0xa,%edi
call   10e0 <sleep@plt>
mov    (%r14),%esi
lea    0x10(%rsp),%rdx
mov    %ebx,%edi
call   1050 <ioctl@plt>
cmp    $0xffffffff,%eax
je     1808 <main+0x648>
mov    0x10(%rsp),%esi
mov    0x14(%rsp),%edx
add    $0x1,%edx
mov    0x18(%rsp),%ecx
mov    0x1c(%rsp),%r8d
mov    0x20(%rsp),%r9d
mov    0x24(%rsp),%eax
mov    %eax,(%rsp)
lea    0xa2b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%r14),%esi
lea    0x10(%rsp),%rdx
mov    %ebx,%edi
call   1050 <ioctl@plt>
cmp    $0xffffffff,%eax
je     1819 <main+0x659>
mov    0x10(%rsp),%esi
mov    0x14(%rsp),%edx
add    $0x1,%edx
mov    0x18(%rsp),%ecx
mov    0x1c(%rsp),%r8d
mov    0x20(%rsp),%r9d
mov    0x24(%rsp),%eax
mov    %eax,(%rsp)
lea    0x9e5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xc42(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%edi
call   1060 <close@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0x94a(%rip),%rdi
call   10b0 <perror@plt>
jmp    1248 <main+0x88>
lea    0x954(%rip),%rdi
call   10b0 <perror@plt>
jmp    126e <main+0xae>
lea    0x943(%rip),%rdi
call   10b0 <perror@plt>
jmp    129b <main+0xdb>
lea    0x932(%rip),%rdi
call   10b0 <perror@plt>
jmp    12c8 <main+0x108>
lea    0x921(%rip),%rdi
call   10b0 <perror@plt>
jmp    12f5 <main+0x135>
lea    0x910(%rip),%rdi
call   10b0 <perror@plt>
jmp    1322 <main+0x162>
lea    0x91b(%rip),%rdi
call   10b0 <perror@plt>
jmp    135c <main+0x19c>
lea    0x926(%rip),%rdi
call   10b0 <perror@plt>
jmp    1387 <main+0x1c7>
lea    0x964(%rip),%rdi
call   10b0 <perror@plt>
jmp    13f4 <main+0x234>
lea    0x904(%rip),%rdi
call   10b0 <perror@plt>
jmp    1446 <main+0x286>
lea    0x996(%rip),%rdi
call   10b0 <perror@plt>
jmp    150a <main+0x34a>
lea    0x9a1(%rip),%rdi
call   10b0 <perror@plt>
jmp    1534 <main+0x374>
lea    0x9d3(%rip),%rdi
call   10b0 <perror@plt>
jmp    1572 <main+0x3b2>
lea    0x888(%rip),%rdi
call   10b0 <perror@plt>
jmp    1598 <main+0x3d8>
lea    0x8af(%rip),%rdi
call   10b0 <perror@plt>
jmp    15e3 <main+0x423>
lea    0x9fb(%rip),%rdi
call   10b0 <perror@plt>
jmp    1638 <main+0x478>
lea    0x88d(%rip),%rdi
call   10b0 <perror@plt>
jmp    1666 <main+0x4a6>
lea    0x87c(%rip),%rdi
call   10b0 <perror@plt>
jmp    16ac <main+0x4ec>
mov    0x2787(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0x7db(%rip),%rdi
mov    %rbp,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
%struct.rtc_time = type { i32, i32, i32, i32, i32, i32 }
@.str = [10 x i8] c"/dev/rtc0\00"
@.str.1 = [23 x i8] c"====== RTC Test ====\0A\00"
@.str.2 = [21 x i8] c"0. open and release\0A\00"
@O_RDONLY = global i32 0
@.str.3 = [25 x i8] c"failed to open '%s': %s\0A\00"
@errno = global i32 0
@.str.4 = [22 x i8] c"opened '%s': fd = %d\0A\00"
@.str.5 = [21 x i8] c"1. ioctl RTC_UIE_ON\0A\00"
@RTC_UIE_ON = global i32 0
@.str.6 = [27 x i8] c"rtc ioctl RTC_UIE_ON error\00"
@.str.7 = [21 x i8] c"2. RTC read 5 times\0A\00"
@.str.8 = [15 x i8] c"rtc read error\00"
@.str.9 = [13 x i8] c"RTC read %d\0A\00"
@.str.10 = [22 x i8] c"3. ioctl RTC_UIE_OFF\0A\00"
@RTC_UIE_OFF = global i32 0
@.str.11 = [28 x i8] c"rtc ioctl RTC_UIE_OFF error\00"
@.str.12 = [17 x i8] c"4. Get RTC Time\0A\00"
@RTC_RD_TIME = global i32 0
@.str.13 = [28 x i8] c"rtc ioctl RTC_RD_TIME error\00"
@.str.14 = [51 x i8] c"Current RTC date/time is %d-%d-%d, %02d:%02d:%02d\0A\00"
@.str.15 = [17 x i8] c"5. Set RTC Time\0A\00"
@RTC_SET_TIME = global i32 0
@.str.16 = [29 x i8] c"rtc ioctl RTC_SET_TIME error\00"
@.str.17 = [55 x i8] c"Set Current RTC date/time to %d-%d-%d, %02d:%02d:%02d\0A\00"
@.str.18 = [14 x i8] c"Get RTC time\0A\00"
@.str.19 = [19 x i8] c"6. Set alarm Time\0A\00"
@RTC_ALM_SET = global i32 0
@.str.20 = [28 x i8] c"rtc ioctl RTC_ALM_SET error\00"
@.str.21 = [19 x i8] c"7. Get alarm Time\0A\00"
@RTC_ALM_READ = global i32 0
@.str.22 = [29 x i8] c"rtc ioctl RTC_ALM_READ error\00"
@.str.23 = [38 x i8] c"Alarm time now set to %02d:%02d:%02d\0A\00"
@RTC_AIE_ON = global i32 0
@.str.24 = [27 x i8] c"rtc ioctl RTC_ALE_ON error\00"
@.str.25 = [33 x i8] c"Waiting 50 seconds for alarm...\0A\00"
@stderr = global i32 0
@.str.26 = [64 x i8] c" Fail! Alarm rang too fast ... took %i seconds instead of 50!\0A\00"
@.str.27 = [20 x i8] c" Okay. Alarm rang.\0A\00"
@.str.28 = [22 x i8] c"8. ioctl RTC_AIE_OFF\0A\00"
@RTC_AIE_OFF = global i32 0
@.str.29 = [24 x i8] c"ioctl RTC_ALE_OFF error\00"
@.str.30 = [19 x i8] c"8.5 test sleep 10\0A\00"
@.str.31 = [19 x i8] c"RTC Tests done !!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
%10 = alloca %struct.rtc_time
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %11
%14 = load i32, i32* %4
%15 = icmp sgt i32 %14, 1
br i1 %15, label %16, label %20
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
store i8* %19, i8** %11
br label %20
20: ; preds = %16, %2
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%23 = load i8*, i8** %11
%24 = load i32, i32* @O_RDONLY
%25 = call i32 @open(i8* %23, i32 %24)
store i32 %25, i32* %6
%26 = load i32, i32* %6
%27 = icmp eq i32 %26, -1
br i1 %27, label %28, label %34
28: ; preds = %20
%29 = load i8*, i8** %11
%30 = load i32, i32* @errno
%31 = call i8* @strerror(i32 %30)
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8* %29, i8* %31)
%33 = call i32 @exit(i32 1)
unreachable
34: ; preds = %20
%35 = load i8*, i8** %11
%36 = load i32, i32* %6
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %35, i32 %36)
br label %38
38: ; preds = %34
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
%40 = load i32, i32* %6
%41 = load i32, i32* @RTC_UIE_ON
%42 = call i32 @ioctl(i32 %40, i32 %41, %struct.rtc_time* null)
store i32 %42, i32* %8
%43 = load i32, i32* %8
%44 = icmp eq i32 %43, -1
br i1 %44, label %45, label %47
45: ; preds = %38
%46 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0))
br label %47
47: ; preds = %45, %38
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
store i32 1, i32* %9
br label %49
49: ; preds = %62, %47
%50 = load i32, i32* %9
%51 = icmp slt i32 %50, 6
br i1 %51, label %52, label %65
52: ; preds = %49
%53 = load i32, i32* %6
%54 = call i32 @read(i32 %53, i64* %7, i32 8)
store i32 %54, i32* %8
%55 = load i32, i32* %8
%56 = icmp eq i32 %55, -1
br i1 %56, label %57, label %59
57: ; preds = %52
%58 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
br label %59
59: ; preds = %57, %52
%60 = load i32, i32* %9
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0), i32 %60)
br label %62
62: ; preds = %59
%63 = load i32, i32* %9
%64 = add nsw i32 %63, 1
store i32 %64, i32* %9
br label %49
65: ; preds = %49
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.10, i64 0, i64 0))
%67 = load i32, i32* %6
%68 = load i32, i32* @RTC_UIE_OFF
%69 = call i32 @ioctl(i32 %67, i32 %68, %struct.rtc_time* null)
store i32 %69, i32* %8
%70 = load i32, i32* %8
%71 = icmp eq i32 %70, -1
br i1 %71, label %72, label %74
72: ; preds = %65
%73 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.11, i64 0, i64 0))
br label %74
74: ; preds = %72, %65
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.12, i64 0, i64 0))
%76 = load i32, i32* %6
%77 = load i32, i32* @RTC_RD_TIME
%78 = call i32 @ioctl(i32 %76, i32 %77, %struct.rtc_time* %10)
store i32 %78, i32* %8
%79 = load i32, i32* %8
%80 = icmp eq i32 %79, -1
br i1 %80, label %81, label %83
81: ; preds = %74
%82 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.13, i64 0, i64 0))
br label %83
83: ; preds = %81, %74
%84 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 0
%85 = load i32, i32* %84
%86 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 1
%87 = load i32, i32* %86
%88 = add nsw i32 %87, 1
%89 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 2
%90 = load i32, i32* %89
%91 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 3
%92 = load i32, i32* %91
%93 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 4
%94 = load i32, i32* %93
%95 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 5
%96 = load i32, i32* %95
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.14, i64 0, i64 0), i32 %85, i32 %88, i32 %90, i32 %92, i32 %94, i32 %96)
%98 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 0
store i32 31, i32* %98
%99 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 1
store i32 4, i32* %99
%100 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 2
store i32 104, i32* %100
%101 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 3
store i32 2, i32* %101
%102 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 4
store i32 30, i32* %102
%103 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 5
store i32 0, i32* %103
%104 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.15, i64 0, i64 0))
%105 = load i32, i32* %6
%106 = load i32, i32* @RTC_SET_TIME
%107 = call i32 @ioctl(i32 %105, i32 %106, %struct.rtc_time* %10)
store i32 %107, i32* %8
%108 = load i32, i32* %8
%109 = icmp eq i32 %108, -1
br i1 %109, label %110, label %112
110: ; preds = %83
%111 = call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.16, i64 0, i64 0))
br label %112
112: ; preds = %110, %83
%113 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 0
%114 = load i32, i32* %113
%115 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 1
%116 = load i32, i32* %115
%117 = add nsw i32 %116, 1
%118 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 2
%119 = load i32, i32* %118
%120 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 3
%121 = load i32, i32* %120
%122 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 4
%123 = load i32, i32* %122
%124 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 5
%125 = load i32, i32* %124
%126 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.17, i64 0, i64 0), i32 %114, i32 %117, i32 %119, i32 %121, i32 %123, i32 %125)
%127 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.18, i64 0, i64 0))
%128 = load i32, i32* %6
%129 = load i32, i32* @RTC_RD_TIME
%130 = call i32 @ioctl(i32 %128, i32 %129, %struct.rtc_time* %10)
store i32 %130, i32* %8
%131 = load i32, i32* %8
%132 = icmp eq i32 %131, -1
br i1 %132, label %133, label %135
133: ; preds = %112
%134 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.13, i64 0, i64 0))
br label %135
135: ; preds = %133, %112
%136 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 0
%137 = load i32, i32* %136
%138 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 1
%139 = load i32, i32* %138
%140 = add nsw i32 %139, 1
%141 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 2
%142 = load i32, i32* %141
%143 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 3
%144 = load i32, i32* %143
%145 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 4
%146 = load i32, i32* %145
%147 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 5
%148 = load i32, i32* %147
%149 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.14, i64 0, i64 0), i32 %137, i32 %140, i32 %142, i32 %144, i32 %146, i32 %148)
%150 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 5
%151 = load i32, i32* %150
%152 = add nsw i32 %151, 50
store i32 %152, i32* %150
%153 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 5
%154 = load i32, i32* %153
%155 = icmp sge i32 %154, 60
br i1 %155, label %156, label %163
156: ; preds = %135
%157 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 5
%158 = load i32, i32* %157
%159 = srem i32 %158, 60
store i32 %159, i32* %157
%160 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 4
%161 = load i32, i32* %160
%162 = add nsw i32 %161, 1
store i32 %162, i32* %160
br label %163
163: ; preds = %156, %135
%164 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 4
%165 = load i32, i32* %164
%166 = icmp eq i32 %165, 60
br i1 %166, label %167, label %172
167: ; preds = %163
%168 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 4
store i32 0, i32* %168
%169 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 3
%170 = load i32, i32* %169
%171 = add nsw i32 %170, 1
store i32 %171, i32* %169
br label %172
172: ; preds = %167, %163
%173 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 3
%174 = load i32, i32* %173
%175 = icmp eq i32 %174, 24
br i1 %175, label %176, label %178
176: ; preds = %172
%177 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 3
store i32 0, i32* %177
br label %178
178: ; preds = %176, %172
%179 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.19, i64 0, i64 0))
%180 = load i32, i32* %6
%181 = load i32, i32* @RTC_ALM_SET
%182 = call i32 @ioctl(i32 %180, i32 %181, %struct.rtc_time* %10)
store i32 %182, i32* %8
%183 = load i32, i32* %8
%184 = icmp eq i32 %183, -1
br i1 %184, label %185, label %187
185: ; preds = %178
%186 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.20, i64 0, i64 0))
br label %187
187: ; preds = %185, %178
%188 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.21, i64 0, i64 0))
%189 = load i32, i32* %6
%190 = load i32, i32* @RTC_ALM_READ
%191 = call i32 @ioctl(i32 %189, i32 %190, %struct.rtc_time* %10)
store i32 %191, i32* %8
%192 = load i32, i32* %8
%193 = icmp eq i32 %192, -1
br i1 %193, label %194, label %196
194: ; preds = %187
%195 = call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.22, i64 0, i64 0))
br label %196
196: ; preds = %194, %187
%197 = call i32 @time(i32* null)
store i32 %197, i32* %12
%198 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 3
%199 = load i32, i32* %198
%200 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 4
%201 = load i32, i32* %200
%202 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 5
%203 = load i32, i32* %202
%204 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.23, i64 0, i64 0), i32 %199, i32 %201, i32 %203)
%205 = load i32, i32* %6
%206 = load i32, i32* @RTC_AIE_ON
%207 = call i32 @ioctl(i32 %205, i32 %206, %struct.rtc_time* null)
store i32 %207, i32* %8
%208 = load i32, i32* %8
%209 = icmp eq i32 %208, -1
br i1 %209, label %210, label %212
210: ; preds = %196
%211 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.24, i64 0, i64 0))
br label %212
212: ; preds = %210, %196
%213 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.25, i64 0, i64 0))
%214 = load i32, i32* %6
%215 = call i32 @read(i32 %214, i64* %7, i32 8)
store i32 %215, i32* %8
%216 = load i32, i32* %8
%217 = icmp eq i32 %216, -1
br i1 %217, label %218, label %220
218: ; preds = %212
%219 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
br label %220
220: ; preds = %218, %212
%221 = call i32 @time(i32* null)
store i32 %221, i32* %13
%222 = load i32, i32* %13
%223 = load i32, i32* %12
%224 = sub nsw i32 %222, %223
%225 = icmp slt i32 %224, 40
br i1 %225, label %226, label %232
226: ; preds = %220
%227 = load i32, i32* @stderr
%228 = load i32, i32* %13
%229 = load i32, i32* %12
%230 = sub nsw i32 %228, %229
%231 = call i32 @fprintf(i32 %227, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.26, i64 0, i64 0), i32 %230)
br label %234
232: ; preds = %220
%233 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.27, i64 0, i64 0))
br label %234
234: ; preds = %232, %226
%235 = load i32, i32* %6
%236 = load i32, i32* @RTC_RD_TIME
%237 = call i32 @ioctl(i32 %235, i32 %236, %struct.rtc_time* %10)
store i32 %237, i32* %8
%238 = load i32, i32* %8
%239 = icmp eq i32 %238, -1
br i1 %239, label %240, label %242
240: ; preds = %234
%241 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.13, i64 0, i64 0))
br label %242
242: ; preds = %240, %234
%243 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 0
%244 = load i32, i32* %243
%245 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 1
%246 = load i32, i32* %245
%247 = add nsw i32 %246, 1
%248 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 2
%249 = load i32, i32* %248
%250 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 3
%251 = load i32, i32* %250
%252 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 4
%253 = load i32, i32* %252
%254 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 5
%255 = load i32, i32* %254
%256 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.14, i64 0, i64 0), i32 %244, i32 %247, i32 %249, i32 %251, i32 %253, i32 %255)
%257 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.28, i64 0, i64 0))
%258 = load i32, i32* %6
%259 = load i32, i32* @RTC_AIE_OFF
%260 = call i32 @ioctl(i32 %258, i32 %259, %struct.rtc_time* null)
store i32 %260, i32* %8
%261 = load i32, i32* %8
%262 = icmp eq i32 %261, -1
br i1 %262, label %263, label %265
263: ; preds = %242
%264 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.29, i64 0, i64 0))
br label %265
265: ; preds = %263, %242
%266 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.30, i64 0, i64 0))
%267 = call i32 @sleep(i32 10)
%268 = load i32, i32* %6
%269 = load i32, i32* @RTC_RD_TIME
%270 = call i32 @ioctl(i32 %268, i32 %269, %struct.rtc_time* %10)
store i32 %270, i32* %8
%271 = load i32, i32* %8
%272 = icmp eq i32 %271, -1
br i1 %272, label %273, label %275
273: ; preds = %265
%274 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.13, i64 0, i64 0))
br label %275
275: ; preds = %273, %265
%276 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 0
%277 = load i32, i32* %276
%278 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 1
%279 = load i32, i32* %278
%280 = add nsw i32 %279, 1
%281 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 2
%282 = load i32, i32* %281
%283 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 3
%284 = load i32, i32* %283
%285 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 4
%286 = load i32, i32* %285
%287 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 5
%288 = load i32, i32* %287
%289 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.14, i64 0, i64 0), i32 %277, i32 %280, i32 %282, i32 %284, i32 %286, i32 %288)
%290 = load i32, i32* %6
%291 = load i32, i32* @RTC_RD_TIME
%292 = call i32 @ioctl(i32 %290, i32 %291, %struct.rtc_time* %10)
store i32 %292, i32* %8
%293 = load i32, i32* %8
%294 = icmp eq i32 %293, -1
br i1 %294, label %295, label %297
295: ; preds = %275
%296 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.13, i64 0, i64 0))
br label %297
297: ; preds = %295, %275
%298 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 0
%299 = load i32, i32* %298
%300 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 1
%301 = load i32, i32* %300
%302 = add nsw i32 %301, 1
%303 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 2
%304 = load i32, i32* %303
%305 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 3
%306 = load i32, i32* %305
%307 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 4
%308 = load i32, i32* %307
%309 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %10, i32 0, i32 5
%310 = load i32, i32* %309
%311 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.14, i64 0, i64 0), i32 %299, i32 %302, i32 %304, i32 %306, i32 %308, i32 %310)
%312 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.31, i64 0, i64 0))
%313 = load i32, i32* %6
%314 = call i32 @close(i32 %313)
ret i32 0
}

LLVM IR (-O2):
%struct.rtc_time = type { i32, i32, i32, i32, i32, i32 }
@.str = [10 x i8] c"/dev/rtc0\00"
@O_RDONLY = global i32 0
@.str.3 = [25 x i8] c"failed to open '%s': %s\0A\00"
@errno = global i32 0
@.str.4 = [22 x i8] c"opened '%s': fd = %d\0A\00"
@RTC_UIE_ON = global i32 0
@.str.6 = [27 x i8] c"rtc ioctl RTC_UIE_ON error\00"
@.str.8 = [15 x i8] c"rtc read error\00"
@.str.9 = [13 x i8] c"RTC read %d\0A\00"
@RTC_UIE_OFF = global i32 0
@.str.11 = [28 x i8] c"rtc ioctl RTC_UIE_OFF error\00"
@RTC_RD_TIME = global i32 0
@.str.13 = [28 x i8] c"rtc ioctl RTC_RD_TIME error\00"
@.str.14 = [51 x i8] c"Current RTC date/time is %d-%d-%d, %02d:%02d:%02d\0A\00"
@RTC_SET_TIME = global i32 0
@.str.16 = [29 x i8] c"rtc ioctl RTC_SET_TIME error\00"
@.str.17 = [55 x i8] c"Set Current RTC date/time to %d-%d-%d, %02d:%02d:%02d\0A\00"
@RTC_ALM_SET = global i32 0
@.str.20 = [28 x i8] c"rtc ioctl RTC_ALM_SET error\00"
@RTC_ALM_READ = global i32 0
@.str.22 = [29 x i8] c"rtc ioctl RTC_ALM_READ error\00"
@.str.23 = [38 x i8] c"Alarm time now set to %02d:%02d:%02d\0A\00"
@RTC_AIE_ON = global i32 0
@.str.24 = [27 x i8] c"rtc ioctl RTC_ALE_ON error\00"
@stderr = global i32 0
@.str.26 = [64 x i8] c" Fail! Alarm rang too fast ... took %i seconds instead of 50!\0A\00"
@RTC_AIE_OFF = global i32 0
@.str.29 = [24 x i8] c"ioctl RTC_ALE_OFF error\00"
@str = [22 x i8] c"====== RTC Test ====\00"
@str.32 = [20 x i8] c"0. open and release\00"
@str.33 = [20 x i8] c"1. ioctl RTC_UIE_ON\00"
@str.34 = [20 x i8] c"2. RTC read 5 times\00"
@str.35 = [21 x i8] c"3. ioctl RTC_UIE_OFF\00"
@str.36 = [16 x i8] c"4. Get RTC Time\00"
@str.37 = [16 x i8] c"5. Set RTC Time\00"
@str.38 = [13 x i8] c"Get RTC time\00"
@str.39 = [18 x i8] c"6. Set alarm Time\00"
@str.40 = [18 x i8] c"7. Get alarm Time\00"
@str.41 = [32 x i8] c"Waiting 50 seconds for alarm...\00"
@str.42 = [19 x i8] c" Okay. Alarm rang.\00"
@str.43 = [21 x i8] c"8. ioctl RTC_AIE_OFF\00"
@str.44 = [18 x i8] c"8.5 test sleep 10\00"
@str.45 = [18 x i8] c"RTC Tests done !!\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i64
%4 = alloca %struct.rtc_time
%5 = bitcast i64* %3 to i8*
%6 = bitcast %struct.rtc_time* %4 to i8*
%7 = icmp sgt i32 %0, 1
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
br label %11
11: ; preds = %8, %2
%12 = phi i8* [ %10, %8 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), %2 ]
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.32, i64 0, i64 0))
%15 = load i32, i32* @O_RDONLY
%16 = tail call i32 @open(i8* %12, i32 %15)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %23
18: ; preds = %11
%19 = load i32, i32* @errno
%20 = tail call i8* @strerror(i32 %19)
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8* %12, i8* %20)
%22 = tail call i32 @exit(i32 1)
unreachable
23: ; preds = %11
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %12, i32 %16)
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.33, i64 0, i64 0))
%26 = load i32, i32* @RTC_UIE_ON
%27 = tail call i32 @ioctl(i32 %16, i32 %26, %struct.rtc_time* null)
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %31
29: ; preds = %23
%30 = tail call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0))
br label %31
31: ; preds = %29, %23
%32 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.34, i64 0, i64 0))
%33 = call i32 @read(i32 %16, i64* %3, i32 8)
%34 = icmp eq i32 %33, -1
br i1 %34, label %35, label %37
35: ; preds = %31
%36 = tail call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
br label %37
37: ; preds = %35, %31
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0), i32 1)
%39 = call i32 @read(i32 %16, i64* %3, i32 8)
%40 = icmp eq i32 %39, -1
br i1 %40, label %41, label %43
41: ; preds = %37
%42 = tail call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
br label %43
43: ; preds = %41, %37
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0), i32 2)
%45 = call i32 @read(i32 %16, i64* %3, i32 8)
%46 = icmp eq i32 %45, -1
br i1 %46, label %47, label %49
47: ; preds = %43
%48 = tail call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
br label %49
49: ; preds = %47, %43
%50 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0), i32 3)
%51 = call i32 @read(i32 %16, i64* %3, i32 8)
%52 = icmp eq i32 %51, -1
br i1 %52, label %53, label %55
53: ; preds = %49
%54 = tail call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
br label %55
55: ; preds = %53, %49
%56 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0), i32 4)
%57 = call i32 @read(i32 %16, i64* %3, i32 8)
%58 = icmp eq i32 %57, -1
br i1 %58, label %59, label %61
59: ; preds = %55
%60 = tail call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
br label %61
61: ; preds = %59, %55
%62 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0), i32 5)
%63 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.35, i64 0, i64 0))
%64 = load i32, i32* @RTC_UIE_OFF
%65 = tail call i32 @ioctl(i32 %16, i32 %64, %struct.rtc_time* null)
%66 = icmp eq i32 %65, -1
br i1 %66, label %67, label %69
67: ; preds = %61
%68 = tail call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.11, i64 0, i64 0))
br label %69
69: ; preds = %67, %61
%70 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.36, i64 0, i64 0))
%71 = load i32, i32* @RTC_RD_TIME
%72 = call i32 @ioctl(i32 %16, i32 %71, %struct.rtc_time* %4)
%73 = icmp eq i32 %72, -1
br i1 %73, label %74, label %76
74: ; preds = %69
%75 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.13, i64 0, i64 0))
br label %76
76: ; preds = %74, %69
%77 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %4, i64 0, i32 0
%78 = load i32, i32* %77
%79 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %4, i64 0, i32 1
%80 = load i32, i32* %79
%81 = add nsw i32 %80, 1
%82 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %4, i64 0, i32 2
%83 = load i32, i32* %82
%84 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %4, i64 0, i32 3
%85 = load i32, i32* %84
%86 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %4, i64 0, i32 4
%87 = load i32, i32* %86
%88 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %4, i64 0, i32 5
%89 = load i32, i32* %88
%90 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.14, i64 0, i64 0), i32 %78, i32 %81, i32 %83, i32 %85, i32 %87, i32 %89)
%91 = bitcast %struct.rtc_time* %4 to <4 x i32>*
store <4 x i32> <i32 31, i32 4, i32 104, i32 2>, <4 x i32>* %91
store i32 30, i32* %86
store i32 0, i32* %88
%92 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.37, i64 0, i64 0))
%93 = load i32, i32* @RTC_SET_TIME
%94 = call i32 @ioctl(i32 %16, i32 %93, %struct.rtc_time* %4)
%95 = icmp eq i32 %94, -1
br i1 %95, label %96, label %98
96: ; preds = %76
%97 = call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.16, i64 0, i64 0))
br label %98
98: ; preds = %96, %76
%99 = load i32, i32* %77
%100 = load i32, i32* %79
%101 = add nsw i32 %100, 1
%102 = load i32, i32* %82
%103 = load i32, i32* %84
%104 = load i32, i32* %86
%105 = load i32, i32* %88
%106 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.17, i64 0, i64 0), i32 %99, i32 %101, i32 %102, i32 %103, i32 %104, i32 %105)
%107 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.38, i64 0, i64 0))
%108 = load i32, i32* @RTC_RD_TIME
%109 = call i32 @ioctl(i32 %16, i32 %108, %struct.rtc_time* %4)
%110 = icmp eq i32 %109, -1
br i1 %110, label %111, label %113
111: ; preds = %98
%112 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.13, i64 0, i64 0))
br label %113
113: ; preds = %111, %98
%114 = load i32, i32* %77
%115 = load i32, i32* %79
%116 = add nsw i32 %115, 1
%117 = load i32, i32* %82
%118 = load i32, i32* %84
%119 = load i32, i32* %86
%120 = load i32, i32* %88
%121 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.14, i64 0, i64 0), i32 %114, i32 %116, i32 %117, i32 %118, i32 %119, i32 %120)
%122 = load i32, i32* %88
%123 = add nsw i32 %122, 50
store i32 %123, i32* %88
%124 = icmp sgt i32 %122, 9
br i1 %124, label %125, label %129
125: ; preds = %113
%126 = urem i32 %123, 60
store i32 %126, i32* %88
%127 = load i32, i32* %86
%128 = add nsw i32 %127, 1
store i32 %128, i32* %86
br label %131
129: ; preds = %113
%130 = load i32, i32* %86
br label %131
131: ; preds = %129, %125
%132 = phi i32 [ %130, %129 ], [ %128, %125 ]
%133 = icmp eq i32 %132, 60
br i1 %133, label %134, label %137
134: ; preds = %131
store i32 0, i32* %86
%135 = load i32, i32* %84
%136 = add nsw i32 %135, 1
store i32 %136, i32* %84
br label %139
137: ; preds = %131
%138 = load i32, i32* %84
br label %139
139: ; preds = %137, %134
%140 = phi i32 [ %138, %137 ], [ %136, %134 ]
%141 = icmp eq i32 %140, 24
br i1 %141, label %142, label %143
142: ; preds = %139
store i32 0, i32* %84
br label %143
143: ; preds = %142, %139
%144 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.39, i64 0, i64 0))
%145 = load i32, i32* @RTC_ALM_SET
%146 = call i32 @ioctl(i32 %16, i32 %145, %struct.rtc_time* %4)
%147 = icmp eq i32 %146, -1
br i1 %147, label %148, label %150
148: ; preds = %143
%149 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.20, i64 0, i64 0))
br label %150
150: ; preds = %148, %143
%151 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.40, i64 0, i64 0))
%152 = load i32, i32* @RTC_ALM_READ
%153 = call i32 @ioctl(i32 %16, i32 %152, %struct.rtc_time* %4)
%154 = icmp eq i32 %153, -1
br i1 %154, label %155, label %157
155: ; preds = %150
%156 = call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.22, i64 0, i64 0))
br label %157
157: ; preds = %155, %150
%158 = call i32 @time(i32* null)
%159 = load i32, i32* %84
%160 = load i32, i32* %86
%161 = load i32, i32* %88
%162 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.23, i64 0, i64 0), i32 %159, i32 %160, i32 %161)
%163 = load i32, i32* @RTC_AIE_ON
%164 = call i32 @ioctl(i32 %16, i32 %163, %struct.rtc_time* null)
%165 = icmp eq i32 %164, -1
br i1 %165, label %166, label %168
166: ; preds = %157
%167 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.24, i64 0, i64 0))
br label %168
168: ; preds = %166, %157
%169 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.41, i64 0, i64 0))
%170 = call i32 @read(i32 %16, i64* %3, i32 8)
%171 = icmp eq i32 %170, -1
br i1 %171, label %172, label %174
172: ; preds = %168
%173 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
br label %174
174: ; preds = %172, %168
%175 = call i32 @time(i32* null)
%176 = sub nsw i32 %175, %158
%177 = icmp slt i32 %176, 40
br i1 %177, label %178, label %181
178: ; preds = %174
%179 = load i32, i32* @stderr
%180 = call i32 @fprintf(i32 %179, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.26, i64 0, i64 0), i32 %176)
br label %183
181: ; preds = %174
%182 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.42, i64 0, i64 0))
br label %183
183: ; preds = %181, %178
%184 = load i32, i32* @RTC_RD_TIME
%185 = call i32 @ioctl(i32 %16, i32 %184, %struct.rtc_time* %4)
%186 = icmp eq i32 %185, -1
br i1 %186, label %187, label %189
187: ; preds = %183
%188 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.13, i64 0, i64 0))
br label %189
189: ; preds = %187, %183
%190 = load i32, i32* %77
%191 = load i32, i32* %79
%192 = add nsw i32 %191, 1
%193 = load i32, i32* %82
%194 = load i32, i32* %84
%195 = load i32, i32* %86
%196 = load i32, i32* %88
%197 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.14, i64 0, i64 0), i32 %190, i32 %192, i32 %193, i32 %194, i32 %195, i32 %196)
%198 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.43, i64 0, i64 0))
%199 = load i32, i32* @RTC_AIE_OFF
%200 = call i32 @ioctl(i32 %16, i32 %199, %struct.rtc_time* null)
%201 = icmp eq i32 %200, -1
br i1 %201, label %202, label %204
202: ; preds = %189
%203 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.29, i64 0, i64 0))
br label %204
204: ; preds = %202, %189
%205 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.44, i64 0, i64 0))
%206 = call i32 @sleep(i32 10)
%207 = load i32, i32* @RTC_RD_TIME
%208 = call i32 @ioctl(i32 %16, i32 %207, %struct.rtc_time* %4)
%209 = icmp eq i32 %208, -1
br i1 %209, label %210, label %212
210: ; preds = %204
%211 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.13, i64 0, i64 0))
br label %212
212: ; preds = %210, %204
%213 = load i32, i32* %77
%214 = load i32, i32* %79
%215 = add nsw i32 %214, 1
%216 = load i32, i32* %82
%217 = load i32, i32* %84
%218 = load i32, i32* %86
%219 = load i32, i32* %88
%220 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.14, i64 0, i64 0), i32 %213, i32 %215, i32 %216, i32 %217, i32 %218, i32 %219)
%221 = load i32, i32* @RTC_RD_TIME
%222 = call i32 @ioctl(i32 %16, i32 %221, %struct.rtc_time* %4)
%223 = icmp eq i32 %222, -1
br i1 %223, label %224, label %226
224: ; preds = %212
%225 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.13, i64 0, i64 0))
br label %226
226: ; preds = %224, %212
%227 = load i32, i32* %77
%228 = load i32, i32* %79
%229 = add nsw i32 %228, 1
%230 = load i32, i32* %82
%231 = load i32, i32* %84
%232 = load i32, i32* %86
%233 = load i32, i32* %88
%234 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.14, i64 0, i64 0), i32 %227, i32 %229, i32 %230, i32 %231, i32 %232, i32 %233)
%235 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.45, i64 0, i64 0))
%236 = call i32 @close(i32 %16)
ret i32 0
}