#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*/ panic(char *);
int rtc_get_day();
int rtc_get_hour();
int rtc_get_minute();
int rtc_get_month();
int rtc_get_second();
int rtc_get_year();
int current_time(int input) {
  switch (input) {
  case 0:
    return rtc_get_second();
  case 1:
    return rtc_get_minute();
  case 2:
    return rtc_get_hour();
  case 3:
    return rtc_get_day();
  case 4:
    return rtc_get_month();
  case 5:
    return rtc_get_year();
  default:
    panic("Input to current_time() was either smaller than zero or larger than "
          "5");
  }
  return 0;
}


x86 assembly (clang, -O0):
<current_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %rax,-0x10(%rbp)
sub    $0x5,%rax
ja     11fa <current_time+0x8a>
mov    -0x10(%rbp),%rax
lea    0xe69(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1090 <rtc_get_second@plt>
mov    %eax,-0x4(%rbp)
jmp    120d <current_time+0x9d>
mov    $0x0,%al
call   1070 <rtc_get_minute@plt>
mov    %eax,-0x4(%rbp)
jmp    120d <current_time+0x9d>
mov    $0x0,%al
call   1060 <rtc_get_hour@plt>
mov    %eax,-0x4(%rbp)
jmp    120d <current_time+0x9d>
mov    $0x0,%al
call   1030 <rtc_get_day@plt>
mov    %eax,-0x4(%rbp)
jmp    120d <current_time+0x9d>
mov    $0x0,%al
call   1080 <rtc_get_month@plt>
mov    %eax,-0x4(%rbp)
jmp    120d <current_time+0x9d>
mov    $0x0,%al
call   1050 <rtc_get_year@plt>
mov    %eax,-0x4(%rbp)
jmp    120d <current_time+0x9d>
lea    0xe17(%rip),%rdi
call   1040 <panic@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<current_time>:
push   %rax
cmp    $0x5,%edi
ja     1190 <current_time+0x20>
mov    %edi,%eax
lea    0xe81(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
xor    %eax,%eax
pop    %rcx
jmp    1090 <rtc_get_second@plt>
lea    0xe81(%rip),%rdi
call   1040 <panic@plt>
xor    %eax,%eax
pop    %rcx
ret
xor    %eax,%eax
pop    %rcx
jmp    1070 <rtc_get_minute@plt>
xor    %eax,%eax
pop    %rcx
jmp    1060 <rtc_get_hour@plt>
xor    %eax,%eax
pop    %rcx
jmp    1030 <rtc_get_day@plt>
xor    %eax,%eax
pop    %rcx
jmp    1080 <rtc_get_month@plt>
xor    %eax,%eax
pop    %rcx
jmp    1050 <rtc_get_year@plt>

LLVM IR (-O0):
@.str = [70 x i8] c"Input to current_time() was either smaller than zero or larger than 5\00"
define i32 @current_time(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %17 [
i32 0, label %5
i32 1, label %7
i32 2, label %9
i32 3, label %11
i32 4, label %13
i32 5, label %15
]
5: ; preds = %1
%6 = call i32 (...) @rtc_get_second()
store i32 %6, i32* %2
br label %20
7: ; preds = %1
%8 = call i32 (...) @rtc_get_minute()
store i32 %8, i32* %2
br label %20
9: ; preds = %1
%10 = call i32 (...) @rtc_get_hour()
store i32 %10, i32* %2
br label %20
11: ; preds = %1
%12 = call i32 (...) @rtc_get_day()
store i32 %12, i32* %2
br label %20
13: ; preds = %1
%14 = call i32 (...) @rtc_get_month()
store i32 %14, i32* %2
br label %20
15: ; preds = %1
%16 = call i32 (...) @rtc_get_year()
store i32 %16, i32* %2
br label %20
17: ; preds = %1
%18 = call i32 @panic(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %17
store i32 0, i32* %2
br label %20
20: ; preds = %19, %15, %13, %11, %9, %7, %5
%21 = load i32, i32* %2
ret i32 %21
}

LLVM IR (-O2):
@.str = [70 x i8] c"Input to current_time() was either smaller than zero or larger than 5\00"
define i32 @current_time(i32 %0) {
switch i32 %0, label %14 [
i32 0, label %2
i32 1, label %4
i32 2, label %6
i32 3, label %8
i32 4, label %10
i32 5, label %12
]
2: ; preds = %1
%3 = tail call i32 (...) @rtc_get_second()
br label %16
4: ; preds = %1
%5 = tail call i32 (...) @rtc_get_minute()
br label %16
6: ; preds = %1
%7 = tail call i32 (...) @rtc_get_hour()
br label %16
8: ; preds = %1
%9 = tail call i32 (...) @rtc_get_day()
br label %16
10: ; preds = %1
%11 = tail call i32 (...) @rtc_get_month()
br label %16
12: ; preds = %1
%13 = tail call i32 (...) @rtc_get_year()
br label %16
14: ; preds = %1
%15 = tail call i32 @panic(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %14, %12, %10, %8, %6, %4, %2
%17 = phi i32 [ 0, %14 ], [ %13, %12 ], [ %11, %10 ], [ %9, %8 ], [ %7, %6 ], [ %5, %4 ], [ %3, %2 ]
ret i32 %17
}