#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*/ _rtc_getalarm();
int /*<<< orphan*/ _rtc_gettime();
int /*<<< orphan*/ _rtc_setalarm(char **);
int /*<<< orphan*/ _rtc_settime(char **);
int /*<<< orphan*/ _rtc_usage();
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ rtc_clear_alarm();
int /*<<< orphan*/ rtc_poweroff();
int /*<<< orphan*/ rtc_poweron();
scalar_t__ strncmp(char *, char *, int);
int _rtc_handler(int argc, char **argv) {
  if (argc < 2) {
    _rtc_usage();
    return 1;
  } else if (strncmp(argv[1], "poweron", 7) == 0) {
    rtc_poweron();
  } else if (strncmp(argv[1], "poweroff", 8) == 0) {
    rtc_poweroff();
  } else if (strncmp(argv[1], "clearalarm", 8) == 0) {
    rtc_clear_alarm();
  } else if (strncmp(argv[1], "getalarm", 8) == 0) {
    _rtc_getalarm();
  } else if ((strncmp(argv[1], "setalarm", 8) == 0) && (argc == 4)) {
    _rtc_setalarm(argv + 2);
  } else if (strncmp(argv[1], "gettime", 7) == 0) {
    _rtc_gettime();
  } else if ((strncmp(argv[1], "settime", 7) == 0) && (argc == 4)) {
    _rtc_settime(argv + 2);
  } else {
    printf("unknown command or missing parameters: %s\n\n", argv[1]);
    _rtc_usage();
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<_rtc_handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11cc <_rtc_handler+0x2c>
mov    $0x0,%al
call   1070 <_rtc_usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    1386 <_rtc_handler+0x1e6>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe25(%rip),%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11fb <_rtc_handler+0x5b>
mov    $0x0,%al
call   10c0 <rtc_poweron@plt>
jmp    137a <_rtc_handler+0x1da>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdfe(%rip),%rsi
mov    $0x8,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    122a <_rtc_handler+0x8a>
mov    $0x0,%al
call   1050 <rtc_poweroff@plt>
jmp    1375 <_rtc_handler+0x1d5>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdd8(%rip),%rsi
mov    $0x8,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1259 <_rtc_handler+0xb9>
mov    $0x0,%al
call   1060 <rtc_clear_alarm@plt>
jmp    1370 <_rtc_handler+0x1d0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdb4(%rip),%rsi
mov    $0x8,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1288 <_rtc_handler+0xe8>
mov    $0x0,%al
call   1090 <_rtc_getalarm@plt>
jmp    136b <_rtc_handler+0x1cb>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd8e(%rip),%rsi
mov    $0x8,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    12c7 <_rtc_handler+0x127>
cmpl   $0x4,-0x8(%rbp)
jne    12c7 <_rtc_handler+0x127>
mov    -0x10(%rbp),%rdi
add    $0x10,%rdi
call   1040 <_rtc_setalarm@plt>
jmp    1366 <_rtc_handler+0x1c6>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd58(%rip),%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    12f6 <_rtc_handler+0x156>
mov    $0x0,%al
call   10b0 <_rtc_gettime@plt>
jmp    1361 <_rtc_handler+0x1c1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd31(%rip),%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1335 <_rtc_handler+0x195>
cmpl   $0x4,-0x8(%rbp)
jne    1335 <_rtc_handler+0x195>
mov    -0x10(%rbp),%rdi
add    $0x10,%rdi
call   10a0 <_rtc_settime@plt>
jmp    135c <_rtc_handler+0x1bc>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xcfa(%rip),%rdi
call   1080 <printf@plt>
mov    $0x0,%al
call   1070 <_rtc_usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    1386 <_rtc_handler+0x1e6>
jmp    1361 <_rtc_handler+0x1c1>
jmp    1366 <_rtc_handler+0x1c6>
jmp    136b <_rtc_handler+0x1cb>
jmp    1370 <_rtc_handler+0x1d0>
jmp    1375 <_rtc_handler+0x1d5>
jmp    137a <_rtc_handler+0x1da>
jmp    137f <_rtc_handler+0x1df>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_rtc_handler>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x1,%edi
jg     11b9 <_rtc_handler+0x19>
xor    %eax,%eax
call   1070 <_rtc_usage@plt>
mov    $0x1,%ebx
jmp    12d3 <_rtc_handler+0x133>
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x8(%rsi),%rdi
lea    0xe37(%rip),%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1255 <_rtc_handler+0xb5>
mov    0x8(%rbx),%rdi
lea    0xe25(%rip),%rsi
mov    $0x8,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1260 <_rtc_handler+0xc0>
mov    0x8(%rbx),%rdi
lea    0xe14(%rip),%rsi
mov    $0x8,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     126b <_rtc_handler+0xcb>
mov    0x8(%rbx),%rdi
lea    0xe05(%rip),%rsi
mov    $0x8,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1276 <_rtc_handler+0xd6>
mov    0x8(%rbx),%rdi
lea    0xdf4(%rip),%rsi
mov    $0x8,%edx
call   1030 <strncmp@plt>
cmp    $0x4,%ebp
jne    1281 <_rtc_handler+0xe1>
test   %rax,%rax
jne    1281 <_rtc_handler+0xe1>
add    $0x10,%rbx
mov    %rbx,%rdi
call   1040 <_rtc_setalarm@plt>
xor    %ebx,%ebx
jmp    12d3 <_rtc_handler+0x133>
xor    %ebx,%ebx
xor    %eax,%eax
call   10c0 <rtc_poweron@plt>
jmp    12d3 <_rtc_handler+0x133>
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <rtc_poweroff@plt>
jmp    12d3 <_rtc_handler+0x133>
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <rtc_clear_alarm@plt>
jmp    12d3 <_rtc_handler+0x133>
xor    %ebx,%ebx
xor    %eax,%eax
call   1090 <_rtc_getalarm@plt>
jmp    12d3 <_rtc_handler+0x133>
mov    0x8(%rbx),%rdi
lea    0xda2(%rip),%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     12ca <_rtc_handler+0x12a>
mov    0x8(%rbx),%rdi
lea    0xd90(%rip),%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
cmp    $0x4,%ebp
jne    12dc <_rtc_handler+0x13c>
test   %rax,%rax
jne    12dc <_rtc_handler+0x13c>
add    $0x10,%rbx
mov    %rbx,%rdi
call   10a0 <_rtc_settime@plt>
xor    %ebx,%ebx
jmp    12d3 <_rtc_handler+0x133>
xor    %ebx,%ebx
xor    %eax,%eax
call   10b0 <_rtc_gettime@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x8(%rbx),%rsi
lea    0xd57(%rip),%rdi
call   1080 <printf@plt>
jmp    11a8 <_rtc_handler+0x8>

LLVM IR (-O0):
@.str = [8 x i8] c"poweron\00"
@.str.1 = [9 x i8] c"poweroff\00"
@.str.2 = [11 x i8] c"clearalarm\00"
@.str.3 = [9 x i8] c"getalarm\00"
@.str.4 = [9 x i8] c"setalarm\00"
@.str.5 = [8 x i8] c"gettime\00"
@.str.6 = [8 x i8] c"settime\00"
@.str.7 = [44 x i8] c"unknown command or missing parameters: %s\0A\0A\00"
define i32 @_rtc_handler(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 2
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = call i32 (...) @_rtc_usage()
store i32 1, i32* %3
br label %90
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i64 @strncmp(i8* %13, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 7)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %10
%17 = call i32 (...) @rtc_poweron()
br label %88
18: ; preds = %10
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i64 @strncmp(i8* %21, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 8)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %18
%25 = call i32 (...) @rtc_poweroff()
br label %87
26: ; preds = %18
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i64 @strncmp(i8* %29, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 8)
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %26
%33 = call i32 (...) @rtc_clear_alarm()
br label %86
34: ; preds = %26
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 1
%37 = load i8*, i8** %36
%38 = call i64 @strncmp(i8* %37, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 8)
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %34
%41 = call i32 (...) @_rtc_getalarm()
br label %85
42: ; preds = %34
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 1
%45 = load i8*, i8** %44
%46 = call i64 @strncmp(i8* %45, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 8)
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %55
48: ; preds = %42
%49 = load i32, i32* %4
%50 = icmp eq i32 %49, 4
br i1 %50, label %51, label %55
51: ; preds = %48
%52 = load i8**, i8*** %5
%53 = getelementptr inbounds i8*, i8** %52, i64 2
%54 = call i32 @_rtc_setalarm(i8** %53)
br label %84
55: ; preds = %48, %42
%56 = load i8**, i8*** %5
%57 = getelementptr inbounds i8*, i8** %56, i64 1
%58 = load i8*, i8** %57
%59 = call i64 @strncmp(i8* %58, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32 7)
%60 = icmp eq i64 %59, 0
br i1 %60, label %61, label %63
61: ; preds = %55
%62 = call i32 (...) @_rtc_gettime()
br label %83
63: ; preds = %55
%64 = load i8**, i8*** %5
%65 = getelementptr inbounds i8*, i8** %64, i64 1
%66 = load i8*, i8** %65
%67 = call i64 @strncmp(i8* %66, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i32 7)
%68 = icmp eq i64 %67, 0
br i1 %68, label %69, label %76
69: ; preds = %63
%70 = load i32, i32* %4
%71 = icmp eq i32 %70, 4
br i1 %71, label %72, label %76
72: ; preds = %69
%73 = load i8**, i8*** %5
%74 = getelementptr inbounds i8*, i8** %73, i64 2
%75 = call i32 @_rtc_settime(i8** %74)
br label %82
76: ; preds = %69, %63
%77 = load i8**, i8*** %5
%78 = getelementptr inbounds i8*, i8** %77, i64 1
%79 = load i8*, i8** %78
%80 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.7, i64 0, i64 0), i8* %79)
%81 = call i32 (...) @_rtc_usage()
store i32 1, i32* %3
br label %90
82: ; preds = %72
br label %83
83: ; preds = %82, %61
br label %84
84: ; preds = %83, %51
br label %85
85: ; preds = %84, %40
br label %86
86: ; preds = %85, %32
br label %87
87: ; preds = %86, %24
br label %88
88: ; preds = %87, %16
br label %89
89: ; preds = %88
store i32 0, i32* %3
br label %90
90: ; preds = %89, %76, %8
%91 = load i32, i32* %3
ret i32 %91
}

LLVM IR (-O2):
@.str = [8 x i8] c"poweron\00"
@.str.1 = [9 x i8] c"poweroff\00"
@.str.2 = [11 x i8] c"clearalarm\00"
@.str.3 = [9 x i8] c"getalarm\00"
@.str.4 = [9 x i8] c"setalarm\00"
@.str.5 = [8 x i8] c"gettime\00"
@.str.6 = [8 x i8] c"settime\00"
@.str.7 = [44 x i8] c"unknown command or missing parameters: %s\0A\0A\00"
define i32 @_rtc_handler(i32 %0, i8** %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 (...) @_rtc_usage()
br label %58
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i64 @strncmp(i8* %8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 7)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %6
%12 = tail call i32 (...) @rtc_poweron()
br label %58
13: ; preds = %6
%14 = load i8*, i8** %7
%15 = tail call i64 @strncmp(i8* %14, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 8)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = tail call i32 (...) @rtc_poweroff()
br label %58
19: ; preds = %13
%20 = load i8*, i8** %7
%21 = tail call i64 @strncmp(i8* %20, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 8)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %19
%24 = tail call i32 (...) @rtc_clear_alarm()
br label %58
25: ; preds = %19
%26 = load i8*, i8** %7
%27 = tail call i64 @strncmp(i8* %26, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 8)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %25
%30 = tail call i32 (...) @_rtc_getalarm()
br label %58
31: ; preds = %25
%32 = load i8*, i8** %7
%33 = tail call i64 @strncmp(i8* %32, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 8)
%34 = icmp eq i64 %33, 0
%35 = icmp eq i32 %0, 4
%36 = and i1 %35, %34
br i1 %36, label %37, label %40
37: ; preds = %31
%38 = getelementptr inbounds i8*, i8** %1, i64 2
%39 = tail call i32 @_rtc_setalarm(i8** %38)
br label %58
40: ; preds = %31
%41 = load i8*, i8** %7
%42 = tail call i64 @strncmp(i8* %41, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32 7)
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %46
44: ; preds = %40
%45 = tail call i32 (...) @_rtc_gettime()
br label %58
46: ; preds = %40
%47 = load i8*, i8** %7
%48 = tail call i64 @strncmp(i8* %47, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i32 7)
%49 = icmp eq i64 %48, 0
%50 = and i1 %35, %49
br i1 %50, label %51, label %54
51: ; preds = %46
%52 = getelementptr inbounds i8*, i8** %1, i64 2
%53 = tail call i32 @_rtc_settime(i8** %52)
br label %58
54: ; preds = %46
%55 = load i8*, i8** %7
%56 = tail call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.7, i64 0, i64 0), i8* %55)
%57 = tail call i32 (...) @_rtc_usage()
br label %58
58: ; preds = %17, %29, %44, %51, %37, %23, %11, %54, %4
%59 = phi i32 [ 1, %4 ], [ 1, %54 ], [ 0, %11 ], [ 0, %23 ], [ 0, %37 ], [ 0, %51 ], [ 0, %44 ], [ 0, %29 ], [ 0, %17 ]
ret i32 %59
}