#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(int, int);
void send_cmdWord_msb_first(unsigned int cmd, int lastBit, int bitoffset) {
  while (bitoffset--) {
    int x = (cmd >> bitoffset) & 0x01;
    send_cmd(x, (lastBit == 1 && bitoffset == 0));
  }
}


x86 assembly (clang, -O0):
<send_cmdWord_msb_first>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xc(%rbp)
cmp    $0x0,%eax
je     1177 <send_cmdWord_msb_first+0x67>
mov    -0x4(%rbp),%eax
mov    -0xc(%rbp),%ecx
shr    %cl,%eax
and    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
xor    %eax,%eax
cmpl   $0x1,-0x8(%rbp)
mov    %al,-0x11(%rbp)
jne    1162 <send_cmdWord_msb_first+0x52>
cmpl   $0x0,-0xc(%rbp)
sete   %al
mov    %al,-0x11(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x11(%rbp),%al
and    $0x1,%al
movzbl %al,%esi
call   1030 <send_cmd@plt>
jmp    1121 <send_cmdWord_msb_first+0x11>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_cmdWord_msb_first>:
push   %rbp
push   %r14
push   %rbx
test   %edx,%edx
je     1155 <send_cmdWord_msb_first+0x45>
mov    %edx,%ebx
mov    %esi,%r14d
mov    %edi,%ebp
add    $0xffffffff,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    $0x1,%r14d
sete   %al
mov    %ebp,%edi
mov    %ebx,%ecx
shr    %cl,%edi
and    $0x1,%edi
sub    $0x1,%ebx
setb   %cl
and    %al,%cl
movzbl %cl,%esi
call   1030 <send_cmd@plt>
cmp    $0xffffffff,%ebx
jne    1130 <send_cmdWord_msb_first+0x20>
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define void @send_cmdWord_msb_first(i32 %0, i32 %1, i32 %2) {
%4 = icmp eq i32 %2, 0
br i1 %4, label %16, label %5
5: ; preds = %3
%6 = icmp eq i32 %1, 1
br label %7
7: ; preds = %5, %7
%8 = phi i32 [ %2, %5 ], [ %9, %7 ]
%9 = add nsw i32 %8, -1
%10 = lshr i32 %0, %9
%11 = and i32 %10, 1
%12 = icmp eq i32 %9, 0
%13 = select i1 %6, i1 %12, i1 false
%14 = zext i1 %13 to i32
%15 = tail call i32 @send_cmd(i32 %11, i32 %14)
br i1 %12, label %16, label %7
16: ; preds = %7, %3
ret void
}