#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_last(unsigned int cmd, int lastBit, int bitoffset) {
  int i;
  for (i = 0; i < bitoffset; i++) {
    int x = (cmd >> i) & 0x01;
    send_cmd(x, (lastBit == 1 && bitoffset == i + 1));
  }
}


x86 assembly (clang, -O0):
<send_cmdWord_msb_last>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1186 <send_cmdWord_msb_last+0x76>
mov    -0x4(%rbp),%eax
mov    -0x10(%rbp),%ecx
shr    %cl,%eax
and    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
xor    %eax,%eax
cmpl   $0x1,-0x8(%rbp)
mov    %al,-0x15(%rbp)
jne    1168 <send_cmdWord_msb_last+0x58>
mov    -0xc(%rbp),%eax
mov    -0x10(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
sete   %al
mov    %al,-0x15(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x15(%rbp),%al
and    $0x1,%al
movzbl %al,%esi
call   1030 <send_cmd@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1128 <send_cmdWord_msb_last+0x18>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_cmdWord_msb_last>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %edx,%edx
jle    1156 <send_cmdWord_msb_last+0x46>
mov    %edx,%ebx
mov    %esi,%r15d
mov    %edi,%r14d
neg    %ebx
xor    %ebp,%ebp
xor    $0x1,%r15d
nopl   0x0(%rax,%rax,1)
mov    %r14d,%edi
mov    %ebp,%ecx
shr    %cl,%edi
and    $0x1,%edi
lea    (%rbx,%rbp,1),%eax
add    $0x1,%ebp
not    %eax
xor    %esi,%esi
or     %r15d,%eax
sete   %sil
call   1030 <send_cmd@plt>
mov    %ebx,%eax
add    %ebp,%eax
jne    1130 <send_cmdWord_msb_last+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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