#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 code2unit(int);
char *bmap2asc(unsigned int bitmap, char *chrs) {
  int j;
  static char outbuf[17];
  for (j = 0; j < 16; j++) {
    if (bitmap & (1 << j))
      outbuf[code2unit(j) - 1] = chrs[1];
    else
      outbuf[code2unit(j) - 1] = chrs[0];
  }
  outbuf[16] = '\0';
  return outbuf;
}


x86 assembly (clang, -O0):
<bmap2asc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x10,-0x14(%rbp)
jge    11ab <bmap2asc+0x9b>
mov    -0x4(%rbp),%eax
mov    -0x14(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1174 <bmap2asc+0x64>
mov    -0x10(%rbp),%rax
mov    0x1(%rax),%al
mov    %al,-0x15(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <code2unit@plt>
mov    -0x15(%rbp),%dl
sub    $0x1,%eax
movslq %eax,%rcx
lea    0x2ed4(%rip),%rax
mov    %dl,(%rax,%rcx,1)
jmp    1198 <bmap2asc+0x88>
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x16(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <code2unit@plt>
mov    -0x16(%rbp),%dl
sub    $0x1,%eax
movslq %eax,%rcx
lea    0x2eab(%rip),%rax
mov    %dl,(%rax,%rcx,1)
jmp    119d <bmap2asc+0x8d>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1126 <bmap2asc+0x16>
movb   $0x0,0x2e9e(%rip)
lea    0x2e87(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bmap2asc>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebp
xor    %ebx,%ebx
lea    0x2f1a(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
bt     %ebx,%ebp
mov    %r14,%rax
adc    $0x0,%rax
movzbl (%rax),%r12d
mov    %ebx,%edi
call   1030 <code2unit@plt>
cltq
mov    %r12b,-0x1(%rax,%r15,1)
add    $0x1,%ebx
cmp    $0x10,%ebx
jne    1130 <bmap2asc+0x20>
movb   $0x0,0x2ef5(%rip)
lea    0x2ede(%rip),%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@bmap2asc.outbuf = internal global [17 x i8] zeroinitializer
define i8* @bmap2asc(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
store i32 0, i32* %5
br label %6
6: ; preds = %34, %2
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 16
br i1 %8, label %9, label %37
9: ; preds = %6
%10 = load i32, i32* %3
%11 = load i32, i32* %5
%12 = shl i32 1, %11
%13 = and i32 %10, %12
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %24
15: ; preds = %9
%16 = load i8*, i8** %4
%17 = getelementptr inbounds i8, i8* %16, i64 1
%18 = load i8, i8* %17
%19 = load i32, i32* %5
%20 = call i32 @code2unit(i32 %19)
%21 = sub nsw i32 %20, 1
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [17 x i8], [17 x i8]* @bmap2asc.outbuf, i64 0, i64 %22
store i8 %18, i8* %23
br label %33
24: ; preds = %9
%25 = load i8*, i8** %4
%26 = getelementptr inbounds i8, i8* %25, i64 0
%27 = load i8, i8* %26
%28 = load i32, i32* %5
%29 = call i32 @code2unit(i32 %28)
%30 = sub nsw i32 %29, 1
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [17 x i8], [17 x i8]* @bmap2asc.outbuf, i64 0, i64 %31
store i8 %27, i8* %32
br label %33
33: ; preds = %24, %15
br label %34
34: ; preds = %33
%35 = load i32, i32* %5
%36 = add nsw i32 %35, 1
store i32 %36, i32* %5
br label %6
37: ; preds = %6
store i8 0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @bmap2asc.outbuf, i64 0, i64 16)
ret i8* getelementptr inbounds ([17 x i8], [17 x i8]* @bmap2asc.outbuf, i64 0, i64 0)
}

LLVM IR (-O2):
@bmap2asc.outbuf = internal global [17 x i8] zeroinitializer
define i8* @bmap2asc(i32 %0, i8* nocapture %1) {
br label %3
3: ; preds = %2, %3
%4 = phi i32 [ 0, %2 ], [ %15, %3 ]
%5 = shl nuw nsw i32 1, %4
%6 = and i32 %5, %0
%7 = icmp ne i32 %6, 0
%8 = zext i1 %7 to i64
%9 = getelementptr i8, i8* %1, i64 %8
%10 = load i8, i8* %9
%11 = tail call i32 @code2unit(i32 %4)
%12 = add nsw i32 %11, -1
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [17 x i8], [17 x i8]* @bmap2asc.outbuf, i64 0, i64 %13
store i8 %10, i8* %14
%15 = add nuw nsw i32 %4, 1
%16 = icmp eq i32 %15, 16
br i1 %16, label %17, label %3
17: ; preds = %3
store i8 0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @bmap2asc.outbuf, i64 0, i64 16)
ret i8* getelementptr inbounds ([17 x i8], [17 x i8]* @bmap2asc.outbuf, i64 0, i64 0)
}