#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 void *time_t;
struct tm {
  int tm_sec;
  int tm_min;
  int tm_hour;
  int tm_mday;
  int tm_mon;
  int tm_year;
  int tm_isdst;
  scalar_t__ tm_yday;
  scalar_t__ tm_wday;
};
struct timeval {
  scalar_t__ tv_usec;
  void *tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
void *mktime(struct tm *);
int /*<<< orphan*/ printf(char *, ...);
int read_rtc(int);
int settimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ setup_io();
int /*<<< orphan*/ sscanf(char *, char *, int *, int *, int *, int *, int *,
                          int *);
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ write_rtc(int, int);
int main(int argc, char **argv) {
  int lp;
  unsigned char val;
  int year, month, day, hour, minute, second;
  time_t epoch_time;
  struct tm time_requested;
  struct timeval time_setformat;
  if (argc > 2) {
    printf("Too many arguments specified.\nRun as:\nrtc-pi\nor\nrtc-pi "
           "CCYYMMDDHHMMSS\n");
    exit(-1);
  }
  setup_io();
  if (argc == 2) {
    sscanf(argv[1], "%4d%2d%2d%2d%2d%2d", &year, &month, &day, &hour, &minute,
           &second);
    if ((year < 2000) || (year > 2099) || (month < 1) || (month > 12) ||
        (day < 1) || (day > 31) || (hour < 0) || (hour > 23) || (minute < 0) ||
        (minute > 59) || (second < 0) || (second > 59)) {
      printf("Incorrect date and time specified.\nRun as:\nrtc-pi\nor\nrtc-pi "
             "CCYYMMDDHHMMSS\n");
      exit(-1);
    }
    write_rtc(0x80, ((second / 10) << 4) | (second % 10));
    write_rtc(0x82, ((minute / 10) << 4) | (minute % 10));
    write_rtc(0x84, ((hour / 10) << 4) | (hour % 10));
    write_rtc(0x86, ((day / 10) << 4) | (day % 10));
    write_rtc(0x88, ((month / 10) << 4) | (month % 10));
    write_rtc(0x8C, (((year - 2000) / 10) << 4) | (year % 10));
    time_requested.tm_sec = second;
    time_requested.tm_min = minute;
    time_requested.tm_hour = hour;
    time_requested.tm_mday = day;
    time_requested.tm_mon = month - 1;
    time_requested.tm_year = year - 1900;
    time_requested.tm_wday = 0;
    time_requested.tm_yday = 0;
    time_requested.tm_isdst = -1;
    epoch_time = mktime(&time_requested);
    time_setformat.tv_sec = epoch_time;
    time_setformat.tv_usec = 0;
    lp = settimeofday(&time_setformat, NULL);
    if (lp < 0) {
      printf("Unable to change the system time. Did you run the program as an "
             "administrator?\n");
      printf("The operation returned the error message \"%s\"\n",
             strerror(errno));
      exit(-1);
    }
  } else {
    second = read_rtc(0x81);
    minute = read_rtc(0x83);
    hour = read_rtc(0x85);
    day = read_rtc(0x87);
    month = read_rtc(0x89);
    year = read_rtc(0x8D);
    time_requested.tm_sec = (((second & 0x70) >> 4) * 10) + (second & 0x0F);
    time_requested.tm_min = (((minute & 0x70) >> 4) * 10) + (minute & 0x0F);
    time_requested.tm_hour = (((hour & 0x30) >> 4) * 10) + (hour & 0x0F);
    time_requested.tm_mday = (((day & 0x30) >> 4) * 10) + (day & 0x0F);
    time_requested.tm_mon = (((month & 0x10) >> 4) * 10) + (month & 0x0F) - 1;
    time_requested.tm_year =
        (((year & 0xF0) >> 4) * 10) + (year & 0x0F) + 2000 - 1900;
    time_requested.tm_wday = 0;
    time_requested.tm_yday = 0;
    time_requested.tm_isdst = -1;
    epoch_time = mktime(&time_requested);
    time_setformat.tv_sec = epoch_time;
    time_setformat.tv_usec = 0;
    lp = settimeofday(&time_setformat, NULL);
    if (lp < 0) {
      printf("Unable to change the system time. Did you run the program as an "
             "administrator?\n");
      printf("The operation returned the error message \"%s\"\n",
             strerror(errno));
      exit(-1);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    11cb <main+0x3b>
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
mov    $0x0,%al
call   10b0 <setup_io@plt>
cmpl   $0x2,-0x8(%rbp)
jne    144c <main+0x2bc>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe5c(%rip),%rsi
lea    -0x1c(%rbp),%rdx
lea    -0x20(%rbp),%rcx
lea    -0x24(%rbp),%r8
lea    -0x28(%rbp),%r9
lea    -0x2c(%rbp),%r10
lea    -0x30(%rbp),%rax
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1050 <sscanf@plt>
cmpl   $0x7d0,-0x1c(%rbp)
jl     128f <main+0xff>
cmpl   $0x833,-0x1c(%rbp)
jg     128f <main+0xff>
cmpl   $0x1,-0x20(%rbp)
jl     128f <main+0xff>
cmpl   $0xc,-0x20(%rbp)
jg     128f <main+0xff>
cmpl   $0x1,-0x24(%rbp)
jl     128f <main+0xff>
cmpl   $0x1f,-0x24(%rbp)
jg     128f <main+0xff>
cmpl   $0x0,-0x28(%rbp)
jl     128f <main+0xff>
cmpl   $0x17,-0x28(%rbp)
jg     128f <main+0xff>
cmpl   $0x0,-0x2c(%rbp)
jl     128f <main+0xff>
cmpl   $0x3b,-0x2c(%rbp)
jg     128f <main+0xff>
cmpl   $0x0,-0x30(%rbp)
jl     128f <main+0xff>
cmpl   $0x3b,-0x30(%rbp)
jle    12a7 <main+0x117>
lea    0xdc4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
mov    -0x30(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
shl    $0x4,%esi
mov    -0x30(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
or     %edx,%esi
mov    $0x80,%edi
call   1080 <write_rtc@plt>
mov    -0x2c(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
shl    $0x4,%esi
mov    -0x2c(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
or     %edx,%esi
mov    $0x82,%edi
call   1080 <write_rtc@plt>
mov    -0x28(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
shl    $0x4,%esi
mov    -0x28(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
or     %edx,%esi
mov    $0x84,%edi
call   1080 <write_rtc@plt>
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
shl    $0x4,%esi
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
or     %edx,%esi
mov    $0x86,%edi
call   1080 <write_rtc@plt>
mov    -0x20(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
shl    $0x4,%esi
mov    -0x20(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
or     %edx,%esi
mov    $0x88,%edi
call   1080 <write_rtc@plt>
mov    -0x1c(%rbp),%eax
sub    $0x7d0,%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
shl    $0x4,%esi
mov    -0x1c(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
or     %edx,%esi
mov    $0x8c,%edi
call   1080 <write_rtc@plt>
mov    -0x30(%rbp),%eax
mov    %eax,-0x68(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x64(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x60(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x5c(%rbp)
mov    -0x20(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x58(%rbp)
mov    -0x1c(%rbp),%eax
sub    $0x76c,%eax
mov    %eax,-0x54(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
movl   $0xffffffff,-0x50(%rbp)
lea    -0x68(%rbp),%rdi
call   1060 <mktime@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x70(%rbp)
movq   $0x0,-0x78(%rbp)
lea    -0x78(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <settimeofday@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1447 <main+0x2b7>
lea    0xc8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2bbb(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    %rax,%rsi
lea    0xcc0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
jmp    15bd <main+0x42d>
mov    $0x81,%edi
call   10a0 <read_rtc@plt>
mov    %eax,-0x30(%rbp)
mov    $0x83,%edi
call   10a0 <read_rtc@plt>
mov    %eax,-0x2c(%rbp)
mov    $0x85,%edi
call   10a0 <read_rtc@plt>
mov    %eax,-0x28(%rbp)
mov    $0x87,%edi
call   10a0 <read_rtc@plt>
mov    %eax,-0x24(%rbp)
mov    $0x89,%edi
call   10a0 <read_rtc@plt>
mov    %eax,-0x20(%rbp)
mov    $0x8d,%edi
call   10a0 <read_rtc@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x30(%rbp),%eax
and    $0x70,%eax
sar    $0x4,%eax
imul   $0xa,%eax,%eax
mov    -0x30(%rbp),%ecx
and    $0xf,%ecx
add    %ecx,%eax
mov    %eax,-0x68(%rbp)
mov    -0x2c(%rbp),%eax
and    $0x70,%eax
sar    $0x4,%eax
imul   $0xa,%eax,%eax
mov    -0x2c(%rbp),%ecx
and    $0xf,%ecx
add    %ecx,%eax
mov    %eax,-0x64(%rbp)
mov    -0x28(%rbp),%eax
and    $0x30,%eax
sar    $0x4,%eax
imul   $0xa,%eax,%eax
mov    -0x28(%rbp),%ecx
and    $0xf,%ecx
add    %ecx,%eax
mov    %eax,-0x60(%rbp)
mov    -0x24(%rbp),%eax
and    $0x30,%eax
sar    $0x4,%eax
imul   $0xa,%eax,%eax
mov    -0x24(%rbp),%ecx
and    $0xf,%ecx
add    %ecx,%eax
mov    %eax,-0x5c(%rbp)
mov    -0x20(%rbp),%eax
and    $0x10,%eax
sar    $0x4,%eax
imul   $0xa,%eax,%eax
mov    -0x20(%rbp),%ecx
and    $0xf,%ecx
add    %ecx,%eax
sub    $0x1,%eax
mov    %eax,-0x58(%rbp)
mov    -0x1c(%rbp),%eax
and    $0xf0,%eax
sar    $0x4,%eax
imul   $0xa,%eax,%eax
mov    -0x1c(%rbp),%ecx
and    $0xf,%ecx
add    %ecx,%eax
add    $0x7d0,%eax
sub    $0x76c,%eax
mov    %eax,-0x54(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
movl   $0xffffffff,-0x50(%rbp)
lea    -0x68(%rbp),%rdi
call   1060 <mktime@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x70(%rbp)
movq   $0x0,-0x78(%rbp)
lea    -0x78(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <settimeofday@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    15b8 <main+0x428>
lea    0xb1e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2a4a(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    %rax,%rsi
lea    0xb4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
jmp    15bd <main+0x42d>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x60,%rsp
cmp    $0x3,%edi
jge    1513 <main+0x373>
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %eax,%eax
call   10c0 <setup_io@plt>
cmp    $0x2,%ebp
jne    13f7 <main+0x257>
mov    0x8(%rbx),%rdi
lea    0x14(%rsp),%rax
lea    0x8(%rsp),%rbp
lea    0xe51(%rip),%rsi
lea    0x1c(%rsp),%rdx
lea    0x18(%rsp),%rcx
lea    0x10(%rsp),%r8
lea    0xc(%rsp),%r9
push   %rax
push   %rbp
call   1060 <sscanf@plt>
add    $0x10,%rsp
mov    $0xfffff7cc,%eax
add    0x1c(%rsp),%eax
cmp    $0xffffff9c,%eax
jb     1551 <main+0x3b1>
mov    0x18(%rsp),%eax
test   %eax,%eax
jle    1551 <main+0x3b1>
cmp    $0xc,%eax
jg     1551 <main+0x3b1>
mov    0x10(%rsp),%eax
test   %eax,%eax
jle    1551 <main+0x3b1>
cmp    $0x1f,%eax
jg     1551 <main+0x3b1>
mov    0xc(%rsp),%eax
test   %eax,%eax
js     1551 <main+0x3b1>
cmp    $0x17,%eax
jg     1551 <main+0x3b1>
mov    0x8(%rsp),%eax
test   %eax,%eax
js     1551 <main+0x3b1>
cmp    $0x3b,%eax
jg     1551 <main+0x3b1>
mov    0x14(%rsp),%eax
test   %eax,%eax
js     1551 <main+0x3b1>
cmp    $0x3c,%eax
jge    1551 <main+0x3b1>
movzbl %al,%eax
imul   $0xcd,%eax,%ecx
shr    $0xb,%ecx
mov    %ecx,%edx
shl    $0x4,%edx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %cl,%al
movzbl %al,%esi
or     %edx,%esi
mov    $0x80,%edi
call   1090 <write_rtc@plt>
movslq 0x8(%rsp),%rsi
imul   $0x66666667,%rsi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
sar    $0x2,%eax
add    %ecx,%eax
mov    %eax,%ecx
shl    $0x4,%ecx
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%esi
or     %ecx,%esi
mov    $0x82,%edi
call   1090 <write_rtc@plt>
movslq 0xc(%rsp),%rsi
imul   $0x66666667,%rsi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
sar    $0x2,%eax
add    %ecx,%eax
mov    %eax,%ecx
shl    $0x4,%ecx
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%esi
or     %ecx,%esi
mov    $0x84,%edi
call   1090 <write_rtc@plt>
movslq 0x10(%rsp),%rsi
imul   $0x66666667,%rsi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
sar    $0x2,%eax
add    %ecx,%eax
mov    %eax,%ecx
shl    $0x4,%ecx
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%esi
or     %ecx,%esi
mov    $0x86,%edi
call   1090 <write_rtc@plt>
movslq 0x18(%rsp),%rsi
imul   $0x66666667,%rsi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
sar    $0x2,%eax
add    %ecx,%eax
mov    %eax,%ecx
shl    $0x4,%ecx
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%esi
or     %ecx,%esi
mov    $0x88,%edi
call   1090 <write_rtc@plt>
movslq 0x1c(%rsp),%rsi
lea    -0x7d0(%rsi),%eax
cltq
imul   $0x66666667,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x22,%rax
add    %ecx,%eax
shl    $0x4,%eax
imul   $0x66666667,%rsi,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x2,%ecx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%esi
or     %eax,%esi
mov    $0x8c,%edi
call   1090 <write_rtc@plt>
mov    0x14(%rsp),%eax
mov    %eax,0x30(%rsp)
mov    0x8(%rsp),%eax
mov    %eax,0x34(%rsp)
mov    0xc(%rsp),%eax
mov    %eax,0x38(%rsp)
mov    0x10(%rsp),%eax
mov    %eax,0x3c(%rsp)
mov    0x18(%rsp),%eax
add    $0xffffffff,%eax
mov    %eax,0x40(%rsp)
mov    $0xfffff894,%eax
add    0x1c(%rsp),%eax
jmp    14c6 <main+0x326>
mov    $0x81,%edi
call   10b0 <read_rtc@plt>
mov    %eax,%r14d
mov    %eax,0x14(%rsp)
mov    $0x83,%edi
call   10b0 <read_rtc@plt>
mov    %eax,%r15d
mov    %eax,0x8(%rsp)
mov    $0x85,%edi
call   10b0 <read_rtc@plt>
mov    %eax,%r12d
mov    %eax,0xc(%rsp)
mov    $0x87,%edi
call   10b0 <read_rtc@plt>
mov    %eax,%ebp
mov    %eax,0x10(%rsp)
mov    $0x89,%edi
call   10b0 <read_rtc@plt>
mov    %eax,%ebx
mov    $0x8d,%edi
call   10b0 <read_rtc@plt>
movd   %r14d,%xmm0
movd   %r15d,%xmm1
punpckldq %xmm1,%xmm0
movd   %r12d,%xmm1
movd   %ebp,%xmm2
punpckldq %xmm2,%xmm1
punpcklqdq %xmm1,%xmm0
movdqa %xmm0,%xmm1
psrld  $0x4,%xmm1
pand   0xb80(%rip),%xmm1
pmaddwd 0xb88(%rip),%xmm1
pand   0xb90(%rip),%xmm0
paddd  %xmm1,%xmm0
movdqa %xmm0,0x30(%rsp)
mov    %ebx,%ecx
shr    $0x4,%ecx
and    $0x1,%ecx
lea    (%rcx,%rcx,4),%ecx
and    $0xf,%ebx
lea    (%rbx,%rcx,2),%ecx
add    $0xffffffff,%ecx
mov    %ecx,0x40(%rsp)
mov    %eax,%ecx
shr    $0x4,%ecx
and    $0xf,%ecx
lea    (%rcx,%rcx,4),%ecx
and    $0xf,%eax
lea    (%rax,%rcx,2),%eax
add    $0x64,%eax
mov    %eax,0x44(%rsp)
pxor   %xmm0,%xmm0
movdqa %xmm0,0x50(%rsp)
movl   $0xffffffff,0x48(%rsp)
ff
lea    0x30(%rsp),%rdi
call   1070 <mktime@plt>
mov    %rax,0x28(%rsp)
movq   $0x0,0x20(%rsp)
lea    0x20(%rsp),%rdi
xor    %esi,%esi
call   1050 <settimeofday@plt>
test   %eax,%eax
js     151c <main+0x37c>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xbf2(%rip),%rdi
jmp    1558 <main+0x3b8>
lea    0xb4f(%rip),%rdi
call   1030 <puts@plt>
mov    0x2ab1(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
lea    0xb06(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
lea    0xb69(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32, i32, i64, i64 }
%struct.timeval = type { i64, i8* }
@.str = [71 x i8] c"Too many arguments specified.\0ARun as:\0Artc-pi\0Aor\0Artc-pi CCYYMMDDHHMMSS\0A\00"
@.str.1 = [19 x i8] c"%4d%2d%2d%2d%2d%2d\00"
@.str.2 = [76 x i8] c"Incorrect date and time specified.\0ARun as:\0Artc-pi\0Aor\0Artc-pi CCYYMMDDHHMMSS\0A\00"
@.str.3 = [80 x i8] c"Unable to change the system time. Did you run the program as an administrator?\0A\00"
@.str.4 = [47 x i8] c"The operation returned the error message \22%s\22\0A\00"
@errno = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8*
%15 = alloca %struct.tm
%16 = alloca %struct.timeval
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%17 = load i32, i32* %4
%18 = icmp sgt i32 %17, 2
br i1 %18, label %19, label %22
19: ; preds = %2
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str, i64 0, i64 0))
%21 = call i32 @exit(i32 -1)
unreachable
22: ; preds = %2
%23 = call i32 (...) @setup_io()
%24 = load i32, i32* %4
%25 = icmp eq i32 %24, 2
br i1 %25, label %26, label %144
26: ; preds = %22
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i32 @sscanf(i8* %29, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32* %8, i32* %9, i32* %10, i32* %11, i32* %12, i32* %13)
%31 = load i32, i32* %8
%32 = icmp slt i32 %31, 2000
br i1 %32, label %66, label %33
33: ; preds = %26
%34 = load i32, i32* %8
%35 = icmp sgt i32 %34, 2099
br i1 %35, label %66, label %36
36: ; preds = %33
%37 = load i32, i32* %9
%38 = icmp slt i32 %37, 1
br i1 %38, label %66, label %39
39: ; preds = %36
%40 = load i32, i32* %9
%41 = icmp sgt i32 %40, 12
br i1 %41, label %66, label %42
42: ; preds = %39
%43 = load i32, i32* %10
%44 = icmp slt i32 %43, 1
br i1 %44, label %66, label %45
45: ; preds = %42
%46 = load i32, i32* %10
%47 = icmp sgt i32 %46, 31
br i1 %47, label %66, label %48
48: ; preds = %45
%49 = load i32, i32* %11
%50 = icmp slt i32 %49, 0
br i1 %50, label %66, label %51
51: ; preds = %48
%52 = load i32, i32* %11
%53 = icmp sgt i32 %52, 23
br i1 %53, label %66, label %54
54: ; preds = %51
%55 = load i32, i32* %12
%56 = icmp slt i32 %55, 0
br i1 %56, label %66, label %57
57: ; preds = %54
%58 = load i32, i32* %12
%59 = icmp sgt i32 %58, 59
br i1 %59, label %66, label %60
60: ; preds = %57
%61 = load i32, i32* %13
%62 = icmp slt i32 %61, 0
br i1 %62, label %66, label %63
63: ; preds = %60
%64 = load i32, i32* %13
%65 = icmp sgt i32 %64, 59
br i1 %65, label %66, label %69
66: ; preds = %63, %60, %57, %54, %51, %48, %45, %42, %39, %36, %33, %26
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.2, i64 0, i64 0))
%68 = call i32 @exit(i32 -1)
unreachable
69: ; preds = %63
%70 = load i32, i32* %13
%71 = sdiv i32 %70, 10
%72 = shl i32 %71, 4
%73 = load i32, i32* %13
%74 = srem i32 %73, 10
%75 = or i32 %72, %74
%76 = call i32 @write_rtc(i32 128, i32 %75)
%77 = load i32, i32* %12
%78 = sdiv i32 %77, 10
%79 = shl i32 %78, 4
%80 = load i32, i32* %12
%81 = srem i32 %80, 10
%82 = or i32 %79, %81
%83 = call i32 @write_rtc(i32 130, i32 %82)
%84 = load i32, i32* %11
%85 = sdiv i32 %84, 10
%86 = shl i32 %85, 4
%87 = load i32, i32* %11
%88 = srem i32 %87, 10
%89 = or i32 %86, %88
%90 = call i32 @write_rtc(i32 132, i32 %89)
%91 = load i32, i32* %10
%92 = sdiv i32 %91, 10
%93 = shl i32 %92, 4
%94 = load i32, i32* %10
%95 = srem i32 %94, 10
%96 = or i32 %93, %95
%97 = call i32 @write_rtc(i32 134, i32 %96)
%98 = load i32, i32* %9
%99 = sdiv i32 %98, 10
%100 = shl i32 %99, 4
%101 = load i32, i32* %9
%102 = srem i32 %101, 10
%103 = or i32 %100, %102
%104 = call i32 @write_rtc(i32 136, i32 %103)
%105 = load i32, i32* %8
%106 = sub nsw i32 %105, 2000
%107 = sdiv i32 %106, 10
%108 = shl i32 %107, 4
%109 = load i32, i32* %8
%110 = srem i32 %109, 10
%111 = or i32 %108, %110
%112 = call i32 @write_rtc(i32 140, i32 %111)
%113 = load i32, i32* %13
%114 = getelementptr inbounds %struct.tm, %struct.tm* %15, i32 0, i32 0
store i32 %113, i32* %114
%115 = load i32, i32* %12
%116 = getelementptr inbounds %struct.tm, %struct.tm* %15, i32 0, i32 1
store i32 %115, i32* %116
%117 = load i32, i32* %11
%118 = getelementptr inbounds %struct.tm, %struct.tm* %15, i32 0, i32 2
store i32 %117, i32* %118
%119 = load i32, i32* %10
%120 = getelementptr inbounds %struct.tm, %struct.tm* %15, i32 0, i32 3
store i32 %119, i32* %120
%121 = load i32, i32* %9
%122 = sub nsw i32 %121, 1
%123 = getelementptr inbounds %struct.tm, %struct.tm* %15, i32 0, i32 4
store i32 %122, i32* %123
%124 = load i32, i32* %8
%125 = sub nsw i32 %124, 1900
%126 = getelementptr inbounds %struct.tm, %struct.tm* %15, i32 0, i32 5
store i32 %125, i32* %126
%127 = getelementptr inbounds %struct.tm, %struct.tm* %15, i32 0, i32 8
store i64 0, i64* %127
%128 = getelementptr inbounds %struct.tm, %struct.tm* %15, i32 0, i32 7
store i64 0, i64* %128
%129 = getelementptr inbounds %struct.tm, %struct.tm* %15, i32 0, i32 6
store i32 -1, i32* %129
%130 = call i8* @mktime(%struct.tm* %15)
store i8* %130, i8** %14
%131 = load i8*, i8** %14
%132 = getelementptr inbounds %struct.timeval, %struct.timeval* %16, i32 0, i32 1
store i8* %131, i8** %132
%133 = getelementptr inbounds %struct.timeval, %struct.timeval* %16, i32 0, i32 0
store i64 0, i64* %133
%134 = call i32 @settimeofday(%struct.timeval* %16, i32* null)
store i32 %134, i32* %6
%135 = load i32, i32* %6
%136 = icmp slt i32 %135, 0
br i1 %136, label %137, label %143
137: ; preds = %69
%138 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @.str.3, i64 0, i64 0))
%139 = load i32, i32* @errno
%140 = call i8* @strerror(i32 %139)
%141 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0), i8* %140)
%142 = call i32 @exit(i32 -1)
unreachable
143: ; preds = %69
br label %219
144: ; preds = %22
%145 = call i32 @read_rtc(i32 129)
store i32 %145, i32* %13
%146 = call i32 @read_rtc(i32 131)
store i32 %146, i32* %12
%147 = call i32 @read_rtc(i32 133)
store i32 %147, i32* %11
%148 = call i32 @read_rtc(i32 135)
store i32 %148, i32* %10
%149 = call i32 @read_rtc(i32 137)
store i32 %149, i32* %9
%150 = call i32 @read_rtc(i32 141)
store i32 %150, i32* %8
%151 = load i32, i32* %13
%152 = and i32 %151, 112
%153 = ashr i32 %152, 4
%154 = mul nsw i32 %153, 10
%155 = load i32, i32* %13
%156 = and i32 %155, 15
%157 = add nsw i32 %154, %156
%158 = getelementptr inbounds %struct.tm, %struct.tm* %15, i32 0, i32 0
store i32 %157, i32* %158
%159 = load i32, i32* %12
%160 = and i32 %159, 112
%161 = ashr i32 %160, 4
%162 = mul nsw i32 %161, 10
%163 = load i32, i32* %12
%164 = and i32 %163, 15
%165 = add nsw i32 %162, %164
%166 = getelementptr inbounds %struct.tm, %struct.tm* %15, i32 0, i32 1
store i32 %165, i32* %166
%167 = load i32, i32* %11
%168 = and i32 %167, 48
%169 = ashr i32 %168, 4
%170 = mul nsw i32 %169, 10
%171 = load i32, i32* %11
%172 = and i32 %171, 15
%173 = add nsw i32 %170, %172
%174 = getelementptr inbounds %struct.tm, %struct.tm* %15, i32 0, i32 2
store i32 %173, i32* %174
%175 = load i32, i32* %10
%176 = and i32 %175, 48
%177 = ashr i32 %176, 4
%178 = mul nsw i32 %177, 10
%179 = load i32, i32* %10
%180 = and i32 %179, 15
%181 = add nsw i32 %178, %180
%182 = getelementptr inbounds %struct.tm, %struct.tm* %15, i32 0, i32 3
store i32 %181, i32* %182
%183 = load i32, i32* %9
%184 = and i32 %183, 16
%185 = ashr i32 %184, 4
%186 = mul nsw i32 %185, 10
%187 = load i32, i32* %9
%188 = and i32 %187, 15
%189 = add nsw i32 %186, %188
%190 = sub nsw i32 %189, 1
%191 = getelementptr inbounds %struct.tm, %struct.tm* %15, i32 0, i32 4
store i32 %190, i32* %191
%192 = load i32, i32* %8
%193 = and i32 %192, 240
%194 = ashr i32 %193, 4
%195 = mul nsw i32 %194, 10
%196 = load i32, i32* %8
%197 = and i32 %196, 15
%198 = add nsw i32 %195, %197
%199 = add nsw i32 %198, 2000
%200 = sub nsw i32 %199, 1900
%201 = getelementptr inbounds %struct.tm, %struct.tm* %15, i32 0, i32 5
store i32 %200, i32* %201
%202 = getelementptr inbounds %struct.tm, %struct.tm* %15, i32 0, i32 8
store i64 0, i64* %202
%203 = getelementptr inbounds %struct.tm, %struct.tm* %15, i32 0, i32 7
store i64 0, i64* %203
%204 = getelementptr inbounds %struct.tm, %struct.tm* %15, i32 0, i32 6
store i32 -1, i32* %204
%205 = call i8* @mktime(%struct.tm* %15)
store i8* %205, i8** %14
%206 = load i8*, i8** %14
%207 = getelementptr inbounds %struct.timeval, %struct.timeval* %16, i32 0, i32 1
store i8* %206, i8** %207
%208 = getelementptr inbounds %struct.timeval, %struct.timeval* %16, i32 0, i32 0
store i64 0, i64* %208
%209 = call i32 @settimeofday(%struct.timeval* %16, i32* null)
store i32 %209, i32* %6
%210 = load i32, i32* %6
%211 = icmp slt i32 %210, 0
br i1 %211, label %212, label %218
212: ; preds = %144
%213 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @.str.3, i64 0, i64 0))
%214 = load i32, i32* @errno
%215 = call i8* @strerror(i32 %214)
%216 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0), i8* %215)
%217 = call i32 @exit(i32 -1)
unreachable
218: ; preds = %144
br label %219
219: ; preds = %218, %143
ret i32 0
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32, i32, i64, i64 }
%struct.timeval = type { i64, i8* }
@.str.1 = [19 x i8] c"%4d%2d%2d%2d%2d%2d\00"
@.str.4 = [47 x i8] c"The operation returned the error message \22%s\22\0A\00"
@errno = global i32 0
@str.5 = [79 x i8] c"Unable to change the system time. Did you run the program as an administrator?\00"
@str.6 = [75 x i8] c"Incorrect date and time specified.\0ARun as:\0Artc-pi\0Aor\0Artc-pi CCYYMMDDHHMMSS\00"
@str.7 = [70 x i8] c"Too many arguments specified.\0ARun as:\0Artc-pi\0Aor\0Artc-pi CCYYMMDDHHMMSS\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.tm
%10 = alloca %struct.timeval
%11 = bitcast i32* %3 to i8*
%12 = bitcast i32* %4 to i8*
%13 = bitcast i32* %5 to i8*
%14 = bitcast i32* %6 to i8*
%15 = bitcast i32* %7 to i8*
%16 = bitcast i32* %8 to i8*
%17 = bitcast %struct.tm* %9 to i8*
%18 = bitcast %struct.timeval* %10 to i8*
%19 = icmp sgt i32 %0, 2
br i1 %19, label %20, label %23
20: ; preds = %2
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([70 x i8], [70 x i8]* @str.7, i64 0, i64 0))
%22 = tail call i32 @exit(i32 -1)
unreachable
23: ; preds = %2
%24 = tail call i32 (...) @setup_io()
%25 = icmp eq i32 %0, 2
br i1 %25, label %26, label %129
26: ; preds = %23
%27 = getelementptr inbounds i8*, i8** %1, i64 1
%28 = load i8*, i8** %27
%29 = call i32 @sscanf(i8* %28, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4, i32* %5, i32* %6, i32* %7, i32* %8)
%30 = load i32, i32* %3
%31 = add i32 %30, -2100
%32 = icmp ult i32 %31, -100
%33 = load i32, i32* %4
%34 = icmp slt i32 %33, 1
%35 = select i1 %32, i1 true, i1 %34
%36 = icmp sgt i32 %33, 12
%37 = select i1 %35, i1 true, i1 %36
%38 = load i32, i32* %5
%39 = icmp slt i32 %38, 1
%40 = select i1 %37, i1 true, i1 %39
%41 = icmp sgt i32 %38, 31
%42 = select i1 %40, i1 true, i1 %41
%43 = load i32, i32* %6
%44 = icmp slt i32 %43, 0
%45 = select i1 %42, i1 true, i1 %44
%46 = icmp sgt i32 %43, 23
%47 = select i1 %45, i1 true, i1 %46
%48 = load i32, i32* %7
%49 = icmp slt i32 %48, 0
%50 = select i1 %47, i1 true, i1 %49
%51 = icmp sgt i32 %48, 59
%52 = select i1 %50, i1 true, i1 %51
%53 = load i32, i32* %8
%54 = icmp slt i32 %53, 0
%55 = select i1 %52, i1 true, i1 %54
%56 = icmp sgt i32 %53, 59
%57 = select i1 %55, i1 true, i1 %56
br i1 %57, label %58, label %61
58: ; preds = %26
%59 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([75 x i8], [75 x i8]* @str.6, i64 0, i64 0))
%60 = call i32 @exit(i32 -1)
unreachable
61: ; preds = %26
%62 = trunc i32 %53 to i8
%63 = udiv i8 %62, 10
%64 = zext i8 %63 to i32
%65 = shl nuw nsw i32 %64, 4
%66 = urem i8 %62, 10
%67 = zext i8 %66 to i32
%68 = or i32 %65, %67
%69 = call i32 @write_rtc(i32 128, i32 %68)
%70 = load i32, i32* %7
%71 = sdiv i32 %70, 10
%72 = shl i32 %71, 4
%73 = srem i32 %70, 10
%74 = or i32 %72, %73
%75 = call i32 @write_rtc(i32 130, i32 %74)
%76 = load i32, i32* %6
%77 = sdiv i32 %76, 10
%78 = shl i32 %77, 4
%79 = srem i32 %76, 10
%80 = or i32 %78, %79
%81 = call i32 @write_rtc(i32 132, i32 %80)
%82 = load i32, i32* %5
%83 = sdiv i32 %82, 10
%84 = shl i32 %83, 4
%85 = srem i32 %82, 10
%86 = or i32 %84, %85
%87 = call i32 @write_rtc(i32 134, i32 %86)
%88 = load i32, i32* %4
%89 = sdiv i32 %88, 10
%90 = shl i32 %89, 4
%91 = srem i32 %88, 10
%92 = or i32 %90, %91
%93 = call i32 @write_rtc(i32 136, i32 %92)
%94 = load i32, i32* %3
%95 = add nsw i32 %94, -2000
%96 = sdiv i32 %95, 10
%97 = shl i32 %96, 4
%98 = srem i32 %94, 10
%99 = or i32 %97, %98
%100 = call i32 @write_rtc(i32 140, i32 %99)
%101 = load i32, i32* %8
%102 = getelementptr inbounds %struct.tm, %struct.tm* %9, i64 0, i32 0
store i32 %101, i32* %102
%103 = load i32, i32* %7
%104 = getelementptr inbounds %struct.tm, %struct.tm* %9, i64 0, i32 1
store i32 %103, i32* %104
%105 = load i32, i32* %6
%106 = getelementptr inbounds %struct.tm, %struct.tm* %9, i64 0, i32 2
store i32 %105, i32* %106
%107 = load i32, i32* %5
%108 = getelementptr inbounds %struct.tm, %struct.tm* %9, i64 0, i32 3
store i32 %107, i32* %108
%109 = load i32, i32* %4
%110 = add nsw i32 %109, -1
%111 = getelementptr inbounds %struct.tm, %struct.tm* %9, i64 0, i32 4
store i32 %110, i32* %111
%112 = load i32, i32* %3
%113 = add nsw i32 %112, -1900
%114 = getelementptr inbounds %struct.tm, %struct.tm* %9, i64 0, i32 5
store i32 %113, i32* %114
%115 = getelementptr inbounds %struct.tm, %struct.tm* %9, i64 0, i32 7
%116 = getelementptr inbounds %struct.tm, %struct.tm* %9, i64 0, i32 6
%117 = bitcast i64* %115 to i8*
store i32 -1, i32* %116
%118 = call i8* @mktime(%struct.tm* %9)
%119 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i64 0, i32 1
store i8* %118, i8** %119
%120 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i64 0, i32 0
store i64 0, i64* %120
%121 = call i32 @settimeofday(%struct.timeval* %10, i32* null)
%122 = icmp slt i32 %121, 0
br i1 %122, label %123, label %174
123: ; preds = %61
%124 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([79 x i8], [79 x i8]* @str.5, i64 0, i64 0))
%125 = load i32, i32* @errno
%126 = call i8* @strerror(i32 %125)
%127 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0), i8* %126)
%128 = call i32 @exit(i32 -1)
unreachable
129: ; preds = %23
%130 = tail call i32 @read_rtc(i32 129)
store i32 %130, i32* %8
%131 = tail call i32 @read_rtc(i32 131)
store i32 %131, i32* %7
%132 = tail call i32 @read_rtc(i32 133)
store i32 %132, i32* %6
%133 = tail call i32 @read_rtc(i32 135)
store i32 %133, i32* %5
%134 = tail call i32 @read_rtc(i32 137)
%135 = tail call i32 @read_rtc(i32 141)
%136 = insertelement <4 x i32> poison, i32 %130, i64 0
%137 = insertelement <4 x i32> %136, i32 %131, i64 1
%138 = insertelement <4 x i32> %137, i32 %132, i64 2
%139 = insertelement <4 x i32> %138, i32 %133, i64 3
%140 = lshr <4 x i32> %139, <i32 4, i32 4, i32 4, i32 4>
%141 = and <4 x i32> %140, <i32 7, i32 7, i32 3, i32 3>
%142 = mul nuw nsw <4 x i32> %141, <i32 10, i32 10, i32 10, i32 10>
%143 = and <4 x i32> %139, <i32 15, i32 15, i32 15, i32 15>
%144 = add nuw nsw <4 x i32> %142, %143
%145 = bitcast %struct.tm* %9 to <4 x i32>*
store <4 x i32> %144, <4 x i32>* %145
%146 = lshr i32 %134, 4
%147 = and i32 %146, 1
%148 = mul nuw nsw i32 %147, 10
%149 = and i32 %134, 15
%150 = add nsw i32 %149, -1
%151 = add nsw i32 %150, %148
%152 = getelementptr inbounds %struct.tm, %struct.tm* %9, i64 0, i32 4
store i32 %151, i32* %152
%153 = lshr i32 %135, 4
%154 = and i32 %153, 15
%155 = mul nuw nsw i32 %154, 10
%156 = and i32 %135, 15
%157 = add nuw nsw i32 %156, 100
%158 = add nuw nsw i32 %157, %155
%159 = getelementptr inbounds %struct.tm, %struct.tm* %9, i64 0, i32 5
store i32 %158, i32* %159
%160 = getelementptr inbounds %struct.tm, %struct.tm* %9, i64 0, i32 7
%161 = getelementptr inbounds %struct.tm, %struct.tm* %9, i64 0, i32 6
%162 = bitcast i64* %160 to i8*
store i32 -1, i32* %161
%163 = call i8* @mktime(%struct.tm* %9)
%164 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i64 0, i32 1
store i8* %163, i8** %164
%165 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i64 0, i32 0
store i64 0, i64* %165
%166 = call i32 @settimeofday(%struct.timeval* %10, i32* null)
%167 = icmp slt i32 %166, 0
br i1 %167, label %168, label %174
168: ; preds = %129
%169 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([79 x i8], [79 x i8]* @str.5, i64 0, i64 0))
%170 = load i32, i32* @errno
%171 = call i8* @strerror(i32 %170)
%172 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0), i8* %171)
%173 = call i32 @exit(i32 -1)
unreachable
174: ; preds = %129, %61
ret i32 0
}