#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 */
typedef int /*<<< orphan*/ uint8_t;

/* Variables and functions */
scalar_t__ parse_uint8_hex(char const *, int /*<<< orphan*/ *);
int parse_byte_list(const char **str_bytes, unsigned int n_bytes,
                    uint8_t *result) {
  int rc = -1;
  int i = 0;
  while (i < n_bytes) {
    if (parse_uint8_hex(str_bytes[i], result + i)) {
      goto cleanup;
    }
    i++;
  }
  rc = 0;
cleanup:
  return rc;
}


x86 assembly (clang, -O0):
<parse_byte_list>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0xffffffff,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    117a <parse_byte_list+0x6a>
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rsi
movslq -0x20(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
call   1030 <parse_uint8_hex@plt>
cmp    $0x0,%rax
je     116c <parse_byte_list+0x5c>
jmp    1181 <parse_byte_list+0x71>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1131 <parse_byte_list+0x21>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_byte_list>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
je     114b <parse_byte_list+0x3b>
mov    %rdx,%r14
mov    %rdi,%r15
mov    %esi,%r12d
shl    $0x2,%r12
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    (%r15,%rbx,2),%rdi
lea    (%r14,%rbx,1),%rsi
call   1030 <parse_uint8_hex@plt>
test   %rax,%rax
jne    114f <parse_byte_list+0x3f>
add    $0x4,%rbx
cmp    %rbx,%r12
jne    1130 <parse_byte_list+0x20>
xor    %eax,%eax
jmp    1154 <parse_byte_list+0x44>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @parse_byte_list(i8** %0, i32 %1, i32* %2) {
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
store i8** %0, i8*** %4
store i32 %1, i32* %5
store i32* %2, i32** %6
store i32 -1, i32* %7
store i32 0, i32* %8
br label %9
9: ; preds = %26, %3
%10 = load i32, i32* %8
%11 = load i32, i32* %5
%12 = icmp ult i32 %10, %11
br i1 %12, label %13, label %29
13: ; preds = %9
%14 = load i8**, i8*** %4
%15 = load i32, i32* %8
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8*, i8** %14, i64 %16
%18 = load i8*, i8** %17
%19 = load i32*, i32** %6
%20 = load i32, i32* %8
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %19, i64 %21
%23 = call i64 @parse_uint8_hex(i8* %18, i32* %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %13
br label %30
26: ; preds = %13
%27 = load i32, i32* %8
%28 = add nsw i32 %27, 1
store i32 %28, i32* %8
br label %9
29: ; preds = %9
store i32 0, i32* %7
br label %30
30: ; preds = %29, %25
%31 = load i32, i32* %7
ret i32 %31
}

LLVM IR (-O2):
define i32 @parse_byte_list(i8** nocapture %0, i32 %1, i32* %2) {
%4 = icmp eq i32 %1, 0
br i1 %4, label %17, label %5
5: ; preds = %3
%6 = zext i32 %1 to i64
br label %9
7: ; preds = %9
%8 = icmp eq i64 %16, %6
br i1 %8, label %17, label %9
9: ; preds = %5, %7
%10 = phi i64 [ 0, %5 ], [ %16, %7 ]
%11 = getelementptr inbounds i8*, i8** %0, i64 %10
%12 = load i8*, i8** %11
%13 = getelementptr inbounds i32, i32* %2, i64 %10
%14 = tail call i64 @parse_uint8_hex(i8* %12, i32* %13)
%15 = icmp eq i64 %14, 0
%16 = add nuw nsw i64 %10, 1
br i1 %15, label %7, label %17
17: ; preds = %9, %7, %3
%18 = phi i32 [ 0, %3 ], [ 0, %7 ], [ -1, %9 ]
ret i32 %18
}