#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_FromHex(unsigned char);
int CyBtldr_FromAscii(unsigned int bufSize, unsigned char *buffer,
                      unsigned short *rowSize, unsigned char *rowData) {
  unsigned short i;
  int err = 0x00;
  if (bufSize & 1)
    err = 0x03;
  else {
    for (i = 0; i < bufSize / 2; i++) {
      rowData[i] = (CyBtldr_FromHex(buffer[i * 2]) << 4) |
                   CyBtldr_FromHex(buffer[i * 2 + 1]);
    }
    *rowSize = i;
  }
  return err;
}


x86 assembly (clang, -O0):
<CyBtldr_FromAscii>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x4(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1149 <CyBtldr_FromAscii+0x39>
movl   $0x3,-0x28(%rbp)
jmp    11c8 <CyBtldr_FromAscii+0xb8>
movw   $0x0,-0x22(%rbp)
movzwl -0x22(%rbp),%eax
mov    -0x4(%rbp),%ecx
shr    $0x1,%ecx
cmp    %ecx,%eax
jae    11bd <CyBtldr_FromAscii+0xad>
mov    -0x10(%rbp),%rax
movzwl -0x22(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%edi
call   1030 <CyBtldr_FromHex@plt>
shl    $0x4,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
movzwl -0x22(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%edi
call   1030 <CyBtldr_FromHex@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
or     %ecx,%eax
mov    %al,%dl
mov    -0x20(%rbp),%rax
movzwl -0x22(%rbp),%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x22(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x22(%rbp)
jmp    114f <CyBtldr_FromAscii+0x3f>
mov    -0x22(%rbp),%cx
mov    -0x18(%rbp),%rax
mov    %cx,(%rax)
mov    -0x28(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CyBtldr_FromAscii>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    $0x3,%eax
mov    %edi,0xc(%rsp)
test   $0x1,%dil
jne    1193 <CyBtldr_FromAscii+0x83>
mov    %rdx,0x10(%rsp)
xor    %ebx,%ebx
mov    $0x0,%eax
cmpl   $0x2,0xc(%rsp)
jb     1189 <CyBtldr_FromAscii+0x79>
mov    %rcx,%r12
mov    %rsi,%r13
shrl   0xc(%rsp)
nopw   0x0(%rax,%rax,1)
mov    %ebx,%r14d
lea    (%r14,%r14,1),%r15
movzbl 0x0(%r13,%r14,2),%edi
call   1030 <CyBtldr_FromHex@plt>
mov    %eax,%ebp
shl    $0x4,%ebp
mov    %r15d,%eax
movzbl 0x1(%r13,%rax,1),%edi
call   1030 <CyBtldr_FromHex@plt>
or     %ebp,%eax
mov    %al,(%r12,%r14,1)
add    $0x1,%ebx
mov    %ebx,%eax
movzwl %bx,%ebx
cmp    %ebx,0xc(%rsp)
ja     1150 <CyBtldr_FromAscii+0x40>
mov    0x10(%rsp),%rcx
mov    %ax,(%rcx)
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @CyBtldr_FromAscii(i32 %0, i8* %1, i16* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i16*
%8 = alloca i8*
%9 = alloca i16
%10 = alloca i32
store i32 %0, i32* %5
store i8* %1, i8** %6
store i16* %2, i16** %7
store i8* %3, i8** %8
store i32 0, i32* %10
%11 = load i32, i32* %5
%12 = and i32 %11, 1
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %4
store i32 3, i32* %10
br label %53
15: ; preds = %4
store i16 0, i16* %9
br label %16
16: ; preds = %47, %15
%17 = load i16, i16* %9
%18 = zext i16 %17 to i32
%19 = load i32, i32* %5
%20 = udiv i32 %19, 2
%21 = icmp ult i32 %18, %20
br i1 %21, label %22, label %50
22: ; preds = %16
%23 = load i8*, i8** %6
%24 = load i16, i16* %9
%25 = zext i16 %24 to i32
%26 = mul nsw i32 %25, 2
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %23, i64 %27
%29 = load i8, i8* %28
%30 = call i32 @CyBtldr_FromHex(i8 zeroext %29)
%31 = shl i32 %30, 4
%32 = load i8*, i8** %6
%33 = load i16, i16* %9
%34 = zext i16 %33 to i32
%35 = mul nsw i32 %34, 2
%36 = add nsw i32 %35, 1
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %32, i64 %37
%39 = load i8, i8* %38
%40 = call i32 @CyBtldr_FromHex(i8 zeroext %39)
%41 = or i32 %31, %40
%42 = trunc i32 %41 to i8
%43 = load i8*, i8** %8
%44 = load i16, i16* %9
%45 = zext i16 %44 to i64
%46 = getelementptr inbounds i8, i8* %43, i64 %45
store i8 %42, i8* %46
br label %47
47: ; preds = %22
%48 = load i16, i16* %9
%49 = add i16 %48, 1
store i16 %49, i16* %9
br label %16
50: ; preds = %16
%51 = load i16, i16* %9
%52 = load i16*, i16** %7
store i16 %51, i16* %52
br label %53
53: ; preds = %50, %14
%54 = load i32, i32* %10
ret i32 %54
}

LLVM IR (-O2):
define i32 @CyBtldr_FromAscii(i32 %0, i8* nocapture %1, i16* nocapture writeonly %2, i8* nocapture writeonly %3) {
%5 = and i32 %0, 1
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %33
7: ; preds = %4
%8 = lshr i32 %0, 1
%9 = icmp ult i32 %0, 2
br i1 %9, label %31, label %10
10: ; preds = %7, %10
%11 = phi i32 [ %29, %10 ], [ 0, %7 ]
%12 = trunc i32 %11 to i16
%13 = shl nuw nsw i32 %11, 1
%14 = zext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %1, i64 %14
%16 = load i8, i8* %15
%17 = tail call i32 @CyBtldr_FromHex(i8 zeroext %16)
%18 = shl i32 %17, 4
%19 = or i32 %13, 1
%20 = zext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %1, i64 %20
%22 = load i8, i8* %21
%23 = tail call i32 @CyBtldr_FromHex(i8 zeroext %22)
%24 = or i32 %23, %18
%25 = trunc i32 %24 to i8
%26 = zext i32 %11 to i64
%27 = getelementptr inbounds i8, i8* %3, i64 %26
store i8 %25, i8* %27
%28 = add i16 %12, 1
%29 = zext i16 %28 to i32
%30 = icmp ugt i32 %8, %29
br i1 %30, label %10, label %31
31: ; preds = %10, %7
%32 = phi i16 [ 0, %7 ], [ %28, %10 ]
store i16 %32, i16* %2
br label %33
33: ; preds = %4, %31
%34 = phi i32 [ 0, %31 ], [ 3, %4 ]
ret i32 %34
}