#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 */

/* Variables and functions */
int /*<<< orphan*/ hwtosys();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ settime(char *, char *);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ systohw();
int main(int argc, char *argv[]) {
  if (argc == 2 && !strcmp(argv[1], "hwtosys"))
    hwtosys();
  else if (argc == 2 && !strcmp(argv[1], "systohw"))
    systohw();
  else if (argc == 4 && !strcmp(argv[1], "settime"))
    settime(argv[2], argv[3]);
  else {
    printf("\nRead/Write RTC time\n$Revision: 1.2 $\n\n");
    printf("Usage: <rtctest> command\n");
    printf("\ncommand:\n");
    printf("hwtosys\t\t - set system time from rtc\n");
    printf("systohw\t\t - set rtc from system time\n");
    printf("settime <time>\t - set system and rtc time to given value\n");
    printf("  <time> \t - yyyy-mm-dd hh:mm:ss\n\n");
    return 0;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    1199 <main+0x49>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe81(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1199 <main+0x49>
mov    $0x0,%al
call   1070 <hwtosys@plt>
jmp    1277 <main+0x127>
cmpl   $0x2,-0x8(%rbp)
jne    11cc <main+0x7c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe56(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11cc <main+0x7c>
mov    $0x0,%al
call   1040 <systohw@plt>
jmp    1272 <main+0x122>
cmpl   $0x4,-0x8(%rbp)
jne    120d <main+0xbd>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe2b(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    120d <main+0xbd>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   1060 <settime@plt>
jmp    126d <main+0x11d>
lea    0xe04(%rip),%rdi
call   1030 <printf@plt>
lea    0xe20(%rip),%rdi
call   1030 <printf@plt>
lea    0xe2e(%rip),%rdi
call   1030 <printf@plt>
lea    0xe2d(%rip),%rdi
call   1030 <printf@plt>
lea    0xe47(%rip),%rdi
call   1030 <printf@plt>
lea    0xe61(%rip),%rdi
call   1030 <printf@plt>
lea    0xe8f(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    127e <main+0x12e>
jmp    1272 <main+0x122>
jmp    1277 <main+0x127>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
cmp    $0x4,%edi
je     1195 <main+0x45>
cmp    $0x2,%edi
jne    11a9 <main+0x59>
mov    0x8(%rbx),%rbx
lea    0xe97(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1201 <main+0xb1>
lea    0xe88(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
jne    11a9 <main+0x59>
xor    %eax,%eax
call   1040 <systohw@plt>
jmp    11fd <main+0xad>
mov    0x8(%rbx),%rdi
lea    0xe70(%rip),%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
je     120a <main+0xba>
lea    0xe68(%rip),%rdi
call   1030 <puts@plt>
lea    0xe83(%rip),%rdi
call   1030 <puts@plt>
lea    0xe90(%rip),%rdi
call   1030 <puts@plt>
lea    0xe8e(%rip),%rdi
call   1030 <puts@plt>
lea    0xea7(%rip),%rdi
call   1030 <puts@plt>
lea    0xec0(%rip),%rdi
call   1030 <puts@plt>
lea    0xeed(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret
xor    %eax,%eax
call   1070 <hwtosys@plt>
jmp    11fd <main+0xad>
mov    0x10(%rbx),%rdi
mov    0x18(%rbx),%rsi
call   1060 <settime@plt>
jmp    11fd <main+0xad>

LLVM IR (-O0):
@.str = [8 x i8] c"hwtosys\00"
@.str.1 = [8 x i8] c"systohw\00"
@.str.2 = [8 x i8] c"settime\00"
@.str.3 = [40 x i8] c"\0ARead/Write RTC time\0A$Revision: 1.2 $\0A\0A\00"
@.str.4 = [26 x i8] c"Usage: <rtctest> command\0A\00"
@.str.5 = [11 x i8] c"\0Acommand:\0A\00"
@.str.6 = [38 x i8] c"hwtosys\09\09 - set system time from rtc\0A\00"
@.str.7 = [38 x i8] c"systohw\09\09 - set rtc from system time\0A\00"
@.str.8 = [58 x i8] c"settime <time>\09 - set system and rtc time to given value\0A\00"
@.str.9 = [35 x i8] c" <time> \09 - yyyy-mm-dd hh:mm:ss\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp eq i32 %6, 2
br i1 %7, label %8, label %16
8: ; preds = %2
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = call i32 @strcmp(i8* %11, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%13 = icmp ne i32 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %8
%15 = call i32 (...) @hwtosys()
br label %54
16: ; preds = %8, %2
%17 = load i32, i32* %4
%18 = icmp eq i32 %17, 2
br i1 %18, label %19, label %27
19: ; preds = %16
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32 @strcmp(i8* %22, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%24 = icmp ne i32 %23, 0
br i1 %24, label %27, label %25
25: ; preds = %19
%26 = call i32 (...) @systohw()
br label %53
27: ; preds = %19, %16
%28 = load i32, i32* %4
%29 = icmp eq i32 %28, 4
br i1 %29, label %30, label %44
30: ; preds = %27
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = call i32 @strcmp(i8* %33, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%35 = icmp ne i32 %34, 0
br i1 %35, label %44, label %36
36: ; preds = %30
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 2
%39 = load i8*, i8** %38
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 3
%42 = load i8*, i8** %41
%43 = call i32 @settime(i8* %39, i8* %42)
br label %52
44: ; preds = %30, %27
%45 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
%46 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%47 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%48 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0))
%49 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.7, i64 0, i64 0))
%50 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.8, i64 0, i64 0))
%51 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.9, i64 0, i64 0))
store i32 0, i32* %3
br label %55
52: ; preds = %36
br label %53
53: ; preds = %52, %25
br label %54
54: ; preds = %53, %14
store i32 0, i32* %3
br label %55
55: ; preds = %54, %44
%56 = load i32, i32* %3
ret i32 %56
}

LLVM IR (-O2):
@.str = [8 x i8] c"hwtosys\00"
@.str.1 = [8 x i8] c"systohw\00"
@.str.2 = [8 x i8] c"settime\00"
@str = [39 x i8] c"\0ARead/Write RTC time\0A$Revision: 1.2 $\0A\00"
@str.10 = [25 x i8] c"Usage: <rtctest> command\00"
@str.11 = [10 x i8] c"\0Acommand:\00"
@str.12 = [37 x i8] c"hwtosys\09\09 - set system time from rtc\00"
@str.13 = [37 x i8] c"systohw\09\09 - set rtc from system time\00"
@str.14 = [57 x i8] c"settime <time>\09 - set system and rtc time to given value\00"
@str.15 = [34 x i8] c" <time> \09 - yyyy-mm-dd hh:mm:ss\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
switch i32 %0, label %26 [
i32 2, label %3
i32 4, label %15
]
3: ; preds = %2
%4 = getelementptr inbounds i8*, i8** %1, i64 1
%5 = load i8*, i8** %4
%6 = tail call i32 @strcmp(i8* dereferenceable(1) %5, i8* dereferenceable(8) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %3
%9 = tail call i32 (...) @hwtosys()
br label %34
10: ; preds = %3
%11 = tail call i32 @strcmp(i8* dereferenceable(1) %5, i8* dereferenceable(8) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %26
13: ; preds = %10
%14 = tail call i32 (...) @systohw()
br label %34
15: ; preds = %2
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = tail call i32 @strcmp(i8* dereferenceable(1) %17, i8* dereferenceable(8) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %26
20: ; preds = %15
%21 = getelementptr inbounds i8*, i8** %1, i64 2
%22 = load i8*, i8** %21
%23 = getelementptr inbounds i8*, i8** %1, i64 3
%24 = load i8*, i8** %23
%25 = tail call i32 @settime(i8* %22, i8* %24)
br label %34
26: ; preds = %2, %10, %15
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str, i64 0, i64 0))
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.10, i64 0, i64 0))
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.11, i64 0, i64 0))
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.12, i64 0, i64 0))
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.13, i64 0, i64 0))
%32 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str.14, i64 0, i64 0))
%33 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.15, i64 0, i64 0))
br label %34
34: ; preds = %8, %20, %13, %26
ret i32 0
}