#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*/ send_cmd(unsigned char, int);
void send_byte(unsigned char byte, int lastByte) {
  int x;
  for (x = 7; x >= 0; x--) {
    send_cmd(byte >> x & 0x01, (lastByte == 1 && x == 0));
  }
}


x86 assembly (clang, -O0):
<send_byte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x7,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jl     117c <send_byte+0x6c>
movzbl -0x1(%rbp),%eax
mov    -0xc(%rbp),%ecx
sar    %cl,%eax
and    $0x1,%eax
mov    %al,-0xe(%rbp)
xor    %eax,%eax
cmpl   $0x1,-0x8(%rbp)
mov    %al,-0xd(%rbp)
jne    115a <send_byte+0x4a>
cmpl   $0x0,-0xc(%rbp)
sete   %al
mov    %al,-0xd(%rbp)
mov    -0xe(%rbp),%al
mov    -0xd(%rbp),%cl
and    $0x1,%cl
movzbl %cl,%esi
movzbl %al,%edi
call   1030 <send_cmd@plt>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1128 <send_byte+0x18>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_byte>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
xor    %ebp,%ebp
cmp    $0x1,%esi
sete   %bpl
mov    %ebx,%eax
shr    $0x7,%al
movzbl %al,%edi
xor    %esi,%esi
call   1030 <send_cmd@plt>
mov    %ebx,%eax
shr    $0x6,%al
and    $0x1,%al
movzbl %al,%edi
xor    %esi,%esi
call   1030 <send_cmd@plt>
mov    %ebx,%eax
shr    $0x5,%al
and    $0x1,%al
movzbl %al,%edi
xor    %esi,%esi
call   1030 <send_cmd@plt>
mov    %ebx,%eax
shr    $0x4,%al
and    $0x1,%al
movzbl %al,%edi
xor    %esi,%esi
call   1030 <send_cmd@plt>
mov    %ebx,%eax
shr    $0x3,%al
and    $0x1,%al
movzbl %al,%edi
xor    %esi,%esi
call   1030 <send_cmd@plt>
mov    %ebx,%eax
shr    $0x2,%al
and    $0x1,%al
movzbl %al,%edi
xor    %esi,%esi
call   1030 <send_cmd@plt>
mov    %ebx,%eax
shr    %al
and    $0x1,%al
movzbl %al,%edi
xor    %esi,%esi
call   1030 <send_cmd@plt>
and    $0x1,%ebx
mov    %ebx,%edi
mov    %ebp,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <send_cmd@plt>

LLVM IR (-O0):
define void @send_byte(i8 zeroext %0, i32 %1) {
%3 = alloca i8
%4 = alloca i32
%5 = alloca i32
store i8 %0, i8* %3
store i32 %1, i32* %4
store i32 7, i32* %5
br label %6
6: ; preds = %25, %2
%7 = load i32, i32* %5
%8 = icmp sge i32 %7, 0
br i1 %8, label %9, label %28
9: ; preds = %6
%10 = load i8, i8* %3
%11 = zext i8 %10 to i32
%12 = load i32, i32* %5
%13 = ashr i32 %11, %12
%14 = and i32 %13, 1
%15 = trunc i32 %14 to i8
%16 = load i32, i32* %4
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %21
18: ; preds = %9
%19 = load i32, i32* %5
%20 = icmp eq i32 %19, 0
br label %21
21: ; preds = %18, %9
%22 = phi i1 [ false, %9 ], [ %20, %18 ]
%23 = zext i1 %22 to i32
%24 = call i32 @send_cmd(i8 zeroext %15, i32 %23)
br label %25
25: ; preds = %21
%26 = load i32, i32* %5
%27 = add nsw i32 %26, -1
store i32 %27, i32* %5
br label %6
28: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @send_byte(i8 zeroext %0, i32 %1) {
%3 = icmp eq i32 %1, 1
%4 = lshr i8 %0, 7
%5 = tail call i32 @send_cmd(i8 zeroext %4, i32 0)
%6 = lshr i8 %0, 6
%7 = and i8 %6, 1
%8 = tail call i32 @send_cmd(i8 zeroext %7, i32 0)
%9 = lshr i8 %0, 5
%10 = and i8 %9, 1
%11 = tail call i32 @send_cmd(i8 zeroext %10, i32 0)
%12 = lshr i8 %0, 4
%13 = and i8 %12, 1
%14 = tail call i32 @send_cmd(i8 zeroext %13, i32 0)
%15 = lshr i8 %0, 3
%16 = and i8 %15, 1
%17 = tail call i32 @send_cmd(i8 zeroext %16, i32 0)
%18 = lshr i8 %0, 2
%19 = and i8 %18, 1
%20 = tail call i32 @send_cmd(i8 zeroext %19, i32 0)
%21 = lshr i8 %0, 1
%22 = and i8 %21, 1
%23 = tail call i32 @send_cmd(i8 zeroext %22, i32 0)
%24 = and i8 %0, 1
%25 = zext i1 %3 to i32
%26 = tail call i32 @send_cmd(i8 zeroext %24, i32 %25)
ret void
}