#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 CyBtldr_CreateEraseRowCmd(unsigned char, unsigned short, unsigned char *,
                              unsigned long *, unsigned long *);
int CyBtldr_ParseEraseRowCmdResult(unsigned char *, unsigned long,
                                   unsigned char *);
int CyBtldr_TransferData(unsigned char *, unsigned long, unsigned char *,
                         unsigned long);
int CyBtldr_ValidateRow(unsigned char, unsigned short);
int CyBtldr_EraseRow(unsigned char arrayID, unsigned short rowNum) {
  unsigned char inBuf[512];
  unsigned char outBuf[512];
  unsigned long inSize = 0;
  unsigned long outSize = 0;
  unsigned char status = 0x00;
  int err = CyBtldr_ValidateRow(arrayID, rowNum);
  if (0x00 == err)
    err = CyBtldr_CreateEraseRowCmd(arrayID, rowNum, inBuf, &inSize, &outSize);
  if (0x00 == err)
    err = CyBtldr_TransferData(inBuf, inSize, outBuf, outSize);
  if (0x00 == err)
    err = CyBtldr_ParseEraseRowCmdResult(outBuf, outSize, &status);
  if (0x00 != status)
    err = status | 0x4000;
  return err;
}


x86 assembly (clang, -O0):
<CyBtldr_EraseRow>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %si,%ax
mov    %dil,%cl
mov    %cl,-0x1(%rbp)
mov    %ax,-0x4(%rbp)
movq   $0x0,-0x418(%rbp)
movq   $0x0,-0x420(%rbp)
movb   $0x0,-0x421(%rbp)
mov    -0x1(%rbp),%al
movzbl %al,%edi
movzwl -0x4(%rbp),%esi
call   1030 <CyBtldr_ValidateRow@plt>
mov    %eax,-0x428(%rbp)
xor    %eax,%eax
cmp    -0x428(%rbp),%eax
jne    11c7 <CyBtldr_EraseRow+0x87>
mov    -0x1(%rbp),%sil
mov    -0x4(%rbp),%ax
lea    -0x210(%rbp),%rdx
lea    -0x418(%rbp),%rcx
lea    -0x420(%rbp),%r8
movzbl %sil,%edi
movzwl %ax,%esi
call   1050 <CyBtldr_CreateEraseRowCmd@plt>
mov    %eax,-0x428(%rbp)
xor    %eax,%eax
cmp    -0x428(%rbp),%eax
jne    11fc <CyBtldr_EraseRow+0xbc>
lea    -0x210(%rbp),%rdi
mov    -0x418(%rbp),%rsi
lea    -0x410(%rbp),%rdx
mov    -0x420(%rbp),%rcx
call   1060 <CyBtldr_TransferData@plt>
mov    %eax,-0x428(%rbp)
xor    %eax,%eax
cmp    -0x428(%rbp),%eax
jne    122a <CyBtldr_EraseRow+0xea>
lea    -0x410(%rbp),%rdi
mov    -0x420(%rbp),%rsi
lea    -0x421(%rbp),%rdx
call   1040 <CyBtldr_ParseEraseRowCmdResult@plt>
mov    %eax,-0x428(%rbp)
movzbl -0x421(%rbp),%ecx
xor    %eax,%eax
cmp    %ecx,%eax
je     124d <CyBtldr_EraseRow+0x10d>
movzbl -0x421(%rbp),%eax
or     $0x4000,%eax
mov    %eax,-0x428(%rbp)
mov    -0x428(%rbp),%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CyBtldr_EraseRow>:
push   %rbp
push   %rbx
sub    $0x428,%rsp
mov    %esi,%ebx
mov    %edi,%ebp
movq   $0x0,0x18(%rsp)
movq   $0x0,0x10(%rsp)
movb   $0x0,0xf(%rsp)
call   1030 <CyBtldr_ValidateRow@plt>
test   %eax,%eax
jne    11d4 <CyBtldr_EraseRow+0x94>
movzbl %bpl,%edi
movzwl %bx,%esi
lea    0x220(%rsp),%rdx
lea    0x18(%rsp),%rcx
lea    0x10(%rsp),%r8
call   1050 <CyBtldr_CreateEraseRowCmd@plt>
test   %eax,%eax
jne    11d4 <CyBtldr_EraseRow+0x94>
mov    0x18(%rsp),%rsi
mov    0x10(%rsp),%rcx
lea    0x220(%rsp),%rdi
lea    0x20(%rsp),%rdx
call   1060 <CyBtldr_TransferData@plt>
test   %eax,%eax
jne    11d4 <CyBtldr_EraseRow+0x94>
mov    0x10(%rsp),%rsi
lea    0x20(%rsp),%rdi
lea    0xf(%rsp),%rdx
call   1040 <CyBtldr_ParseEraseRowCmdResult@plt>
movzbl 0xf(%rsp),%ecx
test   %ecx,%ecx
je     11d4 <CyBtldr_EraseRow+0x94>
or     $0x4000,%ecx
mov    %ecx,%eax
add    $0x428,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @CyBtldr_EraseRow(i8 zeroext %0, i16 zeroext %1) {
%3 = alloca i8
%4 = alloca i16
%5 = alloca [512 x i8]
%6 = alloca [512 x i8]
%7 = alloca i64
%8 = alloca i64
%9 = alloca i8
%10 = alloca i32
store i8 %0, i8* %3
store i16 %1, i16* %4
store i64 0, i64* %7
store i64 0, i64* %8
store i8 0, i8* %9
%11 = load i8, i8* %3
%12 = load i16, i16* %4
%13 = call i32 @CyBtldr_ValidateRow(i8 zeroext %11, i16 zeroext %12)
store i32 %13, i32* %10
%14 = load i32, i32* %10
%15 = icmp eq i32 0, %14
br i1 %15, label %16, label %21
16: ; preds = %2
%17 = load i8, i8* %3
%18 = load i16, i16* %4
%19 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%20 = call i32 @CyBtldr_CreateEraseRowCmd(i8 zeroext %17, i16 zeroext %18, i8* %19, i64* %7, i64* %8)
store i32 %20, i32* %10
br label %21
21: ; preds = %16, %2
%22 = load i32, i32* %10
%23 = icmp eq i32 0, %22
br i1 %23, label %24, label %30
24: ; preds = %21
%25 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%26 = load i64, i64* %7
%27 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%28 = load i64, i64* %8
%29 = call i32 @CyBtldr_TransferData(i8* %25, i64 %26, i8* %27, i64 %28)
store i32 %29, i32* %10
br label %30
30: ; preds = %24, %21
%31 = load i32, i32* %10
%32 = icmp eq i32 0, %31
br i1 %32, label %33, label %37
33: ; preds = %30
%34 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%35 = load i64, i64* %8
%36 = call i32 @CyBtldr_ParseEraseRowCmdResult(i8* %34, i64 %35, i8* %9)
store i32 %36, i32* %10
br label %37
37: ; preds = %33, %30
%38 = load i8, i8* %9
%39 = zext i8 %38 to i32
%40 = icmp ne i32 0, %39
br i1 %40, label %41, label %45
41: ; preds = %37
%42 = load i8, i8* %9
%43 = zext i8 %42 to i32
%44 = or i32 %43, 16384
store i32 %44, i32* %10
br label %45
45: ; preds = %41, %37
%46 = load i32, i32* %10
ret i32 %46
}

LLVM IR (-O2):
define i32 @CyBtldr_EraseRow(i8 zeroext %0, i16 zeroext %1) {
%3 = alloca [512 x i8]
%4 = alloca [512 x i8]
%5 = alloca i64
%6 = alloca i64
%7 = alloca i8
%8 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%10 = bitcast i64* %5 to i8*
store i64 0, i64* %5
%11 = bitcast i64* %6 to i8*
store i64 0, i64* %6
store i8 0, i8* %7
%12 = tail call i32 @CyBtldr_ValidateRow(i8 zeroext %0, i16 zeroext %1)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %29
14: ; preds = %2
%15 = call i32 @CyBtldr_CreateEraseRowCmd(i8 zeroext %0, i16 zeroext %1, i8* %8, i64* %5, i64* %6)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %29
17: ; preds = %14
%18 = load i64, i64* %5
%19 = load i64, i64* %6
%20 = call i32 @CyBtldr_TransferData(i8* %8, i64 %18, i8* %9, i64 %19)
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %29
22: ; preds = %17
%23 = load i64, i64* %6
%24 = call i32 @CyBtldr_ParseEraseRowCmdResult(i8* %9, i64 %23, i8* %7)
%25 = load i8, i8* %7
%26 = icmp eq i8 %25, 0
%27 = zext i8 %25 to i32
%28 = or i32 %27, 16384
br i1 %26, label %29, label %31
29: ; preds = %2, %14, %17, %22
%30 = phi i32 [ %24, %22 ], [ %12, %2 ], [ %15, %14 ], [ %20, %17 ]
br label %31
31: ; preds = %22, %29
%32 = phi i32 [ %30, %29 ], [ %28, %22 ]
ret i32 %32
}