char *prmb(int mask, int bits) {
  static char buf[8][30];
  static int bn = 0;
  char *bp;
  bn = (bn + 1) % 8;
  bp = buf[bn];
  int i;
  for (i = 0; i < 8; i++) {
    int bit = 0x80 >> i;
    if (!(mask & bit))
      *bp++ = '-';
    else if (bits & bit)
      *bp++ = '1';
    else
      *bp++ = '0';
    if (i % 4 == 3)
      *bp++ = ' ';
  }
  *--bp = 0;
  return buf[bn];
}


x86 assembly (clang, -O0):
<prmb>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    0x3010(%rip),%eax
add    $0x1,%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %edx,0x2fff(%rip)
movslq 0x2ff8(%rip),%rcx
lea    0x2f01(%rip),%rax
imul   $0x1e,%rcx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jge    11f4 <prmb+0xf4>
mov    -0x14(%rbp),%ecx
mov    $0x80,%eax
sar    %cl,%eax
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%eax
and    -0x18(%rbp),%eax
cmp    $0x0,%eax
jne    117e <prmb+0x7e>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x2d,(%rax)
jmp    11bb <prmb+0xbb>
mov    -0x8(%rbp),%eax
and    -0x18(%rbp),%eax
cmp    $0x0,%eax
je     11a4 <prmb+0xa4>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x31,(%rax)
jmp    11b6 <prmb+0xb6>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x30,(%rax)
jmp    11bb <prmb+0xbb>
mov    -0x14(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x3,%edx
jne    11e1 <prmb+0xe1>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x20,(%rax)
jmp    11e6 <prmb+0xe6>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1141 <prmb+0x41>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x0,-0x1(%rax)
movslq 0x2f12(%rip),%rcx
lea    0x2e1b(%rip),%rax
imul   $0x1e,%rcx,%rcx
add    %rcx,%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<prmb>:
mov    0x301a(%rip),%eax
lea    0x1(%rax),%ecx
lea    0x8(%rax),%edx
test   %ecx,%ecx
cmovns %ecx,%edx
and    $0xfffffff8,%edx
neg    %edx
add    %edx,%eax
add    $0x1,%eax
mov    %eax,0x2fff(%rip)
mov    %rax,%rcx
shl    $0x5,%rcx
sub    %rax,%rcx
sub    %rax,%rcx
lea    0x2efb(%rip),%r9
mov    %esi,%eax
and    $0x80,%eax
cmp    $0x1,%eax
mov    $0x31,%dl
sbb    $0x0,%dl
lea    (%r9,%rcx,1),%rax
test   $0x80,%dil
movzbl %dl,%edx
mov    $0x2d,%r8d
cmove  %r8d,%edx
mov    %dl,(%rcx,%r9,1)
mov    %esi,%edx
and    $0x40,%edx
cmp    $0x1,%edx
mov    $0x31,%dl
sbb    $0x0,%dl
test   $0x40,%dil
movzbl %dl,%edx
cmove  %r8d,%edx
mov    %dl,0x1(%rcx,%r9,1)
mov    %esi,%edx
and    $0x20,%edx
cmp    $0x1,%edx
mov    $0x31,%dl
sbb    $0x0,%dl
test   $0x20,%dil
movzbl %dl,%edx
cmove  %r8d,%edx
mov    %dl,0x2(%rcx,%r9,1)
mov    %esi,%edx
and    $0x10,%edx
cmp    $0x1,%edx
mov    $0x31,%dl
sbb    $0x0,%dl
test   $0x10,%dil
movzbl %dl,%edx
cmove  %r8d,%edx
mov    $0x31,%r10b
mov    %dl,0x3(%rcx,%r9,1)
movb   $0x20,0x4(%rcx,%r9,1)
mov    %esi,%edx
and    $0x8,%edx
cmp    $0x1,%edx
mov    $0x31,%dl
sbb    $0x0,%dl
test   $0x8,%dil
movzbl %dl,%edx
cmove  %r8d,%edx
mov    %dl,0x5(%rcx,%r9,1)
mov    %esi,%edx
and    $0x4,%edx
cmp    $0x1,%edx
mov    $0x31,%dl
sbb    $0x0,%dl
test   $0x4,%dil
movzbl %dl,%edx
cmove  %r8d,%edx
mov    %dl,0x6(%rcx,%r9,1)
mov    %esi,%edx
and    $0x2,%edx
cmp    $0x1,%edx
sbb    $0x0,%r10b
test   $0x2,%dil
movzbl %r10b,%edx
cmove  %r8d,%edx
mov    %dl,0x7(%rcx,%r9,1)
and    $0x1,%sil
or     $0x30,%sil
test   $0x1,%dil
movzbl %sil,%edx
cmove  %r8d,%edx
mov    %dl,0x8(%rcx,%r9,1)
movb   $0x0,0x9(%rcx,%r9,1)
ret

LLVM IR (-O0):
@prmb.buf = internal global [8 x [30 x i8]] zeroinitializer
@prmb.bn = internal global i32 0
define i8* @prmb(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%8 = load i32, i32* @prmb.bn
%9 = add nsw i32 %8, 1
%10 = srem i32 %9, 8
store i32 %10, i32* @prmb.bn
%11 = load i32, i32* @prmb.bn
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [8 x [30 x i8]], [8 x [30 x i8]]* @prmb.buf, i64 0, i64 %12
%14 = getelementptr inbounds [30 x i8], [30 x i8]* %13, i64 0, i64 0
store i8* %14, i8** %5
store i32 0, i32* %6
br label %15
15: ; preds = %48, %2
%16 = load i32, i32* %6
%17 = icmp slt i32 %16, 8
br i1 %17, label %18, label %51
18: ; preds = %15
%19 = load i32, i32* %6
%20 = ashr i32 128, %19
store i32 %20, i32* %7
%21 = load i32, i32* %3
%22 = load i32, i32* %7
%23 = and i32 %21, %22
%24 = icmp ne i32 %23, 0
br i1 %24, label %28, label %25
25: ; preds = %18
%26 = load i8*, i8** %5
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %5
store i8 45, i8* %26
br label %40
28: ; preds = %18
%29 = load i32, i32* %4
%30 = load i32, i32* %7
%31 = and i32 %29, %30
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %28
%34 = load i8*, i8** %5
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %5
store i8 49, i8* %34
br label %39
36: ; preds = %28
%37 = load i8*, i8** %5
%38 = getelementptr inbounds i8, i8* %37, i32 1
store i8* %38, i8** %5
store i8 48, i8* %37
br label %39
39: ; preds = %36, %33
br label %40
40: ; preds = %39, %25
%41 = load i32, i32* %6
%42 = srem i32 %41, 4
%43 = icmp eq i32 %42, 3
br i1 %43, label %44, label %47
44: ; preds = %40
%45 = load i8*, i8** %5
%46 = getelementptr inbounds i8, i8* %45, i32 1
store i8* %46, i8** %5
store i8 32, i8* %45
br label %47
47: ; preds = %44, %40
br label %48
48: ; preds = %47
%49 = load i32, i32* %6
%50 = add nsw i32 %49, 1
store i32 %50, i32* %6
br label %15
51: ; preds = %15
%52 = load i8*, i8** %5
%53 = getelementptr inbounds i8, i8* %52, i32 -1
store i8* %53, i8** %5
store i8 0, i8* %53
%54 = load i32, i32* @prmb.bn
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [8 x [30 x i8]], [8 x [30 x i8]]* @prmb.buf, i64 0, i64 %55
%57 = getelementptr inbounds [30 x i8], [30 x i8]* %56, i64 0, i64 0
ret i8* %57
}

LLVM IR (-O2):
@prmb.buf = internal global [8 x [30 x i8]] zeroinitializer
@prmb.bn = internal unnamed_addr global i32 0
define i8* @prmb(i32 %0, i32 %1) {
%3 = load i32, i32* @prmb.bn
%4 = add nsw i32 %3, 1
%5 = srem i32 %4, 8
store i32 %5, i32* @prmb.bn
%6 = zext i32 %5 to i64
%7 = getelementptr inbounds [8 x [30 x i8]], [8 x [30 x i8]]* @prmb.buf, i64 0, i64 %6, i64 0
%8 = and i32 %0, 128
%9 = icmp eq i32 %8, 0
%10 = and i32 %1, 128
%11 = icmp eq i32 %10, 0
%12 = select i1 %11, i8 48, i8 49
%13 = select i1 %9, i8 45, i8 %12
store i8 %13, i8* %7
%14 = getelementptr inbounds [8 x [30 x i8]], [8 x [30 x i8]]* @prmb.buf, i64 0, i64 %6, i64 1
%15 = and i32 %0, 64
%16 = icmp eq i32 %15, 0
%17 = and i32 %1, 64
%18 = icmp eq i32 %17, 0
%19 = select i1 %18, i8 48, i8 49
%20 = select i1 %16, i8 45, i8 %19
store i8 %20, i8* %14
%21 = getelementptr inbounds [8 x [30 x i8]], [8 x [30 x i8]]* @prmb.buf, i64 0, i64 %6, i64 2
%22 = and i32 %0, 32
%23 = icmp eq i32 %22, 0
%24 = and i32 %1, 32
%25 = icmp eq i32 %24, 0
%26 = select i1 %25, i8 48, i8 49
%27 = select i1 %23, i8 45, i8 %26
store i8 %27, i8* %21
%28 = getelementptr inbounds [8 x [30 x i8]], [8 x [30 x i8]]* @prmb.buf, i64 0, i64 %6, i64 3
%29 = and i32 %0, 16
%30 = icmp eq i32 %29, 0
%31 = and i32 %1, 16
%32 = icmp eq i32 %31, 0
%33 = select i1 %32, i8 48, i8 49
%34 = select i1 %30, i8 45, i8 %33
store i8 %34, i8* %28
%35 = getelementptr inbounds [8 x [30 x i8]], [8 x [30 x i8]]* @prmb.buf, i64 0, i64 %6, i64 4
%36 = getelementptr inbounds [8 x [30 x i8]], [8 x [30 x i8]]* @prmb.buf, i64 0, i64 %6, i64 5
store i8 32, i8* %35
%37 = and i32 %0, 8
%38 = icmp eq i32 %37, 0
%39 = and i32 %1, 8
%40 = icmp eq i32 %39, 0
%41 = select i1 %40, i8 48, i8 49
%42 = select i1 %38, i8 45, i8 %41
store i8 %42, i8* %36
%43 = getelementptr inbounds [8 x [30 x i8]], [8 x [30 x i8]]* @prmb.buf, i64 0, i64 %6, i64 6
%44 = and i32 %0, 4
%45 = icmp eq i32 %44, 0
%46 = and i32 %1, 4
%47 = icmp eq i32 %46, 0
%48 = select i1 %47, i8 48, i8 49
%49 = select i1 %45, i8 45, i8 %48
store i8 %49, i8* %43
%50 = getelementptr inbounds [8 x [30 x i8]], [8 x [30 x i8]]* @prmb.buf, i64 0, i64 %6, i64 7
%51 = and i32 %0, 2
%52 = icmp eq i32 %51, 0
%53 = and i32 %1, 2
%54 = icmp eq i32 %53, 0
%55 = select i1 %54, i8 48, i8 49
%56 = select i1 %52, i8 45, i8 %55
store i8 %56, i8* %50
%57 = getelementptr inbounds [8 x [30 x i8]], [8 x [30 x i8]]* @prmb.buf, i64 0, i64 %6, i64 8
%58 = and i32 %0, 1
%59 = icmp eq i32 %58, 0
%60 = and i32 %1, 1
%61 = icmp eq i32 %60, 0
%62 = select i1 %61, i8 48, i8 49
%63 = select i1 %59, i8 45, i8 %62
store i8 %63, i8* %57
%64 = getelementptr inbounds [8 x [30 x i8]], [8 x [30 x i8]]* @prmb.buf, i64 0, i64 %6, i64 9
store i8 0, i8* %64
ret i8* %7
}