#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, unsigned char);
int /*<<< orphan*/ McDevIf_ExecutePacket();
int /*<<< orphan*/ McDevIf_ReadDirect(int, unsigned char *);
void FifoReset(unsigned long dTargetFifo) {
  unsigned char bData;
  McDevIf_ReadDirect(((0x00004000UL) | (unsigned long)(14)), &bData);
  if ((0x00000000UL) != ((0x0000FF00UL) & dTargetFifo)) {
    bData |= (0x08);
    McDevIf_AddPacket(((0x20000000UL) | (0x00004000UL) | (unsigned long)(14)),
                      bData);
    bData &= (unsigned char)~(0x08);
    McDevIf_AddPacket(((0x20000000UL) | (0x00004000UL) | (unsigned long)(14)),
                      bData);
  }
  if ((0x00000000UL) != ((0x00FF0000UL) & dTargetFifo)) {
    bData |= (0x02);
    McDevIf_AddPacket(((0x20000000UL) | (0x00004000UL) | (unsigned long)(14)),
                      bData);
    bData &= (unsigned char)~(0x02);
    McDevIf_AddPacket(((0x20000000UL) | (0x00004000UL) | (unsigned long)(14)),
                      bData);
  }
  McDevIf_ExecutePacket();
}


x86 assembly (clang, -O0):
<FifoReset>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x400e,%edi
lea    -0x9(%rbp),%rsi
call   1030 <McDevIf_ReadDirect@plt>
mov    -0x8(%rbp),%rcx
and    $0xff00,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     1192 <FifoReset+0x62>
movzbl -0x9(%rbp),%eax
or     $0x8,%eax
mov    %al,-0x9(%rbp)
mov    $0x2000400e,%edi
movzbl -0x9(%rbp),%esi
call   1050 <McDevIf_AddPacket@plt>
movzbl -0x9(%rbp),%eax
and    $0xf7,%eax
mov    %al,-0x9(%rbp)
mov    $0x2000400e,%edi
movzbl -0x9(%rbp),%esi
call   1050 <McDevIf_AddPacket@plt>
mov    -0x8(%rbp),%rcx
and    $0xff0000,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     11da <FifoReset+0xaa>
movzbl -0x9(%rbp),%eax
or     $0x2,%eax
mov    %al,-0x9(%rbp)
mov    $0x2000400e,%edi
movzbl -0x9(%rbp),%esi
call   1050 <McDevIf_AddPacket@plt>
movzbl -0x9(%rbp),%eax
and    $0xfd,%eax
mov    %al,-0x9(%rbp)
mov    $0x2000400e,%edi
movzbl -0x9(%rbp),%esi
call   1050 <McDevIf_AddPacket@plt>
mov    $0x0,%al
call   1040 <McDevIf_ExecutePacket@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FifoReset>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0xf(%rsp),%rsi
mov    $0x400e,%edi
call   1030 <McDevIf_ReadDirect@plt>
test   $0xff00,%ebx
je     117d <FifoReset+0x4d>
movzbl 0xf(%rsp),%esi
or     $0x8,%esi
mov    %sil,0xf(%rsp)
mov    $0x2000400e,%edi
call   1050 <McDevIf_AddPacket@plt>
movzbl 0xf(%rsp),%esi
and    $0xfffffff7,%esi
mov    %sil,0xf(%rsp)
mov    $0x2000400e,%edi
call   1050 <McDevIf_AddPacket@plt>
test   $0xff0000,%ebx
je     11b3 <FifoReset+0x83>
movzbl 0xf(%rsp),%esi
or     $0x2,%esi
mov    %sil,0xf(%rsp)
mov    $0x2000400e,%edi
call   1050 <McDevIf_AddPacket@plt>
movzbl 0xf(%rsp),%esi
and    $0xfffffffd,%esi
mov    %sil,0xf(%rsp)
mov    $0x2000400e,%edi
call   1050 <McDevIf_AddPacket@plt>
xor    %eax,%eax
call   1040 <McDevIf_ExecutePacket@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @FifoReset(i64 %0) {
%2 = alloca i64
%3 = alloca i8
store i64 %0, i64* %2
%4 = call i32 @McDevIf_ReadDirect(i32 16398, i8* %3)
%5 = load i64, i64* %2
%6 = and i64 65280, %5
%7 = icmp ne i64 0, %6
br i1 %7, label %8, label %21
8: ; preds = %1
%9 = load i8, i8* %3
%10 = zext i8 %9 to i32
%11 = or i32 %10, 8
%12 = trunc i32 %11 to i8
store i8 %12, i8* %3
%13 = load i8, i8* %3
%14 = call i32 @McDevIf_AddPacket(i32 536887310, i8 zeroext %13)
%15 = load i8, i8* %3
%16 = zext i8 %15 to i32
%17 = and i32 %16, 247
%18 = trunc i32 %17 to i8
store i8 %18, i8* %3
%19 = load i8, i8* %3
%20 = call i32 @McDevIf_AddPacket(i32 536887310, i8 zeroext %19)
br label %21
21: ; preds = %8, %1
%22 = load i64, i64* %2
%23 = and i64 16711680, %22
%24 = icmp ne i64 0, %23
br i1 %24, label %25, label %38
25: ; preds = %21
%26 = load i8, i8* %3
%27 = zext i8 %26 to i32
%28 = or i32 %27, 2
%29 = trunc i32 %28 to i8
store i8 %29, i8* %3
%30 = load i8, i8* %3
%31 = call i32 @McDevIf_AddPacket(i32 536887310, i8 zeroext %30)
%32 = load i8, i8* %3
%33 = zext i8 %32 to i32
%34 = and i32 %33, 253
%35 = trunc i32 %34 to i8
store i8 %35, i8* %3
%36 = load i8, i8* %3
%37 = call i32 @McDevIf_AddPacket(i32 536887310, i8 zeroext %36)
br label %38
38: ; preds = %25, %21
%39 = call i32 (...) @McDevIf_ExecutePacket()
ret void
}

LLVM IR (-O2):
define void @FifoReset(i64 %0) {
%2 = alloca i8
%3 = call i32 @McDevIf_ReadDirect(i32 16398, i8* %2)
%4 = and i64 %0, 65280
%5 = icmp eq i64 %4, 0
br i1 %5, label %13, label %6
6: ; preds = %1
%7 = load i8, i8* %2
%8 = or i8 %7, 8
store i8 %8, i8* %2
%9 = call i32 @McDevIf_AddPacket(i32 536887310, i8 zeroext %8)
%10 = load i8, i8* %2
%11 = and i8 %10, -9
store i8 %11, i8* %2
%12 = call i32 @McDevIf_AddPacket(i32 536887310, i8 zeroext %11)
br label %13
13: ; preds = %6, %1
%14 = and i64 %0, 16711680
%15 = icmp eq i64 %14, 0
br i1 %15, label %23, label %16
16: ; preds = %13
%17 = load i8, i8* %2
%18 = or i8 %17, 2
store i8 %18, i8* %2
%19 = call i32 @McDevIf_AddPacket(i32 536887310, i8 zeroext %18)
%20 = load i8, i8* %2
%21 = and i8 %20, -3
store i8 %21, i8* %2
%22 = call i32 @McDevIf_AddPacket(i32 536887310, i8 zeroext %21)
br label %23
23: ; preds = %16, %13
%24 = call i32 (...) @McDevIf_ExecutePacket()
ret void
}