#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*/ fprintf(int /*<<< orphan*/ *, char *, char *);
void output(FILE *f, unsigned char *data, size_t datac) {
  int i;
  for (i = 0; i < datac / 2; i++) {
    unsigned short code = (data[2 * i] << 8) + (data[2 * i + 1]);
    char temp[18];
    temp[16] = '\n';
    temp[17] = '\0';
    int j;
    for (j = 0; j < 16; j++) {
      temp[j] = (code >> 15 - j) & 1 ? '1' : '0';
    }
    fprintf(f, "%s", temp);
  }
}


x86 assembly (clang, -O0):
<output>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
mov    -0x18(%rbp),%rcx
shr    $0x1,%rcx
cmp    %rcx,%rax
jae    11e2 <output+0xd2>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
shl    $0x8,%eax
mov    -0x10(%rbp),%rcx
mov    -0x1c(%rbp),%edx
shl    $0x1,%edx
add    $0x1,%edx
movslq %edx,%rdx
movzbl (%rcx,%rdx,1),%ecx
add    %ecx,%eax
mov    %ax,-0x1e(%rbp)
movb   $0xa,-0x20(%rbp)
movb   $0x0,-0x1f(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0x10,-0x34(%rbp)
jge    11c0 <output+0xb0>
movzwl -0x1e(%rbp),%edx
mov    $0xf,%ecx
sub    -0x34(%rbp),%ecx
sar    %cl,%edx
and    $0x1,%edx
mov    $0x30,%eax
mov    $0x31,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,%cl
movslq -0x34(%rbp),%rax
mov    %cl,-0x30(%rbp,%rax,1)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    117d <output+0x6d>
mov    -0x8(%rbp),%rdi
lea    -0x30(%rbp),%rdx
lea    0xe31(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112b <output+0x1b>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
cmp    $0x2,%rdx
jb     11cc <output+0xbc>
mov    %rdx,%r13
mov    %rsi,%r14
mov    %rdi,%r15
shr    %r13
xor    %ebx,%ebx
mov    %rsp,%r12
nopl   0x0(%rax,%rax,1)
movzwl (%r14,%rbx,2),%eax
movd   %eax,%xmm0
pshufd $0x0,%xmm0,%xmm1
psllq  $0x18,%xmm0
pshufd $0x55,%xmm0,%xmm0
movw   $0xa,0x10(%rsp)
movdqa %xmm0,%xmm2
movdqa 0xe95(%rip),%xmm4
pand   %xmm4,%xmm2
movdqa 0xe99(%rip),%xmm5
pand   %xmm5,%xmm0
movdqa %xmm1,%xmm3
pand   %xmm4,%xmm3
pand   %xmm5,%xmm1
pxor   %xmm4,%xmm4
pcmpeqd %xmm4,%xmm1
pcmpeqd %xmm4,%xmm3
packssdw %xmm1,%xmm3
pcmpeqd %xmm4,%xmm0
pcmpeqd %xmm4,%xmm2
packssdw %xmm0,%xmm2
packsswb %xmm2,%xmm3
paddb  0xe71(%rip),%xmm3
movdqa %xmm3,(%rsp)
mov    %r12,%rdi
mov    %r15,%rsi
call   1030 <fputs@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1140 <output+0x30>
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
define void @output(i32* %0, i8* %1, i64 %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
%8 = alloca i16
%9 = alloca [18 x i8]
%10 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
store i32 0, i32* %7
br label %11
11: ; preds = %62, %3
%12 = load i32, i32* %7
%13 = sext i32 %12 to i64
%14 = load i64, i64* %6
%15 = udiv i64 %14, 2
%16 = icmp ult i64 %13, %15
br i1 %16, label %17, label %65
17: ; preds = %11
%18 = load i8*, i8** %5
%19 = load i32, i32* %7
%20 = mul nsw i32 2, %19
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %18, i64 %21
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
%25 = shl i32 %24, 8
%26 = load i8*, i8** %5
%27 = load i32, i32* %7
%28 = mul nsw i32 2, %27
%29 = add nsw i32 %28, 1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %26, i64 %30
%32 = load i8, i8* %31
%33 = zext i8 %32 to i32
%34 = add nsw i32 %25, %33
%35 = trunc i32 %34 to i16
store i16 %35, i16* %8
%36 = getelementptr inbounds [18 x i8], [18 x i8]* %9, i64 0, i64 16
store i8 10, i8* %36
%37 = getelementptr inbounds [18 x i8], [18 x i8]* %9, i64 0, i64 17
store i8 0, i8* %37
store i32 0, i32* %10
br label %38
38: ; preds = %55, %17
%39 = load i32, i32* %10
%40 = icmp slt i32 %39, 16
br i1 %40, label %41, label %58
41: ; preds = %38
%42 = load i16, i16* %8
%43 = zext i16 %42 to i32
%44 = load i32, i32* %10
%45 = sub nsw i32 15, %44
%46 = ashr i32 %43, %45
%47 = and i32 %46, 1
%48 = icmp ne i32 %47, 0
%49 = zext i1 %48 to i64
%50 = select i1 %48, i32 49, i32 48
%51 = trunc i32 %50 to i8
%52 = load i32, i32* %10
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [18 x i8], [18 x i8]* %9, i64 0, i64 %53
store i8 %51, i8* %54
br label %55
55: ; preds = %41
%56 = load i32, i32* %10
%57 = add nsw i32 %56, 1
store i32 %57, i32* %10
br label %38
58: ; preds = %38
%59 = load i32*, i32** %4
%60 = getelementptr inbounds [18 x i8], [18 x i8]* %9, i64 0, i64 0
%61 = call i32 @fprintf(i32* %59, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %60)
br label %62
62: ; preds = %58
%63 = load i32, i32* %7
%64 = add nsw i32 %63, 1
store i32 %64, i32* %7
br label %11
65: ; preds = %11
ret void
}

LLVM IR (-O2):
define void @output(i32* nocapture %0, i8* nocapture %1, i64 %2) {
%4 = alloca [18 x i8]
%5 = icmp ult i64 %2, 2
br i1 %5, label %26, label %6
6: ; preds = %3
%7 = lshr i64 %2, 1
%8 = getelementptr inbounds [18 x i8], [18 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds [18 x i8], [18 x i8]* %4, i64 0, i64 16
%10 = getelementptr inbounds [18 x i8], [18 x i8]* %4, i64 0, i64 17
%11 = bitcast [18 x i8]* %4 to <16 x i8>*
br label %12
12: ; preds = %6, %12
%13 = phi i64 [ 0, %6 ], [ %24, %12 ]
%14 = shl nuw nsw i64 %13, 1
%15 = getelementptr inbounds i8, i8* %1, i64 %14
%16 = bitcast i8* %15 to <2 x i8>*
%17 = load <2 x i8>, <2 x i8>* %16
%18 = zext <2 x i8> %17 to <2 x i32>
%19 = shufflevector <2 x i32> %18, <2 x i32> poison, <16 x i32> <i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1>
store i8 10, i8* %9
store i8 0, i8* %10
%20 = and <16 x i32> %19, <i32 128, i32 64, i32 32, i32 16, i32 8, i32 4, i32 2, i32 1, i32 128, i32 64, i32 32, i32 16, i32 8, i32 4, i32 2, i32 1>
%21 = icmp eq <16 x i32> %20, zeroinitializer
%22 = select <16 x i1> %21, <16 x i8> <i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48>, <16 x i8> <i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49>
store <16 x i8> %22, <16 x i8>* %11
%23 = call i32 @fputs(i8* %8, i32* %0)
%24 = add nuw nsw i64 %13, 1
%25 = icmp eq i64 %24, %7
br i1 %25, label %26, label %12
26: ; preds = %12, %3
ret void
}