#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*/ gfx_decoder_software_reset();
int /*<<< orphan*/ saa7114_write_reg(int, unsigned char);
int saa7114_set_decoder_input_size(unsigned short width,
                                   unsigned short height) {
  height = (height + 1) >> 1;
  saa7114_write_reg(0xC6, (unsigned char)(width & 0x00FF));
  saa7114_write_reg(0xC7, (unsigned char)(width >> 8));
  saa7114_write_reg(0xCA, (unsigned char)(height & 0x00FF));
  saa7114_write_reg(0xCB, (unsigned char)(height >> 8));
  gfx_decoder_software_reset();
  return (0);
}


x86 assembly (clang, -O0):
<saa7114_set_decoder_input_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %si,%ax
mov    %di,%cx
mov    %cx,-0x2(%rbp)
mov    %ax,-0x4(%rbp)
movzwl -0x4(%rbp),%eax
add    $0x1,%eax
sar    $0x1,%eax
mov    %ax,-0x4(%rbp)
movzwl -0x2(%rbp),%eax
and    $0xff,%eax
mov    $0xc6,%edi
movzbl %al,%esi
call   1030 <saa7114_write_reg@plt>
movzwl -0x2(%rbp),%eax
sar    $0x8,%eax
mov    $0xc7,%edi
movzbl %al,%esi
call   1030 <saa7114_write_reg@plt>
movzwl -0x4(%rbp),%eax
and    $0xff,%eax
mov    $0xca,%edi
movzbl %al,%esi
call   1030 <saa7114_write_reg@plt>
movzwl -0x4(%rbp),%eax
sar    $0x8,%eax
mov    $0xcb,%edi
movzbl %al,%esi
call   1030 <saa7114_write_reg@plt>
mov    $0x0,%al
call   1040 <gfx_decoder_software_reset@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<saa7114_set_decoder_input_size>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebx
mov    %edi,%ebp
add    $0x1,%ebx
mov    %ebx,%r14d
shr    %r14d
movzbl %bpl,%esi
mov    $0xc6,%edi
call   1030 <saa7114_write_reg@plt>
shr    $0x8,%ebp
mov    $0xc7,%edi
mov    %ebp,%esi
call   1030 <saa7114_write_reg@plt>
movzbl %r14b,%esi
mov    $0xca,%edi
call   1030 <saa7114_write_reg@plt>
shr    $0x9,%ebx
mov    $0xcb,%edi
mov    %ebx,%esi
call   1030 <saa7114_write_reg@plt>
xor    %eax,%eax
call   1040 <gfx_decoder_software_reset@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @saa7114_set_decoder_input_size(i16 zeroext %0, i16 zeroext %1) {
%3 = alloca i16
%4 = alloca i16
store i16 %0, i16* %3
store i16 %1, i16* %4
%5 = load i16, i16* %4
%6 = zext i16 %5 to i32
%7 = add nsw i32 %6, 1
%8 = ashr i32 %7, 1
%9 = trunc i32 %8 to i16
store i16 %9, i16* %4
%10 = load i16, i16* %3
%11 = zext i16 %10 to i32
%12 = and i32 %11, 255
%13 = trunc i32 %12 to i8
%14 = call i32 @saa7114_write_reg(i32 198, i8 zeroext %13)
%15 = load i16, i16* %3
%16 = zext i16 %15 to i32
%17 = ashr i32 %16, 8
%18 = trunc i32 %17 to i8
%19 = call i32 @saa7114_write_reg(i32 199, i8 zeroext %18)
%20 = load i16, i16* %4
%21 = zext i16 %20 to i32
%22 = and i32 %21, 255
%23 = trunc i32 %22 to i8
%24 = call i32 @saa7114_write_reg(i32 202, i8 zeroext %23)
%25 = load i16, i16* %4
%26 = zext i16 %25 to i32
%27 = ashr i32 %26, 8
%28 = trunc i32 %27 to i8
%29 = call i32 @saa7114_write_reg(i32 203, i8 zeroext %28)
%30 = call i32 (...) @gfx_decoder_software_reset()
ret i32 0
}

LLVM IR (-O2):
define i32 @saa7114_set_decoder_input_size(i16 zeroext %0, i16 zeroext %1) {
%3 = zext i16 %1 to i32
%4 = add nuw nsw i32 %3, 1
%5 = lshr i32 %4, 1
%6 = trunc i16 %0 to i8
%7 = tail call i32 @saa7114_write_reg(i32 198, i8 zeroext %6)
%8 = lshr i16 %0, 8
%9 = trunc i16 %8 to i8
%10 = tail call i32 @saa7114_write_reg(i32 199, i8 zeroext %9)
%11 = trunc i32 %5 to i8
%12 = tail call i32 @saa7114_write_reg(i32 202, i8 zeroext %11)
%13 = lshr i32 %4, 9
%14 = trunc i32 %13 to i8
%15 = tail call i32 @saa7114_write_reg(i32 203, i8 zeroext %14)
%16 = tail call i32 (...) @gfx_decoder_software_reset()
ret i32 0
}