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

/* Variables and functions */
int /*<<< orphan*/ fread(char *, int, int, int /*<<< orphan*/ *);
char *getVIPByte(FILE *in, char *buf, int carriage) {
  char inputbyte;
  fread(&inputbyte, sizeof(char), 1, in);
  *(buf + 7) = inputbyte & 1 ? 'w' : 'W';
  *(buf + 6) = inputbyte & 2 ? 'w' : 'W';
  *(buf + 5) = inputbyte & 4 ? 'w' : 'W';
  *(buf + 4) = inputbyte & 8 ? 'w' : 'W';
  *(buf + 3) = inputbyte & 16 ? 'w' : 'W';
  *(buf + 2) = inputbyte & 32 ? 'w' : 'W';
  *(buf + 1) = inputbyte & 64 ? 'w' : 'W';
  *(buf + 0) = inputbyte & 128 ? 'w' : 'W';
  *(buf + 8) = carriage == 3 ? 0 : ' ';
  *(buf + 9) = 0;
  return buf;
}


x86 assembly (clang, -O0):
<getVIPByte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rcx
lea    -0x15(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
movsbl -0x15(%rbp),%edx
and    $0x1,%edx
mov    $0x57,%eax
mov    $0x77,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x7(%rax)
movsbl -0x15(%rbp),%edx
and    $0x2,%edx
mov    $0x57,%eax
mov    $0x77,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x6(%rax)
movsbl -0x15(%rbp),%edx
and    $0x4,%edx
mov    $0x57,%eax
mov    $0x77,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x5(%rax)
movsbl -0x15(%rbp),%edx
and    $0x8,%edx
mov    $0x57,%eax
mov    $0x77,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x4(%rax)
movsbl -0x15(%rbp),%edx
and    $0x10,%edx
mov    $0x57,%eax
mov    $0x77,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x3(%rax)
movsbl -0x15(%rbp),%edx
and    $0x20,%edx
mov    $0x57,%eax
mov    $0x77,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x2(%rax)
movsbl -0x15(%rbp),%edx
and    $0x40,%edx
mov    $0x57,%eax
mov    $0x77,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x1(%rax)
movsbl -0x15(%rbp),%edx
and    $0x80,%edx
mov    $0x57,%eax
mov    $0x77,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x14(%rbp),%edx
mov    $0x20,%eax
xor    %ecx,%ecx
cmp    $0x3,%edx
cmove  %ecx,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x8(%rax)
mov    -0x10(%rbp),%rax
movb   $0x0,0x9(%rax)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getVIPByte>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%rcx
cmp    $0x3,%edx
setne  %bpl
lea    0x7(%rsp),%rdi
mov    $0x1,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    0x7(%rsp),%al
mov    %eax,%ecx
and    $0x1,%cl
shl    $0x5,%cl
or     $0x57,%cl
mov    %cl,0x7(%rbx)
mov    %eax,%ecx
and    $0x2,%cl
shl    $0x4,%cl
or     $0x57,%cl
mov    %cl,0x6(%rbx)
mov    %eax,%ecx
and    $0x4,%cl
shl    $0x3,%cl
or     $0x57,%cl
mov    %cl,0x5(%rbx)
mov    %eax,%ecx
and    $0x8,%cl
shl    $0x2,%cl
or     $0x57,%cl
mov    %cl,0x4(%rbx)
mov    %eax,%ecx
and    $0x10,%cl
add    %cl,%cl
or     $0x57,%cl
mov    %cl,0x3(%rbx)
mov    %eax,%ecx
and    $0x20,%cl
or     $0x57,%cl
mov    %cl,0x2(%rbx)
mov    %eax,%ecx
and    $0x40,%cl
shr    %cl
or     $0x57,%cl
mov    %cl,0x1(%rbx)
shr    $0x2,%al
and    $0x20,%al
or     $0x57,%al
mov    %al,(%rbx)
shl    $0x5,%bpl
mov    %bpl,0x8(%rbx)
movb   $0x0,0x9(%rbx)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i8* @getVIPByte(i32* %0, i8* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8
store i32* %0, i32** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%8 = load i32*, i32** %4
%9 = call i32 @fread(i8* %7, i32 1, i32 1, i32* %8)
%10 = load i8, i8* %7
%11 = sext i8 %10 to i32
%12 = and i32 %11, 1
%13 = icmp ne i32 %12, 0
%14 = zext i1 %13 to i64
%15 = select i1 %13, i32 119, i32 87
%16 = trunc i32 %15 to i8
%17 = load i8*, i8** %5
%18 = getelementptr inbounds i8, i8* %17, i64 7
store i8 %16, i8* %18
%19 = load i8, i8* %7
%20 = sext i8 %19 to i32
%21 = and i32 %20, 2
%22 = icmp ne i32 %21, 0
%23 = zext i1 %22 to i64
%24 = select i1 %22, i32 119, i32 87
%25 = trunc i32 %24 to i8
%26 = load i8*, i8** %5
%27 = getelementptr inbounds i8, i8* %26, i64 6
store i8 %25, i8* %27
%28 = load i8, i8* %7
%29 = sext i8 %28 to i32
%30 = and i32 %29, 4
%31 = icmp ne i32 %30, 0
%32 = zext i1 %31 to i64
%33 = select i1 %31, i32 119, i32 87
%34 = trunc i32 %33 to i8
%35 = load i8*, i8** %5
%36 = getelementptr inbounds i8, i8* %35, i64 5
store i8 %34, i8* %36
%37 = load i8, i8* %7
%38 = sext i8 %37 to i32
%39 = and i32 %38, 8
%40 = icmp ne i32 %39, 0
%41 = zext i1 %40 to i64
%42 = select i1 %40, i32 119, i32 87
%43 = trunc i32 %42 to i8
%44 = load i8*, i8** %5
%45 = getelementptr inbounds i8, i8* %44, i64 4
store i8 %43, i8* %45
%46 = load i8, i8* %7
%47 = sext i8 %46 to i32
%48 = and i32 %47, 16
%49 = icmp ne i32 %48, 0
%50 = zext i1 %49 to i64
%51 = select i1 %49, i32 119, i32 87
%52 = trunc i32 %51 to i8
%53 = load i8*, i8** %5
%54 = getelementptr inbounds i8, i8* %53, i64 3
store i8 %52, i8* %54
%55 = load i8, i8* %7
%56 = sext i8 %55 to i32
%57 = and i32 %56, 32
%58 = icmp ne i32 %57, 0
%59 = zext i1 %58 to i64
%60 = select i1 %58, i32 119, i32 87
%61 = trunc i32 %60 to i8
%62 = load i8*, i8** %5
%63 = getelementptr inbounds i8, i8* %62, i64 2
store i8 %61, i8* %63
%64 = load i8, i8* %7
%65 = sext i8 %64 to i32
%66 = and i32 %65, 64
%67 = icmp ne i32 %66, 0
%68 = zext i1 %67 to i64
%69 = select i1 %67, i32 119, i32 87
%70 = trunc i32 %69 to i8
%71 = load i8*, i8** %5
%72 = getelementptr inbounds i8, i8* %71, i64 1
store i8 %70, i8* %72
%73 = load i8, i8* %7
%74 = sext i8 %73 to i32
%75 = and i32 %74, 128
%76 = icmp ne i32 %75, 0
%77 = zext i1 %76 to i64
%78 = select i1 %76, i32 119, i32 87
%79 = trunc i32 %78 to i8
%80 = load i8*, i8** %5
%81 = getelementptr inbounds i8, i8* %80, i64 0
store i8 %79, i8* %81
%82 = load i32, i32* %6
%83 = icmp eq i32 %82, 3
%84 = zext i1 %83 to i64
%85 = select i1 %83, i32 0, i32 32
%86 = trunc i32 %85 to i8
%87 = load i8*, i8** %5
%88 = getelementptr inbounds i8, i8* %87, i64 8
store i8 %86, i8* %88
%89 = load i8*, i8** %5
%90 = getelementptr inbounds i8, i8* %89, i64 9
store i8 0, i8* %90
%91 = load i8*, i8** %5
ret i8* %91
}

LLVM IR (-O2):
define i8* @getVIPByte(i32* nocapture %0, i8* returned writeonly %1, i32 %2) {
%4 = alloca i8
%5 = call i32 @fread(i8* %4, i32 1, i32 1, i32* %0)
%6 = load i8, i8* %4
%7 = and i8 %6, 1
%8 = icmp eq i8 %7, 0
%9 = select i1 %8, i8 87, i8 119
%10 = getelementptr inbounds i8, i8* %1, i64 7
store i8 %9, i8* %10
%11 = and i8 %6, 2
%12 = icmp eq i8 %11, 0
%13 = select i1 %12, i8 87, i8 119
%14 = getelementptr inbounds i8, i8* %1, i64 6
store i8 %13, i8* %14
%15 = and i8 %6, 4
%16 = icmp eq i8 %15, 0
%17 = select i1 %16, i8 87, i8 119
%18 = getelementptr inbounds i8, i8* %1, i64 5
store i8 %17, i8* %18
%19 = and i8 %6, 8
%20 = icmp eq i8 %19, 0
%21 = select i1 %20, i8 87, i8 119
%22 = getelementptr inbounds i8, i8* %1, i64 4
store i8 %21, i8* %22
%23 = and i8 %6, 16
%24 = icmp eq i8 %23, 0
%25 = select i1 %24, i8 87, i8 119
%26 = getelementptr inbounds i8, i8* %1, i64 3
store i8 %25, i8* %26
%27 = and i8 %6, 32
%28 = or i8 %27, 87
%29 = getelementptr inbounds i8, i8* %1, i64 2
store i8 %28, i8* %29
%30 = and i8 %6, 64
%31 = icmp eq i8 %30, 0
%32 = select i1 %31, i8 87, i8 119
%33 = getelementptr inbounds i8, i8* %1, i64 1
store i8 %32, i8* %33
%34 = icmp sgt i8 %6, -1
%35 = select i1 %34, i8 87, i8 119
store i8 %35, i8* %1
%36 = icmp eq i32 %2, 3
%37 = select i1 %36, i8 0, i8 32
%38 = getelementptr inbounds i8, i8* %1, i64 8
store i8 %37, i8* %38
%39 = getelementptr inbounds i8, i8* %1, i64 9
store i8 0, i8* %39
ret i8* %1
}