#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 uint8_t;
typedef int uint16_t;

/* Variables and functions */
scalar_t__ mp2vseqdx_get_color(int *);
void mp2vseqdx_set_horizontal(uint8_t *p_mp2vseqdx, uint16_t i_horizontal) {
  unsigned int base = mp2vseqdx_get_color(p_mp2vseqdx) ? 8 : 5;
  p_mp2vseqdx[base] &= 0xfe;
  p_mp2vseqdx[base] = (i_horizontal >> 6) & 0xff;
  p_mp2vseqdx[base + 1] &= 0x1;
  p_mp2vseqdx[base + 1] |= ((i_horizontal << 2) & 0xfc) | 0x2;
}


x86 assembly (clang, -O0):
<mp2vseqdx_set_horizontal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <mp2vseqdx_get_color@plt>
mov    %rax,%rdx
mov    $0x5,%eax
mov    $0x8,%ecx
cmp    $0x0,%rdx
cmovne %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
mov    (%rax,%rcx,4),%edx
and    $0xfe,%edx
mov    %edx,(%rax,%rcx,4)
mov    -0xc(%rbp),%edx
sar    $0x6,%edx
and    $0xff,%edx
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,%ecx
mov    (%rax,%rcx,4),%edx
and    $0x1,%edx
mov    %edx,(%rax,%rcx,4)
mov    -0xc(%rbp),%edx
shl    $0x2,%edx
and    $0xfc,%edx
or     $0x2,%edx
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,%ecx
or     (%rax,%rcx,4),%edx
mov    %edx,(%rax,%rcx,4)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mp2vseqdx_set_horizontal>:
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%r14
call   1030 <mp2vseqdx_get_color@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
lea    (%rcx,%rcx,2),%eax
add    $0x5,%eax
mov    %ebx,%ecx
shr    $0x6,%ecx
movzbl %cl,%ecx
mov    %ecx,(%r14,%rax,4)
mov    0x4(%r14,%rax,4),%ecx
and    $0x1,%ecx
and    $0x3f,%ebx
lea    (%rcx,%rbx,4),%ecx
add    $0x2,%ecx
mov    %ecx,0x4(%r14,%rax,4)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @mp2vseqdx_set_horizontal(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%6 = load i32*, i32** %3
%7 = call i64 @mp2vseqdx_get_color(i32* %6)
%8 = icmp ne i64 %7, 0
%9 = zext i1 %8 to i64
%10 = select i1 %8, i32 8, i32 5
store i32 %10, i32* %5
%11 = load i32*, i32** %3
%12 = load i32, i32* %5
%13 = zext i32 %12 to i64
%14 = getelementptr inbounds i32, i32* %11, i64 %13
%15 = load i32, i32* %14
%16 = and i32 %15, 254
store i32 %16, i32* %14
%17 = load i32, i32* %4
%18 = ashr i32 %17, 6
%19 = and i32 %18, 255
%20 = load i32*, i32** %3
%21 = load i32, i32* %5
%22 = zext i32 %21 to i64
%23 = getelementptr inbounds i32, i32* %20, i64 %22
store i32 %19, i32* %23
%24 = load i32*, i32** %3
%25 = load i32, i32* %5
%26 = add i32 %25, 1
%27 = zext i32 %26 to i64
%28 = getelementptr inbounds i32, i32* %24, i64 %27
%29 = load i32, i32* %28
%30 = and i32 %29, 1
store i32 %30, i32* %28
%31 = load i32, i32* %4
%32 = shl i32 %31, 2
%33 = and i32 %32, 252
%34 = or i32 %33, 2
%35 = load i32*, i32** %3
%36 = load i32, i32* %5
%37 = add i32 %36, 1
%38 = zext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* %35, i64 %38
%40 = load i32, i32* %39
%41 = or i32 %40, %34
store i32 %41, i32* %39
ret void
}

LLVM IR (-O2):
define void @mp2vseqdx_set_horizontal(i32* %0, i32 %1) {
%3 = tail call i64 @mp2vseqdx_get_color(i32* %0)
%4 = icmp eq i64 %3, 0
%5 = select i1 %4, i32 5, i32 8
%6 = zext i32 %5 to i64
%7 = getelementptr inbounds i32, i32* %0, i64 %6
%8 = lshr i32 %1, 6
%9 = and i32 %8, 255
store i32 %9, i32* %7
%10 = add nuw nsw i32 %5, 1
%11 = zext i32 %10 to i64
%12 = getelementptr inbounds i32, i32* %0, i64 %11
%13 = load i32, i32* %12
%14 = and i32 %13, 1
%15 = shl i32 %1, 2
%16 = and i32 %15, 252
%17 = or i32 %16, %14
%18 = or i32 %17, 2
store i32 %18, i32* %12
ret void
}