#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 */
scalar_t__ CmdRdChk_OFILM();
int /*<<< orphan*/ RegReadA_Ofilm(unsigned short, unsigned char *);
int /*<<< orphan*/ RegWriteA_Ofilm(unsigned short, unsigned char);
void BsyWit_OFILM(unsigned short UsTrgAdr_OFILM, unsigned char UcTrgDat_OFILM) {
  unsigned char UcFlgVal_OFILM;
  RegWriteA_Ofilm(UsTrgAdr_OFILM, UcTrgDat_OFILM);
  UcFlgVal_OFILM = 1;
  while (UcFlgVal_OFILM) {
    RegReadA_Ofilm(UsTrgAdr_OFILM, &UcFlgVal_OFILM);
    UcFlgVal_OFILM &= (UcTrgDat_OFILM & 0x0F);
    if (CmdRdChk_OFILM() != 0)
      break;
  };
}


x86 assembly (clang, -O0):
<BsyWit_OFILM>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %di,%cx
mov    %cx,-0x2(%rbp)
mov    %al,-0x3(%rbp)
mov    -0x2(%rbp),%ax
movzwl %ax,%edi
movzbl -0x3(%rbp),%esi
call   1050 <RegWriteA_Ofilm@plt>
movb   $0x1,-0x4(%rbp)
cmpb   $0x0,-0x4(%rbp)
je     119b <BsyWit_OFILM+0x6b>
lea    -0x4(%rbp),%rsi
movzwl -0x2(%rbp),%edi
call   1030 <RegReadA_Ofilm@plt>
movzbl -0x3(%rbp),%ecx
and    $0xf,%ecx
movzbl -0x4(%rbp),%eax
and    %ecx,%eax
mov    %al,-0x4(%rbp)
mov    $0x0,%al
call   1040 <CmdRdChk_OFILM@plt>
cmp    $0x0,%rax
je     1196 <BsyWit_OFILM+0x66>
jmp    119b <BsyWit_OFILM+0x6b>
jmp    1159 <BsyWit_OFILM+0x29>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BsyWit_OFILM>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebx
mov    %edi,%ebp
call   1050 <RegWriteA_Ofilm@plt>
movb   $0x1,0xf(%rsp)
and    $0xf,%bl
movzwl %bp,%ebp
lea    0xf(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %r14,%rsi
call   1030 <RegReadA_Ofilm@plt>
and    %bl,0xf(%rsp)
xor    %eax,%eax
call   1040 <CmdRdChk_OFILM@plt>
test   %rax,%rax
jne    1181 <BsyWit_OFILM+0x51>
cmpb   $0x0,0xf(%rsp)
jne    1160 <BsyWit_OFILM+0x30>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @BsyWit_OFILM(i16 zeroext %0, i8 zeroext %1) {
%3 = alloca i16
%4 = alloca i8
%5 = alloca i8
store i16 %0, i16* %3
store i8 %1, i8* %4
%6 = load i16, i16* %3
%7 = load i8, i8* %4
%8 = call i32 @RegWriteA_Ofilm(i16 zeroext %6, i8 zeroext %7)
store i8 1, i8* %5
br label %9
9: ; preds = %25, %2
%10 = load i8, i8* %5
%11 = icmp ne i8 %10, 0
br i1 %11, label %12, label %26
12: ; preds = %9
%13 = load i16, i16* %3
%14 = call i32 @RegReadA_Ofilm(i16 zeroext %13, i8* %5)
%15 = load i8, i8* %4
%16 = zext i8 %15 to i32
%17 = and i32 %16, 15
%18 = load i8, i8* %5
%19 = zext i8 %18 to i32
%20 = and i32 %19, %17
%21 = trunc i32 %20 to i8
store i8 %21, i8* %5
%22 = call i64 (...) @CmdRdChk_OFILM()
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %12
br label %26
25: ; preds = %12
br label %9
26: ; preds = %24, %9
ret void
}

LLVM IR (-O2):
define void @BsyWit_OFILM(i16 zeroext %0, i8 zeroext %1) {
%3 = alloca i8
%4 = tail call i32 @RegWriteA_Ofilm(i16 zeroext %0, i8 zeroext %1)
store i8 1, i8* %3
%5 = and i8 %1, 15
br label %6
6: ; preds = %2, %6
%7 = call i32 @RegReadA_Ofilm(i16 zeroext %0, i8* %3)
%8 = load i8, i8* %3
%9 = and i8 %5, %8
store i8 %9, i8* %3
%10 = call i64 (...) @CmdRdChk_OFILM()
%11 = icmp eq i64 %10, 0
%12 = load i8, i8* %3
%13 = icmp ne i8 %12, 0
%14 = select i1 %11, i1 %13, i1 false
br i1 %14, label %6, label %15
15: ; preds = %6
ret void
}