#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 uint64_t;
typedef int uint32_t;

/* Variables and functions */
uint32_t time_format(uint64_t ui64TimeMS, uint32_t ui32Resolution) {
  switch (ui32Resolution) {
  case 0x0:
    return ui64TimeMS;
  case 0x1:
    return ui64TimeMS / 1000;
  case 0x2:
    return ui64TimeMS / 60000;
  case 0x4:
    return ui64TimeMS / 3600000;
  case 0x8:
    return ui64TimeMS / 86400000;
  case 0x10:
    return ui64TimeMS / (uint64_t)2592000000;
  case 0x20:
    return ui64TimeMS / (uint64_t)31536000000;
  default:
    return ui64TimeMS;
  }
}


x86 assembly (clang, -O0):
<time_format>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x20,%rax
ja     11ac <time_format+0xac>
mov    -0x18(%rbp),%rax
lea    0xeda(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11b2 <time_format+0xb2>
mov    -0x8(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
jmp    11b2 <time_format+0xb2>
mov    -0x8(%rbp),%eax
mov    $0xea60,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
jmp    11b2 <time_format+0xb2>
mov    -0x8(%rbp),%eax
mov    $0x36ee80,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
jmp    11b2 <time_format+0xb2>
mov    -0x8(%rbp),%eax
mov    $0x5265c00,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
jmp    11b2 <time_format+0xb2>
mov    -0x8(%rbp),%eax
mov    $0x9a7ec800,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
jmp    11b2 <time_format+0xb2>
mov    -0x8(%rbp),%eax
mov    $0x57b12c00,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
jmp    11b2 <time_format+0xb2>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<time_format>:
mov    %edi,%eax
add    $0xffffffff,%esi
cmp    $0x1f,%esi
ja     11a2 <time_format+0xa2>
lea    0xeeb(%rip),%rcx
movslq (%rcx,%rsi,4),%rdx
add    %rcx,%rdx
jmp    *%rdx
cltq
imul   $0x10624dd3,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rax
jmp    11a0 <time_format+0xa0>
cltq
imul   $0x45e7b273,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x2e,%rax
jmp    11a0 <time_format+0xa0>
cltq
imul   $0x4a90be59,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x34,%rax
jmp    11a0 <time_format+0xa0>
cltq
imul   $0x31b5d43b,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x38,%rax
jmp    11a0 <time_format+0xa0>
cltq
imul   $0xffffffffaf4b5f7d,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x3d,%rax
jmp    11a0 <time_format+0xa0>
cltq
imul   $0xbad5e87,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x3a,%rax
add    %ecx,%eax
ret

LLVM IR (-O0):
define i32 @time_format(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* %5
switch i32 %6, label %27 [
i32 0, label %7
i32 1, label %9
i32 2, label %12
i32 4, label %15
i32 8, label %18
i32 16, label %21
i32 32, label %24
]
7: ; preds = %2
%8 = load i32, i32* %4
store i32 %8, i32* %3
br label %29
9: ; preds = %2
%10 = load i32, i32* %4
%11 = sdiv i32 %10, 1000
store i32 %11, i32* %3
br label %29
12: ; preds = %2
%13 = load i32, i32* %4
%14 = sdiv i32 %13, 60000
store i32 %14, i32* %3
br label %29
15: ; preds = %2
%16 = load i32, i32* %4
%17 = sdiv i32 %16, 3600000
store i32 %17, i32* %3
br label %29
18: ; preds = %2
%19 = load i32, i32* %4
%20 = sdiv i32 %19, 86400000
store i32 %20, i32* %3
br label %29
21: ; preds = %2
%22 = load i32, i32* %4
%23 = sdiv i32 %22, -1702967296
store i32 %23, i32* %3
br label %29
24: ; preds = %2
%25 = load i32, i32* %4
%26 = sdiv i32 %25, 1471228928
store i32 %26, i32* %3
br label %29
27: ; preds = %2
%28 = load i32, i32* %4
store i32 %28, i32* %3
br label %29
29: ; preds = %27, %24, %21, %18, %15, %12, %9, %7
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
define i32 @time_format(i32 %0, i32 %1) {
switch i32 %1, label %15 [
i32 32, label %13
i32 1, label %3
i32 2, label %5
i32 4, label %7
i32 8, label %9
i32 16, label %11
]
3: ; preds = %2
%4 = sdiv i32 %0, 1000
br label %15
5: ; preds = %2
%6 = sdiv i32 %0, 60000
br label %15
7: ; preds = %2
%8 = sdiv i32 %0, 3600000
br label %15
9: ; preds = %2
%10 = sdiv i32 %0, 86400000
br label %15
11: ; preds = %2
%12 = sdiv i32 %0, -1702967296
br label %15
13: ; preds = %2
%14 = sdiv i32 %0, 1471228928
br label %15
15: ; preds = %2, %13, %11, %9, %7, %5, %3
%16 = phi i32 [ %14, %13 ], [ %12, %11 ], [ %10, %9 ], [ %8, %7 ], [ %6, %5 ], [ %4, %3 ], [ %0, %2 ]
ret i32 %16
}