#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*/ saa7114_read_reg(unsigned char, unsigned char *);
int saa7114_get_decoder_vbi_format(int line) {
  unsigned char format = 0, data;
  saa7114_read_reg((unsigned char)(0x3F + line), &data);
  switch (data) {
  case 0xFF:
    format = 0x1;
    break;
  case 0x77:
    format = 0x2;
    break;
  case 0x55:
    format = 0x4;
    break;
  case 0xCC:
    format = 0x8;
    break;
  }
  return (format);
}


x86 assembly (clang, -O0):
<saa7114_get_decoder_vbi_format>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movb   $0x0,-0x5(%rbp)
mov    -0x4(%rbp),%eax
add    $0x3f,%eax
movzbl %al,%edi
lea    -0x6(%rbp),%rsi
call   1030 <saa7114_read_reg@plt>
movzbl -0x6(%rbp),%eax
mov    %eax,-0xc(%rbp)
sub    $0x55,%eax
je     118f <saa7114_get_decoder_vbi_format+0x7f>
jmp    1146 <saa7114_get_decoder_vbi_format+0x36>
mov    -0xc(%rbp),%eax
sub    $0x77,%eax
je     1186 <saa7114_get_decoder_vbi_format+0x76>
jmp    1157 <saa7114_get_decoder_vbi_format+0x47>
mov    -0xc(%rbp),%eax
sub    $0xcc,%eax
je     1198 <saa7114_get_decoder_vbi_format+0x88>
jmp    116a <saa7114_get_decoder_vbi_format+0x5a>
mov    -0xc(%rbp),%eax
sub    $0xff,%eax
jne    119c <saa7114_get_decoder_vbi_format+0x8c>
jmp    117d <saa7114_get_decoder_vbi_format+0x6d>
movb   $0x1,-0x5(%rbp)
jmp    119c <saa7114_get_decoder_vbi_format+0x8c>
movb   $0x2,-0x5(%rbp)
jmp    119c <saa7114_get_decoder_vbi_format+0x8c>
movb   $0x4,-0x5(%rbp)
jmp    119c <saa7114_get_decoder_vbi_format+0x8c>
movb   $0x8,-0x5(%rbp)
movzbl -0x5(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<saa7114_get_decoder_vbi_format>:
push   %rax
add    $0x3f,%dil
movzbl %dil,%edi
lea    0x7(%rsp),%rsi
call   1030 <saa7114_read_reg@plt>
xor    %eax,%eax
mov    0x7(%rsp),%cl
cmp    $0x54,%cl
jg     113f <saa7114_get_decoder_vbi_format+0x2f>
cmp    $0xcc,%cl
je     1150 <saa7114_get_decoder_vbi_format+0x40>
cmp    $0xff,%cl
jne    1155 <saa7114_get_decoder_vbi_format+0x45>
mov    $0x1,%eax
pop    %rcx
ret
cmp    $0x55,%cl
je     1157 <saa7114_get_decoder_vbi_format+0x47>
cmp    $0x77,%cl
jne    1155 <saa7114_get_decoder_vbi_format+0x45>
mov    $0x2,%eax
pop    %rcx
ret
mov    $0x8,%eax
pop    %rcx
ret
mov    $0x4,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @saa7114_get_decoder_vbi_format(i32 %0) {
%2 = alloca i32
%3 = alloca i8
%4 = alloca i8
store i32 %0, i32* %2
store i8 0, i8* %3
%5 = load i32, i32* %2
%6 = add nsw i32 63, %5
%7 = trunc i32 %6 to i8
%8 = call i32 @saa7114_read_reg(i8 zeroext %7, i8* %4)
%9 = load i8, i8* %4
%10 = zext i8 %9 to i32
switch i32 %10, label %15 [
i32 255, label %11
i32 119, label %12
i32 85, label %13
i32 204, label %14
]
11: ; preds = %1
store i8 1, i8* %3
br label %15
12: ; preds = %1
store i8 2, i8* %3
br label %15
13: ; preds = %1
store i8 4, i8* %3
br label %15
14: ; preds = %1
store i8 8, i8* %3
br label %15
15: ; preds = %1, %14, %13, %12, %11
%16 = load i8, i8* %3
%17 = zext i8 %16 to i32
ret i32 %17
}

LLVM IR (-O2):
define i32 @saa7114_get_decoder_vbi_format(i32 %0) {
%2 = alloca i8
%3 = trunc i32 %0 to i8
%4 = add i8 %3, 63
%5 = call i32 @saa7114_read_reg(i8 zeroext %4, i8* %2)
%6 = load i8, i8* %2
switch i8 %6, label %11 [
i8 -1, label %7
i8 119, label %8
i8 85, label %9
i8 -52, label %10
]
7: ; preds = %1
br label %11
8: ; preds = %1
br label %11
9: ; preds = %1
br label %11
10: ; preds = %1
br label %11
11: ; preds = %1, %10, %9, %8, %7
%12 = phi i32 [ 0, %1 ], [ 8, %10 ], [ 4, %9 ], [ 2, %8 ], [ 1, %7 ]
ret i32 %12
}