#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_output_size(unsigned short width,
                                    unsigned short height) {
  width = ((width + 1) >> 1) << 1;
  height = (height + 1) >> 1;
  saa7114_write_reg(0xCC, (unsigned char)(width & 0x00FF));
  saa7114_write_reg(0xCD, (unsigned char)(width >> 8));
  saa7114_write_reg(0xCE, (unsigned char)(height & 0x00FF));
  saa7114_write_reg(0xCF, (unsigned char)(height >> 8));
  gfx_decoder_software_reset();
  return (0);
}


x86 assembly (clang, -O0):
<saa7114_set_decoder_output_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %si,%ax
mov    %di,%cx
mov    %cx,-0x2(%rbp)
mov    %ax,-0x4(%rbp)
movzwl -0x2(%rbp),%eax
add    $0x1,%eax
sar    $0x1,%eax
shl    $0x1,%eax
mov    %ax,-0x2(%rbp)
movzwl -0x4(%rbp),%eax
add    $0x1,%eax
sar    $0x1,%eax
mov    %ax,-0x4(%rbp)
movzwl -0x2(%rbp),%eax
and    $0xff,%eax
mov    $0xcc,%edi
movzbl %al,%esi
call   1030 <saa7114_write_reg@plt>
movzwl -0x2(%rbp),%eax
sar    $0x8,%eax
mov    $0xcd,%edi
movzbl %al,%esi
call   1030 <saa7114_write_reg@plt>
movzwl -0x4(%rbp),%eax
and    $0xff,%eax
mov    $0xce,%edi
movzbl %al,%esi
call   1030 <saa7114_write_reg@plt>
movzwl -0x4(%rbp),%eax
sar    $0x8,%eax
mov    $0xcf,%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_output_size>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %edi,%ebx
add    $0x1,%ebx
add    $0x1,%ebp
mov    %ebp,%r14d
shr    %r14d
mov    %ebx,%eax
and    $0xfe,%eax
mov    $0xcc,%edi
mov    %eax,%esi
call   1030 <saa7114_write_reg@plt>
movzbl %bh,%esi
mov    $0xcd,%edi
call   1030 <saa7114_write_reg@plt>
movzbl %r14b,%esi
mov    $0xce,%edi
call   1030 <saa7114_write_reg@plt>
shr    $0x9,%ebp
mov    $0xcf,%edi
mov    %ebp,%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_output_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* %3
%6 = zext i16 %5 to i32
%7 = add nsw i32 %6, 1
%8 = ashr i32 %7, 1
%9 = shl i32 %8, 1
%10 = trunc i32 %9 to i16
store i16 %10, i16* %3
%11 = load i16, i16* %4
%12 = zext i16 %11 to i32
%13 = add nsw i32 %12, 1
%14 = ashr i32 %13, 1
%15 = trunc i32 %14 to i16
store i16 %15, i16* %4
%16 = load i16, i16* %3
%17 = zext i16 %16 to i32
%18 = and i32 %17, 255
%19 = trunc i32 %18 to i8
%20 = call i32 @saa7114_write_reg(i32 204, i8 zeroext %19)
%21 = load i16, i16* %3
%22 = zext i16 %21 to i32
%23 = ashr i32 %22, 8
%24 = trunc i32 %23 to i8
%25 = call i32 @saa7114_write_reg(i32 205, i8 zeroext %24)
%26 = load i16, i16* %4
%27 = zext i16 %26 to i32
%28 = and i32 %27, 255
%29 = trunc i32 %28 to i8
%30 = call i32 @saa7114_write_reg(i32 206, i8 zeroext %29)
%31 = load i16, i16* %4
%32 = zext i16 %31 to i32
%33 = ashr i32 %32, 8
%34 = trunc i32 %33 to i8
%35 = call i32 @saa7114_write_reg(i32 207, i8 zeroext %34)
%36 = call i32 (...) @gfx_decoder_software_reset()
ret i32 0
}

LLVM IR (-O2):
define i32 @saa7114_set_decoder_output_size(i16 zeroext %0, i16 zeroext %1) {
%3 = add i16 %0, 1
%4 = zext i16 %1 to i32
%5 = add nuw nsw i32 %4, 1
%6 = lshr i32 %5, 1
%7 = trunc i16 %3 to i8
%8 = and i8 %7, -2
%9 = tail call i32 @saa7114_write_reg(i32 204, i8 zeroext %8)
%10 = lshr i16 %3, 8
%11 = trunc i16 %10 to i8
%12 = tail call i32 @saa7114_write_reg(i32 205, i8 zeroext %11)
%13 = trunc i32 %6 to i8
%14 = tail call i32 @saa7114_write_reg(i32 206, i8 zeroext %13)
%15 = lshr i32 %5, 9
%16 = trunc i32 %15 to i8
%17 = tail call i32 @saa7114_write_reg(i32 207, i8 zeroext %16)
%18 = tail call i32 (...) @gfx_decoder_software_reset()
ret i32 0
}