#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*/ setBPin(int, char *);
void ht1632_writebits(unsigned char bits, unsigned char firstbit) {
  while (firstbit) {
    setBPin(2, "LOW");
    if (bits & firstbit) {
      setBPin(0, "HIGH");
    } else {
      setBPin(0, "LOW");
    }
    setBPin(2, "HIGH");
    firstbit >>= 1;
  }
}


x86 assembly (clang, -O0):
<ht1632_writebits>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %dil,%cl
mov    %cl,-0x1(%rbp)
mov    %al,-0x2(%rbp)
cmpb   $0x0,-0x2(%rbp)
je     1193 <ht1632_writebits+0x83>
mov    $0x2,%edi
lea    0xec6(%rip),%rsi
call   1030 <setBPin@plt>
movzbl -0x1(%rbp),%eax
movzbl -0x2(%rbp),%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1165 <ht1632_writebits+0x55>
xor    %edi,%edi
lea    0xea9(%rip),%rsi
call   1030 <setBPin@plt>
jmp    1173 <ht1632_writebits+0x63>
xor    %edi,%edi
lea    0xe92(%rip),%rsi
call   1030 <setBPin@plt>
mov    $0x2,%edi
lea    0xe85(%rip),%rsi
call   1030 <setBPin@plt>
movzbl -0x2(%rbp),%eax
sar    $0x1,%eax
mov    %al,-0x2(%rbp)
jmp    1124 <ht1632_writebits+0x14>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ht1632_writebits>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %esi,%esi
je     1175 <ht1632_writebits+0x65>
mov    %esi,%ebp
mov    %edi,%r14d
lea    0xed8(%rip),%r15
lea    0xed5(%rip),%r12
mov    %ebp,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x2,%edi
mov    %r15,%rsi
call   1030 <setBPin@plt>
test   %r14b,%bpl
mov    %r12,%rsi
cmove  %r15,%rsi
xor    %edi,%edi
call   1030 <setBPin@plt>
mov    $0x2,%edi
mov    %r12,%rsi
call   1030 <setBPin@plt>
shr    %bl
cmp    $0x1,%bpl
mov    %ebx,%ebp
ja     1140 <ht1632_writebits+0x30>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"LOW\00"
@.str.1 = [5 x i8] c"HIGH\00"
define void @ht1632_writebits(i8 zeroext %0, i8 zeroext %1) {
%3 = alloca i8
%4 = alloca i8
store i8 %0, i8* %3
store i8 %1, i8* %4
br label %5
5: ; preds = %20, %2
%6 = load i8, i8* %4
%7 = icmp ne i8 %6, 0
br i1 %7, label %8, label %26
8: ; preds = %5
%9 = call i32 @setBPin(i32 2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%10 = load i8, i8* %3
%11 = zext i8 %10 to i32
%12 = load i8, i8* %4
%13 = zext i8 %12 to i32
%14 = and i32 %11, %13
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %8
%17 = call i32 @setBPin(i32 0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %20
18: ; preds = %8
%19 = call i32 @setBPin(i32 0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %20
20: ; preds = %18, %16
%21 = call i32 @setBPin(i32 2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%22 = load i8, i8* %4
%23 = zext i8 %22 to i32
%24 = ashr i32 %23, 1
%25 = trunc i32 %24 to i8
store i8 %25, i8* %4
br label %5
26: ; preds = %5
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"LOW\00"
@.str.1 = [5 x i8] c"HIGH\00"
define void @ht1632_writebits(i8 zeroext %0, i8 zeroext %1) {
%3 = icmp eq i8 %1, 0
br i1 %3, label %14, label %4
4: ; preds = %2, %4
%5 = phi i8 [ %12, %4 ], [ %1, %2 ]
%6 = tail call i32 @setBPin(i32 2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%7 = and i8 %5, %0
%8 = icmp eq i8 %7, 0
%9 = select i1 %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0)
%10 = tail call i32 @setBPin(i32 0, i8* %9)
%11 = tail call i32 @setBPin(i32 2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%12 = lshr i8 %5, 1
%13 = icmp ult i8 %5, 2
br i1 %13, label %14, label %4
14: ; preds = %4, %2
ret void
}