#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 *, int);
int CyBtldr_CreateSyncBootLoaderCmd(unsigned char *cmdBuf,
                                    unsigned long *cmdSize,
                                    unsigned long *resSize) {
  unsigned short checksum;
  *resSize = 0x07;
  *cmdSize = 0x07;
  cmdBuf[0] = 0x01;
  cmdBuf[1] = 0x35;
  cmdBuf[2] = 0;
  cmdBuf[3] = 0;
  checksum = CyBtldr_ComputeChecksum(cmdBuf, 0x07 - 3);
  cmdBuf[4] = (unsigned char)checksum;
  cmdBuf[5] = (unsigned char)(checksum >> 8);
  cmdBuf[6] = 0x17;
  return 0x00;
}


x86 assembly (clang, -O0):
<CyBtldr_CreateSyncBootLoaderCmd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movq   $0x7,(%rax)
mov    -0x10(%rbp),%rax
movq   $0x7,(%rax)
mov    -0x8(%rbp),%rax
movb   $0x1,(%rax)
mov    -0x8(%rbp),%rax
movb   $0x35,0x1(%rax)
mov    -0x8(%rbp),%rax
movb   $0x0,0x2(%rax)
mov    -0x8(%rbp),%rax
movb   $0x0,0x3(%rax)
mov    -0x8(%rbp),%rdi
mov    $0x4,%esi
call   1030 <CyBtldr_ComputeChecksum@plt>
mov    %ax,-0x1a(%rbp)
mov    -0x1a(%rbp),%ax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x4(%rax)
movzwl -0x1a(%rbp),%eax
sar    $0x8,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x5(%rax)
mov    -0x8(%rbp),%rax
movb   $0x17,0x6(%rax)
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CyBtldr_CreateSyncBootLoaderCmd>:
push   %rbx
mov    %rdi,%rbx
movq   $0x7,(%rdx)
movq   $0x7,(%rsi)
movl   $0x3501,(%rdi)
mov    $0x4,%esi
call   1030 <CyBtldr_ComputeChecksum@plt>
mov    %al,0x4(%rbx)
mov    %ah,0x5(%rbx)
movb   $0x17,0x6(%rbx)
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @CyBtldr_CreateSyncBootLoaderCmd(i8* %0, i64* %1, i64* %2) {
%4 = alloca i8*
%5 = alloca i64*
%6 = alloca i64*
%7 = alloca i16
store i8* %0, i8** %4
store i64* %1, i64** %5
store i64* %2, i64** %6
%8 = load i64*, i64** %6
store i64 7, i64* %8
%9 = load i64*, i64** %5
store i64 7, i64* %9
%10 = load i8*, i8** %4
%11 = getelementptr inbounds i8, i8* %10, i64 0
store i8 1, i8* %11
%12 = load i8*, i8** %4
%13 = getelementptr inbounds i8, i8* %12, i64 1
store i8 53, i8* %13
%14 = load i8*, i8** %4
%15 = getelementptr inbounds i8, i8* %14, i64 2
store i8 0, i8* %15
%16 = load i8*, i8** %4
%17 = getelementptr inbounds i8, i8* %16, i64 3
store i8 0, i8* %17
%18 = load i8*, i8** %4
%19 = call zeroext i16 @CyBtldr_ComputeChecksum(i8* %18, i32 4)
store i16 %19, i16* %7
%20 = load i16, i16* %7
%21 = trunc i16 %20 to i8
%22 = load i8*, i8** %4
%23 = getelementptr inbounds i8, i8* %22, i64 4
store i8 %21, i8* %23
%24 = load i16, i16* %7
%25 = zext i16 %24 to i32
%26 = ashr i32 %25, 8
%27 = trunc i32 %26 to i8
%28 = load i8*, i8** %4
%29 = getelementptr inbounds i8, i8* %28, i64 5
store i8 %27, i8* %29
%30 = load i8*, i8** %4
%31 = getelementptr inbounds i8, i8* %30, i64 6
store i8 23, i8* %31
ret i32 0
}

LLVM IR (-O2):
define i32 @CyBtldr_CreateSyncBootLoaderCmd(i8* %0, i64* nocapture writeonly %1, i64* nocapture writeonly %2) {
store i64 7, i64* %2
store i64 7, i64* %1
store i8 1, i8* %0
%4 = getelementptr inbounds i8, i8* %0, i64 1
store i8 53, i8* %4
%5 = getelementptr inbounds i8, i8* %0, i64 2
store i8 0, i8* %5
%6 = getelementptr inbounds i8, i8* %0, i64 3
store i8 0, i8* %6
%7 = tail call zeroext i16 @CyBtldr_ComputeChecksum(i8* %0, i32 4)
%8 = trunc i16 %7 to i8
%9 = getelementptr inbounds i8, i8* %0, i64 4
store i8 %8, i8* %9
%10 = lshr i16 %7, 8
%11 = trunc i16 %10 to i8
%12 = getelementptr inbounds i8, i8* %0, i64 5
store i8 %11, i8* %12
%13 = getelementptr inbounds i8, i8* %0, i64 6
store i8 23, i8* %13
ret i32 0
}