#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 uint32_t;

/* Variables and functions */
#define V4L2_BUF_FLAG_TIMESTAMP_COPY 132
int V4L2_BUF_FLAG_TIMESTAMP_MASK;
#define V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC 131
#define V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN 130
#define V4L2_BUF_FLAG_TSTAMP_SRC_EOF 129
int V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
#define V4L2_BUF_FLAG_TSTAMP_SRC_SOE 128
void get_ts_flags(uint32_t flags, const char **ts_type,
                  const char **ts_source) {
  switch (flags & V4L2_BUF_FLAG_TIMESTAMP_MASK) {
  case V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN:
    *ts_type = "unk";
    break;
  case V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC:
    *ts_type = "mono";
    break;
  case V4L2_BUF_FLAG_TIMESTAMP_COPY:
    *ts_type = "copy";
    break;
  default:
    *ts_type = "inv";
  }
  switch (flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK) {
  case V4L2_BUF_FLAG_TSTAMP_SRC_EOF:
    *ts_source = "EoF";
    break;
  case V4L2_BUF_FLAG_TSTAMP_SRC_SOE:
    *ts_source = "SoE";
    break;
  default:
    *ts_source = "inv";
  }
}


x86 assembly (clang, -O0):
<get_ts_flags>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2ec7(%rip),%rcx
mov    (%rcx),%ecx
and    %ecx,%eax
mov    %eax,-0x1c(%rbp)
sub    $0x82,%eax
je     1156 <get_ts_flags+0x56>
jmp    1130 <get_ts_flags+0x30>
mov    -0x1c(%rbp),%eax
sub    $0x83,%eax
je     1169 <get_ts_flags+0x69>
jmp    1143 <get_ts_flags+0x43>
mov    -0x1c(%rbp),%eax
sub    $0x84,%eax
je     117c <get_ts_flags+0x7c>
jmp    118f <get_ts_flags+0x8f>
mov    -0x10(%rbp),%rax
lea    0xe9f(%rip),%rcx
mov    %rcx,(%rax)
jmp    119d <get_ts_flags+0x9d>
mov    -0x10(%rbp),%rax
lea    0xe90(%rip),%rcx
mov    %rcx,(%rax)
jmp    119d <get_ts_flags+0x9d>
mov    -0x10(%rbp),%rax
lea    0xe82(%rip),%rcx
mov    %rcx,(%rax)
jmp    119d <get_ts_flags+0x9d>
mov    -0x10(%rbp),%rax
lea    0xe74(%rip),%rcx
mov    %rcx,(%rax)
mov    -0x4(%rbp),%eax
mov    0x2e49(%rip),%rcx
mov    (%rcx),%ecx
and    %ecx,%eax
mov    %eax,-0x20(%rbp)
sub    $0x80,%eax
je     11e4 <get_ts_flags+0xe4>
jmp    11be <get_ts_flags+0xbe>
mov    -0x20(%rbp),%eax
sub    $0x81,%eax
jne    11f7 <get_ts_flags+0xf7>
jmp    11d1 <get_ts_flags+0xd1>
mov    -0x18(%rbp),%rax
lea    0xe36(%rip),%rcx
mov    %rcx,(%rax)
jmp    1205 <get_ts_flags+0x105>
mov    -0x18(%rbp),%rax
lea    0xe27(%rip),%rcx
mov    %rcx,(%rax)
jmp    1205 <get_ts_flags+0x105>
mov    -0x18(%rbp),%rax
lea    0xe0c(%rip),%rcx
mov    %rcx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_ts_flags>:
mov    0x2ed9(%rip),%rax
mov    (%rax),%ecx
and    %edi,%ecx
add    $0xffffff7e,%ecx
lea    0xef6(%rip),%r8
mov    %r8,%rax
cmp    $0x2,%ecx
ja     1131 <get_ts_flags+0x31>
movslq %ecx,%rax
lea    0xef2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
mov    %rax,(%rsi)
mov    0x2eb5(%rip),%rax
and    (%rax),%edi
cmp    $0x80,%edi
lea    0xecc(%rip),%rax
cmove  %rax,%r8
cmp    $0x81,%edi
lea    0xeb7(%rip),%rax
cmovne %r8,%rax
mov    %rax,(%rdx)
ret

LLVM IR (-O0):
@V4L2_BUF_FLAG_TIMESTAMP_MASK = global i32 0
@.str = [4 x i8] c"unk\00"
@.str.1 = [5 x i8] c"mono\00"
@.str.2 = [5 x i8] c"copy\00"
@.str.3 = [4 x i8] c"inv\00"
@V4L2_BUF_FLAG_TSTAMP_SRC_MASK = global i32 0
@.str.4 = [4 x i8] c"EoF\00"
@.str.5 = [4 x i8] c"SoE\00"
define void @get_ts_flags(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8**
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8** %2, i8*** %6
%7 = load i32, i32* %4
%8 = load i32, i32* @V4L2_BUF_FLAG_TIMESTAMP_MASK
%9 = and i32 %7, %8
switch i32 %9, label %16 [
i32 130, label %10
i32 131, label %12
i32 132, label %14
]
10: ; preds = %3
%11 = load i8**, i8*** %5
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %11
br label %18
12: ; preds = %3
%13 = load i8**, i8*** %5
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %13
br label %18
14: ; preds = %3
%15 = load i8**, i8*** %5
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %15
br label %18
16: ; preds = %3
%17 = load i8**, i8*** %5
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8** %17
br label %18
18: ; preds = %16, %14, %12, %10
%19 = load i32, i32* %4
%20 = load i32, i32* @V4L2_BUF_FLAG_TSTAMP_SRC_MASK
%21 = and i32 %19, %20
switch i32 %21, label %26 [
i32 129, label %22
i32 128, label %24
]
22: ; preds = %18
%23 = load i8**, i8*** %6
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8** %23
br label %28
24: ; preds = %18
%25 = load i8**, i8*** %6
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8** %25
br label %28
26: ; preds = %18
%27 = load i8**, i8*** %6
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8** %27
br label %28
28: ; preds = %26, %24, %22
ret void
}

LLVM IR (-O2):
@V4L2_BUF_FLAG_TIMESTAMP_MASK = global i32 0
@.str = [4 x i8] c"unk\00"
@.str.1 = [5 x i8] c"mono\00"
@.str.2 = [5 x i8] c"copy\00"
@.str.3 = [4 x i8] c"inv\00"
@V4L2_BUF_FLAG_TSTAMP_SRC_MASK = global i32 0
@.str.4 = [4 x i8] c"EoF\00"
@.str.5 = [4 x i8] c"SoE\00"
@reltable.get_ts_flags = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str to i64), i64 ptrtoint ([3 x i32]* @reltable.get_ts_flags to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.1 to i64), i64 ptrtoint ([3 x i32]* @reltable.get_ts_flags to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.2 to i64), i64 ptrtoint ([3 x i32]* @reltable.get_ts_flags to i64)) to i32)]
define void @get_ts_flags(i32 %0, i8** nocapture writeonly %1, i8** nocapture writeonly %2) {
%4 = load i32, i32* @V4L2_BUF_FLAG_TIMESTAMP_MASK
%5 = and i32 %4, %0
%6 = add i32 %5, -130
%7 = icmp ult i32 %6, 3
br i1 %7, label %8, label %12
8: ; preds = %3
%9 = sext i32 %6 to i64
%10 = shl i64 %9, 2
%11 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.get_ts_flags to i8*), i64 %10)
br label %12
12: ; preds = %3, %8
%13 = phi i8* [ %11, %8 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), %3 ]
store i8* %13, i8** %1
%14 = load i32, i32* @V4L2_BUF_FLAG_TSTAMP_SRC_MASK
%15 = and i32 %14, %0
%16 = icmp eq i32 %15, 128
%17 = select i1 %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0)
%18 = icmp eq i32 %15, 129
%19 = select i1 %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %17
store i8* %19, i8** %2
ret void
}