#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*/ RegReadA(int, unsigned char *);
int AccWit(unsigned char UcTrgDat) {
  unsigned char UcFlgVal;
  unsigned char UcCntPla;
  UcFlgVal = 1;
  UcCntPla = 0;
  do {
    RegReadA(0x0282, &UcFlgVal);
    UcFlgVal &= UcTrgDat;
    UcCntPla++;
  } while (UcFlgVal && (UcCntPla < 6));
  if (UcCntPla == 6) {
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<AccWit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
movb   $0x1,-0x6(%rbp)
movb   $0x0,-0x7(%rbp)
mov    $0x282,%edi
lea    -0x6(%rbp),%rsi
call   1030 <RegReadA@plt>
movzbl -0x5(%rbp),%ecx
movzbl -0x6(%rbp),%eax
and    %ecx,%eax
mov    %al,-0x6(%rbp)
mov    -0x7(%rbp),%al
add    $0x1,%al
mov    %al,-0x7(%rbp)
movzbl -0x6(%rbp),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x8(%rbp)
je     1168 <AccWit+0x58>
movzbl -0x7(%rbp),%eax
cmp    $0x6,%eax
setl   %al
mov    %al,-0x8(%rbp)
mov    -0x8(%rbp),%al
test   $0x1,%al
jne    1126 <AccWit+0x16>
movzbl -0x7(%rbp),%eax
cmp    $0x6,%eax
jne    118c <AccWit+0x7c>
movl   $0xffffffff,-0x4(%rbp)
jmp    1193 <AccWit+0x83>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AccWit>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebp
movb   $0x1,0xf(%rsp)
xor    %ebx,%ebx
lea    0xf(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
mov    $0x282,%edi
mov    %r14,%rsi
call   1030 <RegReadA@plt>
lea    0x1(%rbx),%ecx
and    %bpl,0xf(%rsp)
je     114e <AccWit+0x3e>
cmp    $0x5,%bl
mov    %ecx,%ebx
jb     1130 <AccWit+0x20>
xor    %eax,%eax
cmp    $0x6,%cl
sete   %al
neg    %eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @AccWit(i8 zeroext %0) {
%2 = alloca i8
store i8 1, i8* %2
br label %3
3: ; preds = %3, %1
%4 = phi i8 [ 0, %1 ], [ %8, %3 ]
%5 = call i32 @RegReadA(i32 642, i8* %2)
%6 = load i8, i8* %2
%7 = and i8 %6, %0
store i8 %7, i8* %2
%8 = add nuw nsw i8 %4, 1
%9 = icmp ne i8 %7, 0
%10 = icmp ult i8 %4, 5
%11 = select i1 %9, i1 %10, i1 false
br i1 %11, label %3, label %12
12: ; preds = %3
%13 = icmp eq i8 %8, 6
%14 = sext i1 %13 to i32
ret i32 %14
}