#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 /*<<< orphan*/ cio_printc(char);
void cio_printb(int n, int size) {
  int i;
  int mask = 1 << (size - 1);
  for (i = 0; i < size; i++) {
    if ((n & (mask >> i)) != 0) {
      cio_printc('1');
    } else {
      cio_printc('0');
    }
  }
}


x86 assembly (clang, -O0):
<cio_printb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1185 <cio_printb+0x75>
mov    -0x4(%rbp),%eax
mov    -0x10(%rbp),%edx
mov    -0xc(%rbp),%ecx
sar    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1168 <cio_printb+0x58>
mov    $0x31,%edi
call   1030 <cio_printc@plt>
jmp    1172 <cio_printb+0x62>
mov    $0x30,%edi
call   1030 <cio_printc@plt>
jmp    1177 <cio_printb+0x67>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1135 <cio_printb+0x25>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cio_printb>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r15d
lea    -0x1(%r15),%ecx
mov    $0x1,%ebx
shl    %cl,%ebx
test   %esi,%esi
jle    1151 <cio_printb+0x41>
mov    %edi,%r14d
xor    %ebp,%ebp
xchg   %ax,%ax
mov    %ebx,%eax
mov    %ebp,%ecx
sar    %cl,%eax
and    %r14d,%eax
cmp    $0x1,%eax
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <cio_printc@plt>
add    $0x1,%ebp
cmp    %ebp,%r15d
jne    1130 <cio_printb+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @cio_printb(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
%8 = sub nsw i32 %7, 1
%9 = shl i32 1, %8
store i32 %9, i32* %6
store i32 0, i32* %5
br label %10
10: ; preds = %26, %2
%11 = load i32, i32* %5
%12 = load i32, i32* %4
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %29
14: ; preds = %10
%15 = load i32, i32* %3
%16 = load i32, i32* %6
%17 = load i32, i32* %5
%18 = ashr i32 %16, %17
%19 = and i32 %15, %18
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %14
%22 = call i32 @cio_printc(i8 signext 49)
br label %25
23: ; preds = %14
%24 = call i32 @cio_printc(i8 signext 48)
br label %25
25: ; preds = %23, %21
br label %26
26: ; preds = %25
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 1
store i32 %28, i32* %5
br label %10
29: ; preds = %10
ret void
}

LLVM IR (-O2):
define void @cio_printb(i32 %0, i32 %1) {
%3 = add nsw i32 %1, -1
%4 = shl nuw i32 1, %3
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %15
6: ; preds = %2, %6
%7 = phi i32 [ %13, %6 ], [ 0, %2 ]
%8 = ashr i32 %4, %7
%9 = and i32 %8, %0
%10 = icmp eq i32 %9, 0
%11 = select i1 %10, i8 48, i8 49
%12 = tail call i32 @cio_printc(i8 signext %11)
%13 = add nuw nsw i32 %7, 1
%14 = icmp eq i32 %13, %1
br i1 %14, label %15, label %6
15: ; preds = %6, %2
ret void
}