#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 */
long strtol(char const *, int /*<<< orphan*/ *, int);
void hex_to_bytes(unsigned char *b, const unsigned char *s) {
  int i;
  unsigned char buf[3];
  buf[2] = '\0';
  for (i = 0; i < 32; ++i) {
    buf[0] = s[2 * i];
    buf[1] = s[2 * i + 1];
    long h = strtol((const char *)buf, NULL, 16);
    b[i] = (unsigned char)h;
  }
}


x86 assembly (clang, -O0):
<hex_to_bytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x0,-0x15(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x20,-0x14(%rbp)
jge    1193 <hex_to_bytes+0x83>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x17(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x16(%rbp)
lea    -0x17(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1030 <strtol@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %al,%dl
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    112b <hex_to_bytes+0x1b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hex_to_bytes>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %rdi,%r14
movb   $0x0,0x7(%rsp)
xor    %ebx,%ebx
lea    0x5(%rsp),%r15
nopw   0x0(%rax,%rax,1)
movzbl (%r12,%rbx,2),%eax
mov    %al,0x5(%rsp)
movzbl 0x1(%r12,%rbx,2),%eax
mov    %al,0x6(%rsp)
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1030 <strtol@plt>
mov    %al,(%r14,%rbx,1)
add    $0x1,%rbx
cmp    $0x20,%rbx
jne    1130 <hex_to_bytes+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @hex_to_bytes(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca [3 x i8]
%7 = alloca i64
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 2
store i8 0, i8* %8
store i32 0, i32* %5
br label %9
9: ; preds = %36, %2
%10 = load i32, i32* %5
%11 = icmp slt i32 %10, 32
br i1 %11, label %12, label %39
12: ; preds = %9
%13 = load i8*, i8** %4
%14 = load i32, i32* %5
%15 = mul nsw i32 2, %14
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %13, i64 %16
%18 = load i8, i8* %17
%19 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 0
store i8 %18, i8* %19
%20 = load i8*, i8** %4
%21 = load i32, i32* %5
%22 = mul nsw i32 2, %21
%23 = add nsw i32 %22, 1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %20, i64 %24
%26 = load i8, i8* %25
%27 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 1
store i8 %26, i8* %27
%28 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 0
%29 = call i64 @strtol(i8* %28, i32* null, i32 16)
store i64 %29, i64* %7
%30 = load i64, i64* %7
%31 = trunc i64 %30 to i8
%32 = load i8*, i8** %3
%33 = load i32, i32* %5
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
store i8 %31, i8* %35
br label %36
36: ; preds = %12
%37 = load i32, i32* %5
%38 = add nsw i32 %37, 1
store i32 %38, i32* %5
br label %9
39: ; preds = %9
ret void
}

LLVM IR (-O2):
define void @hex_to_bytes(i8* nocapture writeonly %0, i8* nocapture %1) {
%3 = alloca [3 x i8]
%4 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 2
store i8 0, i8* %5
%6 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 1
br label %7
7: ; preds = %2, %7
%8 = phi i64 [ 0, %2 ], [ %18, %7 ]
%9 = shl nuw nsw i64 %8, 1
%10 = getelementptr inbounds i8, i8* %1, i64 %9
%11 = load i8, i8* %10
store i8 %11, i8* %4
%12 = or i64 %9, 1
%13 = getelementptr inbounds i8, i8* %1, i64 %12
%14 = load i8, i8* %13
store i8 %14, i8* %6
%15 = call i64 @strtol(i8* nocapture %4, i32* null, i32 16)
%16 = trunc i64 %15 to i8
%17 = getelementptr inbounds i8, i8* %0, i64 %8
store i8 %16, i8* %17
%18 = add nuw nsw i64 %8, 1
%19 = icmp eq i64 %18, 32
br i1 %19, label %20, label %7
20: ; preds = %7
ret void
}