#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 /*<<< orphan*/ uint8_t;

/* Variables and functions */
void decode_row(uint8_t *dest, unsigned bits) {
  for (int c = 0; c < 16; c++) {
    *dest++ = (bits & 0x8000) ? 15 : 0;
    bits <<= 1;
  }
}


x86 assembly (clang, -O0):
<decode_row>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x10,-0x10(%rbp)
jge    115a <decode_row+0x5a>
mov    -0xc(%rbp),%edx
and    $0x8000,%edx
xor    %ecx,%ecx
mov    $0xf,%eax
cmp    $0x0,%edx
cmovne %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x8(%rbp)
mov    %ecx,(%rax)
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1112 <decode_row+0x12>
pop    %rbp
ret

x86 assembly (clang, -O2):
<decode_row>:
movd   %esi,%xmm0
pshufd $0x0,%xmm0,%xmm0
movdqa 0xeef(%rip),%xmm1
movdqa %xmm0,%xmm2
pand   %xmm1,%xmm2
pcmpeqd %xmm1,%xmm2
psrld  $0x1c,%xmm2
movdqu %xmm2,(%rdi)
movdqa 0xee2(%rip),%xmm1
movdqa %xmm0,%xmm2
pand   %xmm1,%xmm2
pcmpeqd %xmm1,%xmm2
psrld  $0x1c,%xmm2
movdqu %xmm2,0x10(%rdi)
movdqa 0xed4(%rip),%xmm1
movdqa %xmm0,%xmm2
pand   %xmm1,%xmm2
pcmpeqd %xmm1,%xmm2
psrld  $0x1c,%xmm2
movdqu %xmm2,0x20(%rdi)
movdqa 0xec6(%rip),%xmm1
pand   %xmm1,%xmm0
pcmpeqd %xmm1,%xmm0
psrld  $0x1c,%xmm0
movdqu %xmm0,0x30(%rdi)
ret

LLVM IR (-O0):
define void @decode_row(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %19, %2
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 16
br i1 %8, label %9, label %22
9: ; preds = %6
%10 = load i32, i32* %4
%11 = and i32 %10, 32768
%12 = icmp ne i32 %11, 0
%13 = zext i1 %12 to i64
%14 = select i1 %12, i32 15, i32 0
%15 = load i32*, i32** %3
%16 = getelementptr inbounds i32, i32* %15, i32 1
store i32* %16, i32** %3
store i32 %14, i32* %15
%17 = load i32, i32* %4
%18 = shl i32 %17, 1
store i32 %18, i32* %4
br label %19
19: ; preds = %9
%20 = load i32, i32* %5
%21 = add nsw i32 %20, 1
store i32 %21, i32* %5
br label %6
22: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @decode_row(i32* nocapture writeonly %0, i32 %1) {
%3 = insertelement <4 x i32> poison, i32 %1, i64 0
%4 = shufflevector <4 x i32> %3, <4 x i32> poison, <4 x i32> zeroinitializer
%5 = and <4 x i32> %4, <i32 32768, i32 16384, i32 8192, i32 4096>
%6 = icmp eq <4 x i32> %5, zeroinitializer
%7 = select <4 x i1> %6, <4 x i32> zeroinitializer, <4 x i32> <i32 15, i32 15, i32 15, i32 15>
%8 = getelementptr inbounds i32, i32* %0, i64 4
%9 = bitcast i32* %0 to <4 x i32>*
store <4 x i32> %7, <4 x i32>* %9
%10 = and <4 x i32> %4, <i32 2048, i32 1024, i32 512, i32 256>
%11 = icmp eq <4 x i32> %10, zeroinitializer
%12 = select <4 x i1> %11, <4 x i32> zeroinitializer, <4 x i32> <i32 15, i32 15, i32 15, i32 15>
%13 = getelementptr inbounds i32, i32* %0, i64 8
%14 = bitcast i32* %8 to <4 x i32>*
store <4 x i32> %12, <4 x i32>* %14
%15 = and <4 x i32> %4, <i32 128, i32 64, i32 32, i32 16>
%16 = icmp eq <4 x i32> %15, zeroinitializer
%17 = select <4 x i1> %16, <4 x i32> zeroinitializer, <4 x i32> <i32 15, i32 15, i32 15, i32 15>
%18 = getelementptr inbounds i32, i32* %0, i64 12
%19 = bitcast i32* %13 to <4 x i32>*
store <4 x i32> %17, <4 x i32>* %19
%20 = and <4 x i32> %4, <i32 8, i32 4, i32 2, i32 1>
%21 = icmp eq <4 x i32> %20, zeroinitializer
%22 = select <4 x i1> %21, <4 x i32> zeroinitializer, <4 x i32> <i32 15, i32 15, i32 15, i32 15>
%23 = bitcast i32* %18 to <4 x i32>*
store <4 x i32> %22, <4 x i32>* %23
ret void
}