#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 */
char *strchr(char *, char const);
void sfpr_md5_sig_from_string(void *signature, const char *str) {
  unsigned char *sig_p;
  const char *str_p;
  char *hex;
  unsigned int high, low, val;
  hex = "0123456789abcdef";
  sig_p = signature;
  for (str_p = str; str_p < str + 16 * 2; str_p += 2) {
    high = strchr(hex, *str_p) - hex;
    low = strchr(hex, *(str_p + 1)) - hex;
    val = high * 16 + low;
    *sig_p++ = val;
  }
}


x86 assembly (clang, -O0):
<sfpr_md5_sig_from_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xed9(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
add    $0x20,%rcx
cmp    %rcx,%rax
jae    11b8 <sfpr_md5_sig_from_string+0xa8>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rax
movsbl (%rax),%esi
call   1030 <strchr@plt>
mov    -0x28(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rax
movsbl 0x1(%rax),%esi
call   1030 <strchr@plt>
mov    -0x28(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x30(%rbp)
mov    -0x2c(%rbp),%eax
shl    $0x4,%eax
add    -0x30(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    -0x20(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x20(%rbp)
jmp    113b <sfpr_md5_sig_from_string+0x2b>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sfpr_md5_sig_from_string>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r12
mov    $0xfffffffffffffffe,%r13
lea    0xed3(%rip),%r15
nopl   (%rax)
movsbl 0x2(%r14,%r13,1),%esi
mov    %r15,%rdi
call   1030 <strchr@plt>
mov    %rax,%rbx
sub    %r15b,%bl
movsbl 0x3(%r14,%r13,1),%esi
mov    %r15,%rdi
call   1030 <strchr@plt>
sub    %r15b,%al
shl    $0x4,%bl
add    %al,%bl
mov    %bl,(%r12)
add    $0x1,%r12
add    $0x2,%r13
cmp    $0x1e,%r13
jb     1130 <sfpr_md5_sig_from_string+0x20>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [17 x i8] c"0123456789abcdef\00"
define void @sfpr_md5_sig_from_string(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8** %7
%11 = load i8*, i8** %3
store i8* %11, i8** %5
%12 = load i8*, i8** %4
store i8* %12, i8** %6
br label %13
13: ; preds = %46, %2
%14 = load i8*, i8** %6
%15 = load i8*, i8** %4
%16 = getelementptr inbounds i8, i8* %15, i64 32
%17 = icmp ult i8* %14, %16
br i1 %17, label %18, label %49
18: ; preds = %13
%19 = load i8*, i8** %7
%20 = load i8*, i8** %6
%21 = load i8, i8* %20
%22 = call i8* @strchr(i8* %19, i8 signext %21)
%23 = load i8*, i8** %7
%24 = ptrtoint i8* %22 to i64
%25 = ptrtoint i8* %23 to i64
%26 = sub i64 %24, %25
%27 = trunc i64 %26 to i32
store i32 %27, i32* %8
%28 = load i8*, i8** %7
%29 = load i8*, i8** %6
%30 = getelementptr inbounds i8, i8* %29, i64 1
%31 = load i8, i8* %30
%32 = call i8* @strchr(i8* %28, i8 signext %31)
%33 = load i8*, i8** %7
%34 = ptrtoint i8* %32 to i64
%35 = ptrtoint i8* %33 to i64
%36 = sub i64 %34, %35
%37 = trunc i64 %36 to i32
store i32 %37, i32* %9
%38 = load i32, i32* %8
%39 = mul i32 %38, 16
%40 = load i32, i32* %9
%41 = add i32 %39, %40
store i32 %41, i32* %10
%42 = load i32, i32* %10
%43 = trunc i32 %42 to i8
%44 = load i8*, i8** %5
%45 = getelementptr inbounds i8, i8* %44, i32 1
store i8* %45, i8** %5
store i8 %43, i8* %44
br label %46
46: ; preds = %18
%47 = load i8*, i8** %6
%48 = getelementptr inbounds i8, i8* %47, i64 2
store i8* %48, i8** %6
br label %13
49: ; preds = %13
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"0123456789abcdef\00"
define void @sfpr_md5_sig_from_string(i8* nocapture writeonly %0, i8* nocapture %1) {
br label %3
3: ; preds = %2, %3
%4 = phi i8* [ %1, %2 ], [ %22, %3 ]
%5 = phi i8* [ %0, %2 ], [ %20, %3 ]
%6 = phi i64 [ 0, %2 ], [ %21, %3 ]
%7 = load i8, i8* %4
%8 = tail call i8* @strchr(i8* dereferenceable(17) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8 signext %7)
%9 = ptrtoint i8* %8 to i64
%10 = trunc i64 %9 to i8
%11 = sub i8 %10, ptrtoint ([17 x i8]* @.str to i8)
%12 = getelementptr inbounds i8, i8* %4, i64 1
%13 = load i8, i8* %12
%14 = tail call i8* @strchr(i8* dereferenceable(17) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8 signext %13)
%15 = ptrtoint i8* %14 to i64
%16 = trunc i64 %15 to i8
%17 = sub i8 %16, ptrtoint ([17 x i8]* @.str to i8)
%18 = shl i8 %11, 4
%19 = add i8 %17, %18
%20 = getelementptr inbounds i8, i8* %5, i64 1
store i8 %19, i8* %5
%21 = add nuw nsw i64 %6, 2
%22 = getelementptr inbounds i8, i8* %1, i64 %21
%23 = icmp ult i64 %6, 30
br i1 %23, label %3, label %24
24: ; preds = %3
ret void
}