#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*/ time_t;
struct tm {
  int tm_mday;
  int tm_hour;
  int tm_min;
  int /*<<< orphan*/ tm_mon;
  int /*<<< orphan*/ tm_year;
};

/* Variables and functions */
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int get_time(int n) {
  struct tm *t;
  time_t tt;
  time(&tt);
  t = localtime(&tt);
  switch (n) {
  case 1:
    return t->tm_year + 1900;
    break;
  case 2:
    return t->tm_mon + 1;
    break;
  case 3:
    return t->tm_mday;
    break;
  case 4:
    return t->tm_hour;
    break;
  case 5:
    return t->tm_min;
    break;
  default:
    return 1;
  }
}


x86 assembly (clang, -O0):
<get_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
lea    -0x14(%rbp),%rdi
mov    %rdi,-0x28(%rbp)
call   1040 <time@plt>
mov    -0x28(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x4,%eax
ja     11c0 <get_time+0xa0>
mov    -0x20(%rbp),%rax
lea    0xe9b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%eax
add    $0x76c,%eax
mov    %eax,-0x4(%rbp)
jmp    11c7 <get_time+0xa7>
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11c7 <get_time+0xa7>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11c7 <get_time+0xa7>
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11c7 <get_time+0xa7>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11c7 <get_time+0xa7>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_time>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
lea    0x4(%rsp),%r14
mov    %r14,%rdi
call   1040 <time@plt>
mov    %r14,%rdi
call   1030 <localtime@plt>
add    $0xffffffff,%ebx
cmp    $0x4,%ebx
ja     1160 <get_time+0x40>
mov    %rax,%rcx
lea    0xeb3(%rip),%rax
movslq (%rax,%rbx,4),%rdx
add    %rax,%rdx
jmp    *%rdx
mov    $0x76c,%eax
add    0x10(%rcx),%eax
jmp    117b <get_time+0x5b>
mov    $0x1,%eax
jmp    117b <get_time+0x5b>
mov    0xc(%rcx),%eax
add    $0x1,%eax
jmp    117b <get_time+0x5b>
mov    (%rcx),%eax
jmp    117b <get_time+0x5b>
mov    0x4(%rcx),%eax
jmp    117b <get_time+0x5b>
mov    0x8(%rcx),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32 }
define i32 @get_time(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.tm*
%5 = alloca i32
store i32 %0, i32* %3
%6 = call i32 @time(i32* %5)
%7 = call %struct.tm* @localtime(i32* %5)
store %struct.tm* %7, %struct.tm** %4
%8 = load i32, i32* %3
switch i32 %8, label %31 [
i32 1, label %9
i32 2, label %14
i32 3, label %19
i32 4, label %23
i32 5, label %27
]
9: ; preds = %1
%10 = load %struct.tm*, %struct.tm** %4
%11 = getelementptr inbounds %struct.tm, %struct.tm* %10, i32 0, i32 4
%12 = load i32, i32* %11
%13 = add nsw i32 %12, 1900
store i32 %13, i32* %2
br label %32
14: ; preds = %1
%15 = load %struct.tm*, %struct.tm** %4
%16 = getelementptr inbounds %struct.tm, %struct.tm* %15, i32 0, i32 3
%17 = load i32, i32* %16
%18 = add nsw i32 %17, 1
store i32 %18, i32* %2
br label %32
19: ; preds = %1
%20 = load %struct.tm*, %struct.tm** %4
%21 = getelementptr inbounds %struct.tm, %struct.tm* %20, i32 0, i32 0
%22 = load i32, i32* %21
store i32 %22, i32* %2
br label %32
23: ; preds = %1
%24 = load %struct.tm*, %struct.tm** %4
%25 = getelementptr inbounds %struct.tm, %struct.tm* %24, i32 0, i32 1
%26 = load i32, i32* %25
store i32 %26, i32* %2
br label %32
27: ; preds = %1
%28 = load %struct.tm*, %struct.tm** %4
%29 = getelementptr inbounds %struct.tm, %struct.tm* %28, i32 0, i32 2
%30 = load i32, i32* %29
store i32 %30, i32* %2
br label %32
31: ; preds = %1
store i32 1, i32* %2
br label %32
32: ; preds = %31, %27, %23, %19, %14, %9
%33 = load i32, i32* %2
ret i32 %33
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32 }
define i32 @get_time(i32 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = call i32 @time(i32* %2)
%5 = call %struct.tm* @localtime(i32* %2)
switch i32 %0, label %23 [
i32 1, label %6
i32 2, label %10
i32 3, label %14
i32 4, label %17
i32 5, label %20
]
6: ; preds = %1
%7 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 4
%8 = load i32, i32* %7
%9 = add nsw i32 %8, 1900
br label %23
10: ; preds = %1
%11 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 3
%12 = load i32, i32* %11
%13 = add nsw i32 %12, 1
br label %23
14: ; preds = %1
%15 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 0
%16 = load i32, i32* %15
br label %23
17: ; preds = %1
%18 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 1
%19 = load i32, i32* %18
br label %23
20: ; preds = %1
%21 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 2
%22 = load i32, i32* %21
br label %23
23: ; preds = %1, %20, %17, %14, %10, %6
%24 = phi i32 [ %22, %20 ], [ %19, %17 ], [ %16, %14 ], [ %13, %10 ], [ %9, %6 ], [ 1, %1 ]
ret i32 %24
}