#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 */
struct scm_timestamping {
  int /*<<< orphan*/ *ts;
};

/* Variables and functions */
int /*<<< orphan*/ __print_timestamp(char const *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ error(int, int /*<<< orphan*/, char *, int);
void print_timestamp(struct scm_timestamping *tss, int tstype, int tskey) {
  const char *tsname;
  switch (tstype) {
  case 1:
    tsname = "  ENQ";
    break;
  case 0:
    tsname = "  SND";
    break;
  case 2:
    tsname = "  ACK";
    break;
  default:
    error(1, 0, "unknown timestamp type: %u", tstype);
  }
  __print_timestamp(tsname, &tss->ts[0], tskey);
}


x86 assembly (clang, -O0):
<print_timestamp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
test   %eax,%eax
je     1177 <print_timestamp+0x57>
jmp    1145 <print_timestamp+0x25>
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
je     1167 <print_timestamp+0x47>
jmp    1156 <print_timestamp+0x36>
mov    -0x1c(%rbp),%eax
sub    $0x2,%eax
je     1187 <print_timestamp+0x67>
jmp    1197 <print_timestamp+0x77>
lea    0xe92(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    11ad <print_timestamp+0x8d>
lea    0xe88(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    11ad <print_timestamp+0x8d>
lea    0xe7e(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    11ad <print_timestamp+0x8d>
mov    -0xc(%rbp),%ecx
mov    $0x1,%edi
xor    %esi,%esi
lea    0xe6a(%rip),%rdx
call   1030 <error@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    (%rax),%rsi
mov    -0x10(%rbp),%edx
call   1040 <__print_timestamp@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_timestamp>:
push   %rax
mov    %esi,%ecx
cmp    $0x3,%esi
jae    1145 <print_timestamp+0x25>
movslq %ecx,%rax
lea    0xefe(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
mov    (%rdi),%rsi
mov    %rax,%rdi
pop    %rax
jmp    1040 <__print_timestamp@plt>
lea    0xec6(%rip),%rdx
mov    $0x1,%edi
xor    %esi,%esi
call   1030 <error@plt>

LLVM IR (-O0):
%struct.scm_timestamping = type { i32* }
@.str = [6 x i8] c" ENQ\00"
@.str.1 = [6 x i8] c" SND\00"
@.str.2 = [6 x i8] c" ACK\00"
@.str.3 = [27 x i8] c"unknown timestamp type: %u\00"
define void @print_timestamp(%struct.scm_timestamping* %0, i32 %1, i32 %2) {
%4 = alloca %struct.scm_timestamping*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
store %struct.scm_timestamping* %0, %struct.scm_timestamping** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %5
switch i32 %8, label %12 [
i32 1, label %9
i32 0, label %10
i32 2, label %11
]
9: ; preds = %3
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %7
br label %15
10: ; preds = %3
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8** %7
br label %15
11: ; preds = %3
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8** %7
br label %15
12: ; preds = %3
%13 = load i32, i32* %5
%14 = call i32 @error(i32 1, i32 0, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %13)
br label %15
15: ; preds = %12, %11, %10, %9
%16 = load i8*, i8** %7
%17 = load %struct.scm_timestamping*, %struct.scm_timestamping** %4
%18 = getelementptr inbounds %struct.scm_timestamping, %struct.scm_timestamping* %17, i32 0, i32 0
%19 = load i32*, i32** %18
%20 = getelementptr inbounds i32, i32* %19, i64 0
%21 = load i32, i32* %6
%22 = call i32 @__print_timestamp(i8* %16, i32* %20, i32 %21)
ret void
}

LLVM IR (-O2):
%struct.scm_timestamping = type { i32* }
@.str = [6 x i8] c" ENQ\00"
@.str.1 = [6 x i8] c" SND\00"
@.str.2 = [6 x i8] c" ACK\00"
@.str.3 = [27 x i8] c"unknown timestamp type: %u\00"
@reltable.print_timestamp = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.1 to i64), i64 ptrtoint ([3 x i32]* @reltable.print_timestamp to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str to i64), i64 ptrtoint ([3 x i32]* @reltable.print_timestamp to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.2 to i64), i64 ptrtoint ([3 x i32]* @reltable.print_timestamp to i64)) to i32)]
define void @print_timestamp(%struct.scm_timestamping* nocapture %0, i32 %1, i32 %2) {
%4 = icmp ult i32 %1, 3
br i1 %4, label %7, label %5
5: ; preds = %3
%6 = tail call i32 @error(i32 1, i32 0, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %1)
unreachable
7: ; preds = %3
%8 = sext i32 %1 to i64
%9 = shl i64 %8, 2
%10 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.print_timestamp to i8*), i64 %9)
%11 = getelementptr inbounds %struct.scm_timestamping, %struct.scm_timestamping* %0, i64 0, i32 0
%12 = load i32*, i32** %11
%13 = tail call i32 @__print_timestamp(i8* %10, i32* %12, i32 %2)
ret void
}