#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ O_RDONLY;
int open(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int, int, int, int, int, int);
scalar_t__ read(int, char *, int);
int /*<<< orphan*/ sscanf(char *, char *, int *, int *, int *, int *, int *,
                          int *);
int main(int argc, char **argv) {
  int fd = open("/dev/rtc", O_RDONLY, 0);
  while (1) {
    int year, month, day, hour, minute, second;
    char buf[100];
    if (read(fd, buf, sizeof(buf)) <= 0)
      return EXIT_FAILURE;
    sscanf(buf, "%d %d %d %d %d %d", &year, &month, &day, &hour, &minute,
           &second);
    printf("Time is %d/%d/%d %02d:%02d:%02d\n", day, month, year, hour, minute,
           second);
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e88(%rip),%rax
mov    (%rax),%esi
lea    0xe97(%rip),%rdi
xor    %edx,%edx
call   1060 <open@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x90(%rbp),%rsi
mov    $0x64,%edx
call   1040 <read@plt>
cmp    $0x0,%rax
jg     11a3 <main+0x63>
mov    0x2e40(%rip),%rax
mov    (%rax),%eax
add    $0xa0,%rsp
pop    %rbp
ret
lea    -0x90(%rbp),%rdi
lea    0xe58(%rip),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x1c(%rbp),%rcx
lea    -0x20(%rbp),%r8
lea    -0x24(%rbp),%r9
lea    -0x28(%rbp),%r10
lea    -0x2c(%rbp),%rax
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1050 <sscanf@plt>
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x24(%rbp),%r8d
mov    -0x28(%rbp),%r9d
mov    -0x2c(%rbp),%eax
lea    0xe29(%rip),%rdi
mov    %eax,(%rsp)
call   1030 <printf@plt>
jmp    1173 <main+0x33>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    0x2e90(%rip),%rax
mov    (%rax),%esi
lea    0xe9f(%rip),%rdi
xor    %edx,%edx
call   1060 <open@plt>
mov    %eax,%ebp
lea    0x20(%rsp),%rsi
mov    %eax,%edi
mov    $0x64,%edx
call   1040 <read@plt>
test   %rax,%rax
jle    120c <main+0xcc>
lea    0x20(%rsp),%rbx
lea    0x18(%rsp),%r12
lea    0x14(%rsp),%r13
lea    0x10(%rsp),%r14
lea    0xe7c(%rip),%r15
nop
mov    %rbx,%rdi
lea    0xe5f(%rip),%rsi
lea    0x1c(%rsp),%rdx
mov    %r12,%rcx
mov    %r13,%r8
mov    %r14,%r9
lea    0x8(%rsp),%rax
push   %rax
lea    0x14(%rsp),%rax
push   %rax
call   1050 <sscanf@plt>
add    $0x10,%rsp
mov    0x14(%rsp),%esi
mov    0x18(%rsp),%edx
mov    0x1c(%rsp),%ecx
mov    0x10(%rsp),%r8d
mov    0xc(%rsp),%r9d
mov    0x8(%rsp),%eax
sub    $0x8,%rsp
mov    %r15,%rdi
push   %rax
call   1030 <printf@plt>
add    $0x10,%rsp
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x64,%edx
call   1040 <read@plt>
test   %rax,%rax
jg     11a0 <main+0x60>
mov    0x2dc5(%rip),%rax
mov    (%rax),%eax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"/dev/rtc\00"
@O_RDONLY = global i32 0
@EXIT_FAILURE = global i32 0
@.str.1 = [18 x i8] c"%d %d %d %d %d %d\00"
@.str.2 = [33 x i8] c"Time is %d/%d/%d %02d:%02d:%02d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca [100 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* @O_RDONLY
%15 = call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %14, i32 0)
store i32 %15, i32* %6
br label %16
16: ; preds = %2, %23
%17 = load i32, i32* %6
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%19 = call i64 @read(i32 %17, i8* %18, i32 100)
%20 = icmp sle i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %16
%22 = load i32, i32* @EXIT_FAILURE
ret i32 %22
23: ; preds = %16
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%25 = call i32 @sscanf(i8* %24, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32* %7, i32* %8, i32* %9, i32* %10, i32* %11, i32* %12)
%26 = load i32, i32* %9
%27 = load i32, i32* %8
%28 = load i32, i32* %7
%29 = load i32, i32* %10
%30 = load i32, i32* %11
%31 = load i32, i32* %12
%32 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 %26, i32 %27, i32 %28, i32 %29, i32 %30, i32 %31)
br label %16
}

LLVM IR (-O2):
@.str = [9 x i8] c"/dev/rtc\00"
@O_RDONLY = global i32 0
@EXIT_FAILURE = global i32 0
@.str.1 = [18 x i8] c"%d %d %d %d %d %d\00"
@.str.2 = [33 x i8] c"Time is %d/%d/%d %02d:%02d:%02d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [100 x i8]
%10 = load i32, i32* @O_RDONLY
%11 = tail call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %10, i32 0)
%12 = bitcast i32* %3 to i8*
%13 = bitcast i32* %4 to i8*
%14 = bitcast i32* %5 to i8*
%15 = bitcast i32* %6 to i8*
%16 = bitcast i32* %7 to i8*
%17 = bitcast i32* %8 to i8*
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%19 = call i64 @read(i32 %11, i8* %18, i32 100)
%20 = icmp slt i64 %19, 1
br i1 %20, label %32, label %21
21: ; preds = %2, %21
%22 = call i32 @sscanf(i8* %18, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4, i32* %5, i32* %6, i32* %7, i32* %8)
%23 = load i32, i32* %5
%24 = load i32, i32* %4
%25 = load i32, i32* %3
%26 = load i32, i32* %6
%27 = load i32, i32* %7
%28 = load i32, i32* %8
%29 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 %23, i32 %24, i32 %25, i32 %26, i32 %27, i32 %28)
%30 = call i64 @read(i32 %11, i8* %18, i32 100)
%31 = icmp slt i64 %30, 1
br i1 %31, label %32, label %21
32: ; preds = %21, %2
%33 = load i32, i32* @EXIT_FAILURE
ret i32 %33
}