#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*/ sendbyte(char);
int /*<<< orphan*/ snewline();
void printbits(unsigned int portval, char numbit) {
  unsigned int bit = 1;
  unsigned int i;
  for (i = 0; i < numbit; i++) {
    if (portval & bit)
      sendbyte('1');
    else
      sendbyte('0');
    bit = bit << 1;
  }
  snewline();
}


x86 assembly (clang, -O0):
<printbits>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %edi,-0x4(%rbp)
mov    %al,-0x5(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
movsbl -0x5(%rbp),%ecx
cmp    %ecx,%eax
jae    118d <printbits+0x6d>
mov    -0x4(%rbp),%eax
and    -0xc(%rbp),%eax
cmp    $0x0,%eax
je     116c <printbits+0x4c>
mov    $0x31,%edi
call   1040 <sendbyte@plt>
jmp    1176 <printbits+0x56>
mov    $0x30,%edi
call   1040 <sendbyte@plt>
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113f <printbits+0x1f>
mov    $0x0,%al
call   1030 <snewline@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printbits>:
push   %rbp
push   %r14
push   %rbx
test   %sil,%sil
je     115c <printbits+0x3c>
mov    %edi,%r14d
movsbl %sil,%ebp
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebx,%eax
and    %r14d,%eax
cmp    $0x1,%eax
mov    $0x31,%edi
sbb    $0x0,%edi
call   1040 <sendbyte@plt>
add    %ebx,%ebx
add    $0xffffffff,%ebp
jne    1140 <printbits+0x20>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <snewline@plt>

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

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