#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 xnum(char const);
void md5str_to_md5sum(const char *str, unsigned char *sum) {
  int i = 0;
  int j = 0;
  int ch = 0;
  for (i = 0; i < 32; i++) {
    if (!(i % 2)) {
      ch = xnum(str[i]);
      continue;
    }
    ch <<= 4;
    ch += xnum(str[i]);
    sum[j] = ch;
    j++;
  }
}


x86 assembly (clang, -O0):
<md5str_to_md5sum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x20,-0x14(%rbp)
jge    11ba <md5str_to_md5sum+0xaa>
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1173 <md5str_to_md5sum+0x63>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <xnum@plt>
mov    %eax,-0x1c(%rbp)
jmp    11ac <md5str_to_md5sum+0x9c>
mov    -0x1c(%rbp),%eax
shl    $0x4,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <xnum@plt>
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113c <md5str_to_md5sum+0x2c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<md5str_to_md5sum>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebx,%ebx
xor    %ebp,%ebp
xor    %r12d,%r12d
jmp    1154 <md5str_to_md5sum+0x44>
nopw   0x0(%rax,%rax,1)
shl    $0x4,%ebp
movsbl (%r15,%rbx,1),%edi
call   1030 <xnum@plt>
add    %eax,%ebp
movslq %r12d,%r12
mov    %bpl,(%r14,%r12,1)
add    $0x1,%r12d
add    $0x1,%rbx
cmp    $0x20,%rbx
je     1167 <md5str_to_md5sum+0x57>
test   $0x1,%bl
jne    1130 <md5str_to_md5sum+0x20>
movsbl (%r15,%rbx,1),%edi
call   1030 <xnum@plt>
mov    %eax,%ebp
jmp    114a <md5str_to_md5sum+0x3a>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @md5str_to_md5sum(i8* nocapture %0, i8* nocapture writeonly %1) {
br label %3
3: ; preds = %2, %23
%4 = phi i64 [ 0, %2 ], [ %26, %23 ]
%5 = phi i32 [ 0, %2 ], [ %25, %23 ]
%6 = phi i32 [ 0, %2 ], [ %24, %23 ]
%7 = and i64 %4, 1
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %3
%10 = getelementptr inbounds i8, i8* %0, i64 %4
%11 = load i8, i8* %10
%12 = tail call i32 @xnum(i8 signext %11)
br label %23
13: ; preds = %3
%14 = shl i32 %5, 4
%15 = getelementptr inbounds i8, i8* %0, i64 %4
%16 = load i8, i8* %15
%17 = tail call i32 @xnum(i8 signext %16)
%18 = add nsw i32 %17, %14
%19 = trunc i32 %18 to i8
%20 = sext i32 %6 to i64
%21 = getelementptr inbounds i8, i8* %1, i64 %20
store i8 %19, i8* %21
%22 = add nsw i32 %6, 1
br label %23
23: ; preds = %13, %9
%24 = phi i32 [ %22, %13 ], [ %6, %9 ]
%25 = phi i32 [ %18, %13 ], [ %12, %9 ]
%26 = add nuw nsw i64 %4, 1
%27 = icmp eq i64 %26, 32
br i1 %27, label %28, label %3
28: ; preds = %23
ret void
}