#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*/ McDevIf_AddPacket(int, int);
long McDevIf_ExecutePacket();
signed long CommandWaitComplete(unsigned long dCoderId) {
  signed long sdRet;
  unsigned char bAddrSfr;
  if ((0UL) == dCoderId) {
    bAddrSfr = (52);
  } else {
    bAddrSfr = (86);
  }
  McDevIf_AddPacket(((0x40000000UL) | (0x000F0000UL) |
                     (((unsigned long)bAddrSfr) << 8) | (unsigned long)(0x80)),
                    0);
  sdRet = McDevIf_ExecutePacket();
  if (((signed long)0) > sdRet) {
    McDevIf_AddPacket(
        ((0x20000000UL) | (0x00004000UL) | (unsigned long)bAddrSfr), (0x80));
    McDevIf_ExecutePacket();
  }
  return sdRet;
}


x86 assembly (clang, -O0):
<CommandWaitComplete>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
xor    %eax,%eax
cmp    -0x8(%rbp),%rax
jne    1141 <CommandWaitComplete+0x21>
movb   $0x34,-0x11(%rbp)
jmp    1145 <CommandWaitComplete+0x25>
movb   $0x56,-0x11(%rbp)
movzbl -0x11(%rbp),%eax
shl    $0x8,%rax
or     $0x400f0000,%rax
or     $0x80,%rax
mov    %eax,%edi
xor    %esi,%esi
call   1040 <McDevIf_AddPacket@plt>
mov    $0x0,%al
call   1030 <McDevIf_ExecutePacket@plt>
mov    %rax,-0x10(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
jle    1196 <CommandWaitComplete+0x76>
movzbl -0x11(%rbp),%eax
or     $0x20004000,%rax
mov    %eax,%edi
mov    $0x80,%esi
call   1040 <McDevIf_AddPacket@plt>
mov    $0x0,%al
call   1030 <McDevIf_ExecutePacket@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CommandWaitComplete>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
mov    $0x34,%eax
mov    $0x56,%ebx
cmove  %eax,%ebx
mov    %ebx,%edi
shl    $0x8,%edi
or     $0x400f0080,%edi
xor    %esi,%esi
call   1040 <McDevIf_AddPacket@plt>
xor    %eax,%eax
call   1030 <McDevIf_ExecutePacket@plt>
mov    %rax,%r14
test   %rax,%rax
jns    116e <CommandWaitComplete+0x4e>
or     $0x20004000,%ebx
mov    %ebx,%edi
mov    $0x80,%esi
call   1040 <McDevIf_AddPacket@plt>
xor    %eax,%eax
call   1030 <McDevIf_ExecutePacket@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i64 @CommandWaitComplete(i64 %0) {
%2 = alloca i64
%3 = alloca i64
%4 = alloca i8
store i64 %0, i64* %2
%5 = load i64, i64* %2
%6 = icmp eq i64 0, %5
br i1 %6, label %7, label %8
7: ; preds = %1
store i8 52, i8* %4
br label %9
8: ; preds = %1
store i8 86, i8* %4
br label %9
9: ; preds = %8, %7
%10 = load i8, i8* %4
%11 = zext i8 %10 to i64
%12 = shl i64 %11, 8
%13 = or i64 1074724864, %12
%14 = or i64 %13, 128
%15 = trunc i64 %14 to i32
%16 = call i32 @McDevIf_AddPacket(i32 %15, i32 0)
%17 = call i64 (...) @McDevIf_ExecutePacket()
store i64 %17, i64* %3
%18 = load i64, i64* %3
%19 = icmp sgt i64 0, %18
br i1 %19, label %20, label %27
20: ; preds = %9
%21 = load i8, i8* %4
%22 = zext i8 %21 to i64
%23 = or i64 536887296, %22
%24 = trunc i64 %23 to i32
%25 = call i32 @McDevIf_AddPacket(i32 %24, i32 128)
%26 = call i64 (...) @McDevIf_ExecutePacket()
br label %27
27: ; preds = %20, %9
%28 = load i64, i64* %3
ret i64 %28
}

LLVM IR (-O2):
define i64 @CommandWaitComplete(i64 %0) {
%2 = icmp eq i64 %0, 0
%3 = select i1 %2, i32 52, i32 86
%4 = shl nuw nsw i32 %3, 8
%5 = or i32 %4, 1074724992
%6 = tail call i32 @McDevIf_AddPacket(i32 %5, i32 0)
%7 = tail call i64 (...) @McDevIf_ExecutePacket()
%8 = icmp slt i64 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %1
%10 = or i32 %3, 536887296
%11 = tail call i32 @McDevIf_AddPacket(i32 %10, i32 128)
%12 = tail call i64 (...) @McDevIf_ExecutePacket()
br label %13
13: ; preds = %9, %1
ret i64 %7
}