#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 */
unsigned short CyBtldr_ComputeChecksum(unsigned char *, unsigned int const);
int CyBtldr_CreateVerifyRowCmd(unsigned char arrayId, unsigned short rowNum,
                               unsigned char *cmdBuf, unsigned long *cmdSize,
                               unsigned long *resSize) {
  const unsigned long RESULT_DATA_SIZE = 1;
  const unsigned long COMMAND_DATA_SIZE = 3;
  const unsigned int COMMAND_SIZE = 0x07 + COMMAND_DATA_SIZE;
  unsigned short checksum;
  *resSize = 0x07 + RESULT_DATA_SIZE;
  *cmdSize = COMMAND_SIZE;
  cmdBuf[0] = 0x01;
  cmdBuf[1] = 0x3A;
  cmdBuf[2] = (unsigned char)COMMAND_DATA_SIZE;
  cmdBuf[3] = (unsigned char)(COMMAND_DATA_SIZE >> 8);
  cmdBuf[4] = arrayId;
  cmdBuf[5] = (unsigned char)rowNum;
  cmdBuf[6] = (unsigned char)(rowNum >> 8);
  checksum = CyBtldr_ComputeChecksum(cmdBuf, COMMAND_SIZE - 3);
  cmdBuf[7] = (unsigned char)checksum;
  cmdBuf[8] = (unsigned char)(checksum >> 8);
  cmdBuf[9] = 0x17;
  return 0x00;
}


x86 assembly (clang, -O0):
<CyBtldr_CreateVerifyRowCmd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %si,%ax
mov    %dil,%sil
mov    %sil,-0x1(%rbp)
mov    %ax,-0x4(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
movq   $0x1,-0x28(%rbp)
movq   $0x3,-0x30(%rbp)
movl   $0xa,-0x34(%rbp)
mov    -0x20(%rbp),%rax
movq   $0x8,(%rax)
mov    -0x18(%rbp),%rax
movq   $0xa,(%rax)
mov    -0x10(%rbp),%rax
movb   $0x1,(%rax)
mov    -0x10(%rbp),%rax
movb   $0x3a,0x1(%rax)
mov    -0x10(%rbp),%rax
movb   $0x3,0x2(%rax)
mov    -0x10(%rbp),%rax
movb   $0x0,0x3(%rax)
mov    -0x1(%rbp),%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x4(%rax)
mov    -0x4(%rbp),%ax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x5(%rax)
movzwl -0x4(%rbp),%eax
sar    $0x8,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x6(%rax)
mov    -0x10(%rbp),%rdi
mov    $0x7,%esi
call   1030 <CyBtldr_ComputeChecksum@plt>
mov    %ax,-0x36(%rbp)
mov    -0x36(%rbp),%ax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x7(%rax)
movzwl -0x36(%rbp),%eax
sar    $0x8,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x8(%rax)
mov    -0x10(%rbp),%rax
movb   $0x17,0x9(%rax)
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CyBtldr_CreateVerifyRowCmd>:
push   %rbx
mov    %rdx,%rbx
mov    %esi,%eax
movq   $0x8,(%r8)
movq   $0xa,(%rcx)
movl   $0x33a01,(%rdx)
mov    %dil,0x4(%rdx)
mov    %al,0x5(%rdx)
mov    %ah,0x6(%rdx)
mov    %rdx,%rdi
mov    $0x7,%esi
call   1030 <CyBtldr_ComputeChecksum@plt>
mov    %al,0x7(%rbx)
mov    %ah,0x8(%rbx)
movb   $0x17,0x9(%rbx)
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @CyBtldr_CreateVerifyRowCmd(i8 zeroext %0, i16 zeroext %1, i8* %2, i64* %3, i64* %4) {
%6 = alloca i8
%7 = alloca i16
%8 = alloca i8*
%9 = alloca i64*
%10 = alloca i64*
%11 = alloca i64
%12 = alloca i64
%13 = alloca i32
%14 = alloca i16
store i8 %0, i8* %6
store i16 %1, i16* %7
store i8* %2, i8** %8
store i64* %3, i64** %9
store i64* %4, i64** %10
store i64 1, i64* %11
store i64 3, i64* %12
store i32 10, i32* %13
%15 = load i64*, i64** %10
store i64 8, i64* %15
%16 = load i64*, i64** %9
store i64 10, i64* %16
%17 = load i8*, i8** %8
%18 = getelementptr inbounds i8, i8* %17, i64 0
store i8 1, i8* %18
%19 = load i8*, i8** %8
%20 = getelementptr inbounds i8, i8* %19, i64 1
store i8 58, i8* %20
%21 = load i8*, i8** %8
%22 = getelementptr inbounds i8, i8* %21, i64 2
store i8 3, i8* %22
%23 = load i8*, i8** %8
%24 = getelementptr inbounds i8, i8* %23, i64 3
store i8 0, i8* %24
%25 = load i8, i8* %6
%26 = load i8*, i8** %8
%27 = getelementptr inbounds i8, i8* %26, i64 4
store i8 %25, i8* %27
%28 = load i16, i16* %7
%29 = trunc i16 %28 to i8
%30 = load i8*, i8** %8
%31 = getelementptr inbounds i8, i8* %30, i64 5
store i8 %29, i8* %31
%32 = load i16, i16* %7
%33 = zext i16 %32 to i32
%34 = ashr i32 %33, 8
%35 = trunc i32 %34 to i8
%36 = load i8*, i8** %8
%37 = getelementptr inbounds i8, i8* %36, i64 6
store i8 %35, i8* %37
%38 = load i8*, i8** %8
%39 = call zeroext i16 @CyBtldr_ComputeChecksum(i8* %38, i32 7)
store i16 %39, i16* %14
%40 = load i16, i16* %14
%41 = trunc i16 %40 to i8
%42 = load i8*, i8** %8
%43 = getelementptr inbounds i8, i8* %42, i64 7
store i8 %41, i8* %43
%44 = load i16, i16* %14
%45 = zext i16 %44 to i32
%46 = ashr i32 %45, 8
%47 = trunc i32 %46 to i8
%48 = load i8*, i8** %8
%49 = getelementptr inbounds i8, i8* %48, i64 8
store i8 %47, i8* %49
%50 = load i8*, i8** %8
%51 = getelementptr inbounds i8, i8* %50, i64 9
store i8 23, i8* %51
ret i32 0
}

LLVM IR (-O2):
define i32 @CyBtldr_CreateVerifyRowCmd(i8 zeroext %0, i16 zeroext %1, i8* %2, i64* nocapture writeonly %3, i64* nocapture writeonly %4) {
store i64 8, i64* %4
store i64 10, i64* %3
store i8 1, i8* %2
%6 = getelementptr inbounds i8, i8* %2, i64 1
store i8 58, i8* %6
%7 = getelementptr inbounds i8, i8* %2, i64 2
store i8 3, i8* %7
%8 = getelementptr inbounds i8, i8* %2, i64 3
store i8 0, i8* %8
%9 = getelementptr inbounds i8, i8* %2, i64 4
store i8 %0, i8* %9
%10 = trunc i16 %1 to i8
%11 = getelementptr inbounds i8, i8* %2, i64 5
store i8 %10, i8* %11
%12 = lshr i16 %1, 8
%13 = trunc i16 %12 to i8
%14 = getelementptr inbounds i8, i8* %2, i64 6
store i8 %13, i8* %14
%15 = tail call zeroext i16 @CyBtldr_ComputeChecksum(i8* %2, i32 7)
%16 = trunc i16 %15 to i8
%17 = getelementptr inbounds i8, i8* %2, i64 7
store i8 %16, i8* %17
%18 = lshr i16 %15, 8
%19 = trunc i16 %18 to i8
%20 = getelementptr inbounds i8, i8* %2, i64 8
store i8 %19, i8* %20
%21 = getelementptr inbounds i8, i8* %2, i64 9
store i8 23, i8* %21
ret i32 0
}