#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 scalar_t__ uint8_t;
typedef int uint32_t;

/* Variables and functions */
int b64_to_int(char const);
scalar_t__ split_24bit(char const *, scalar_t__ *, int, int, int, int, int);
int strlen(char const *);
int restore_md5_array(const char *string, uint8_t *hash) {
  uint32_t tmp = 0;
  int value1, value2;
  if (strlen(string) != 22)
    return -1;
  if (split_24bit(string, hash, 0, 4, 0, 6, 12) < 0)
    return -1;
  if (split_24bit(string, hash, 4, 4, 1, 7, 13) < 0)
    return -1;
  if (split_24bit(string, hash, 8, 4, 2, 8, 14) < 0)
    return -1;
  if (split_24bit(string, hash, 12, 4, 3, 9, 15) < 0)
    return -1;
  if (split_24bit(string, hash, 16, 4, 4, 10, 5) < 0)
    return -1;
  value1 = b64_to_int(string[21]);
  if (value1 < 0)
    return -1;
  value2 = b64_to_int(string[20]);
  if (value2 < 0)
    return -1;
  tmp = (value1 << 6) | value2;
  hash[11] = (uint8_t)tmp;
  return 0;
}


x86 assembly (clang, -O0):
<restore_md5_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x16,%eax
je     1165 <restore_md5_array+0x35>
movl   $0xffffffff,-0x4(%rbp)
jmp    1304 <restore_md5_array+0x1d4>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
xor    %r8d,%r8d
mov    $0x4,%ecx
mov    $0x6,%r9d
mov    %r8d,%edx
movl   $0xc,(%rsp)
call   1040 <split_24bit@plt>
cmp    $0x0,%rax
jge    11a0 <restore_md5_array+0x70>
movl   $0xffffffff,-0x4(%rbp)
jmp    1304 <restore_md5_array+0x1d4>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x4,%ecx
mov    $0x1,%r8d
mov    $0x7,%r9d
mov    %ecx,%edx
movl   $0xd,(%rsp)
call   1040 <split_24bit@plt>
cmp    $0x0,%rax
jge    11dd <restore_md5_array+0xad>
movl   $0xffffffff,-0x4(%rbp)
jmp    1304 <restore_md5_array+0x1d4>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x8,%r9d
mov    $0x4,%ecx
mov    $0x2,%r8d
mov    %r9d,%edx
movl   $0xe,(%rsp)
call   1040 <split_24bit@plt>
cmp    $0x0,%rax
jge    121b <restore_md5_array+0xeb>
movl   $0xffffffff,-0x4(%rbp)
jmp    1304 <restore_md5_array+0x1d4>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0xc,%edx
mov    $0x4,%ecx
mov    $0x3,%r8d
mov    $0x9,%r9d
movl   $0xf,(%rsp)
call   1040 <split_24bit@plt>
cmp    $0x0,%rax
jge    125b <restore_md5_array+0x12b>
movl   $0xffffffff,-0x4(%rbp)
jmp    1304 <restore_md5_array+0x1d4>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x10,%edx
mov    $0x4,%r8d
mov    $0xa,%r9d
mov    %r8d,%ecx
movl   $0x5,(%rsp)
call   1040 <split_24bit@plt>
cmp    $0x0,%rax
jge    1299 <restore_md5_array+0x169>
movl   $0xffffffff,-0x4(%rbp)
jmp    1304 <restore_md5_array+0x1d4>
mov    -0x10(%rbp),%rax
movsbl 0x15(%rax),%edi
call   1050 <b64_to_int@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jge    12bf <restore_md5_array+0x18f>
movl   $0xffffffff,-0x4(%rbp)
jmp    1304 <restore_md5_array+0x1d4>
mov    -0x10(%rbp),%rax
movsbl 0x14(%rax),%edi
call   1050 <b64_to_int@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    12e5 <restore_md5_array+0x1b5>
movl   $0xffffffff,-0x4(%rbp)
jmp    1304 <restore_md5_array+0x1d4>
mov    -0x20(%rbp),%eax
shl    $0x6,%eax
or     -0x24(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movslq -0x1c(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x58(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<restore_md5_array>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%rbp
call   1030 <strlen@plt>
mov    $0xffffffff,%r14d
cmp    $0x16,%eax
jne    1265 <restore_md5_array+0x135>
movl   $0xc,(%rsp)
mov    %rbp,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
mov    $0x4,%ecx
xor    %r8d,%r8d
mov    $0x6,%r9d
call   1040 <split_24bit@plt>
test   %rax,%rax
js     1265 <restore_md5_array+0x135>
movl   $0xd,(%rsp)
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    $0x4,%edx
mov    $0x4,%ecx
mov    $0x1,%r8d
mov    $0x7,%r9d
call   1040 <split_24bit@plt>
test   %rax,%rax
js     1265 <restore_md5_array+0x135>
movl   $0xe,(%rsp)
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    $0x8,%edx
mov    $0x4,%ecx
mov    $0x2,%r8d
mov    $0x8,%r9d
call   1040 <split_24bit@plt>
test   %rax,%rax
js     1265 <restore_md5_array+0x135>
movl   $0xf,(%rsp)
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    $0xc,%edx
mov    $0x4,%ecx
mov    $0x3,%r8d
mov    $0x9,%r9d
call   1040 <split_24bit@plt>
test   %rax,%rax
js     1265 <restore_md5_array+0x135>
movl   $0x5,(%rsp)
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    $0x10,%edx
mov    $0x4,%ecx
mov    $0x4,%r8d
mov    $0xa,%r9d
call   1040 <split_24bit@plt>
test   %rax,%rax
js     1265 <restore_md5_array+0x135>
movsbl 0x15(%rbp),%edi
call   1050 <b64_to_int@plt>
test   %eax,%eax
js     1265 <restore_md5_array+0x135>
mov    %eax,%r15d
movsbl 0x14(%rbp),%edi
call   1050 <b64_to_int@plt>
test   %eax,%eax
js     1265 <restore_md5_array+0x135>
shl    $0x6,%r15d
or     %r15d,%eax
cltq
mov    %rax,0x58(%rbx)
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @restore_md5_array(i8* %0, i64* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %4
store i64* %1, i64** %5
store i32 0, i32* %6
%9 = load i8*, i8** %4
%10 = call i32 @strlen(i8* %9)
%11 = icmp ne i32 %10, 22
br i1 %11, label %12, label %13
12: ; preds = %2
store i32 -1, i32* %3
br label %68
13: ; preds = %2
%14 = load i8*, i8** %4
%15 = load i64*, i64** %5
%16 = call i64 @split_24bit(i8* %14, i64* %15, i32 0, i32 4, i32 0, i32 6, i32 12)
%17 = icmp slt i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %13
store i32 -1, i32* %3
br label %68
19: ; preds = %13
%20 = load i8*, i8** %4
%21 = load i64*, i64** %5
%22 = call i64 @split_24bit(i8* %20, i64* %21, i32 4, i32 4, i32 1, i32 7, i32 13)
%23 = icmp slt i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %19
store i32 -1, i32* %3
br label %68
25: ; preds = %19
%26 = load i8*, i8** %4
%27 = load i64*, i64** %5
%28 = call i64 @split_24bit(i8* %26, i64* %27, i32 8, i32 4, i32 2, i32 8, i32 14)
%29 = icmp slt i64 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %25
store i32 -1, i32* %3
br label %68
31: ; preds = %25
%32 = load i8*, i8** %4
%33 = load i64*, i64** %5
%34 = call i64 @split_24bit(i8* %32, i64* %33, i32 12, i32 4, i32 3, i32 9, i32 15)
%35 = icmp slt i64 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %31
store i32 -1, i32* %3
br label %68
37: ; preds = %31
%38 = load i8*, i8** %4
%39 = load i64*, i64** %5
%40 = call i64 @split_24bit(i8* %38, i64* %39, i32 16, i32 4, i32 4, i32 10, i32 5)
%41 = icmp slt i64 %40, 0
br i1 %41, label %42, label %43
42: ; preds = %37
store i32 -1, i32* %3
br label %68
43: ; preds = %37
%44 = load i8*, i8** %4
%45 = getelementptr inbounds i8, i8* %44, i64 21
%46 = load i8, i8* %45
%47 = call i32 @b64_to_int(i8 signext %46)
store i32 %47, i32* %7
%48 = load i32, i32* %7
%49 = icmp slt i32 %48, 0
br i1 %49, label %50, label %51
50: ; preds = %43
store i32 -1, i32* %3
br label %68
51: ; preds = %43
%52 = load i8*, i8** %4
%53 = getelementptr inbounds i8, i8* %52, i64 20
%54 = load i8, i8* %53
%55 = call i32 @b64_to_int(i8 signext %54)
store i32 %55, i32* %8
%56 = load i32, i32* %8
%57 = icmp slt i32 %56, 0
br i1 %57, label %58, label %59
58: ; preds = %51
store i32 -1, i32* %3
br label %68
59: ; preds = %51
%60 = load i32, i32* %7
%61 = shl i32 %60, 6
%62 = load i32, i32* %8
%63 = or i32 %61, %62
store i32 %63, i32* %6
%64 = load i32, i32* %6
%65 = sext i32 %64 to i64
%66 = load i64*, i64** %5
%67 = getelementptr inbounds i64, i64* %66, i64 11
store i64 %65, i64* %67
store i32 0, i32* %3
br label %68
68: ; preds = %59, %58, %50, %42, %36, %30, %24, %18, %12
%69 = load i32, i32* %3
ret i32 %69
}

LLVM IR (-O2):
define i32 @restore_md5_array(i8* %0, i64* %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = icmp eq i32 %3, 22
br i1 %4, label %5, label %35
5: ; preds = %2
%6 = tail call i64 @split_24bit(i8* %0, i64* %1, i32 0, i32 4, i32 0, i32 6, i32 12)
%7 = icmp slt i64 %6, 0
br i1 %7, label %35, label %8
8: ; preds = %5
%9 = tail call i64 @split_24bit(i8* %0, i64* %1, i32 4, i32 4, i32 1, i32 7, i32 13)
%10 = icmp slt i64 %9, 0
br i1 %10, label %35, label %11
11: ; preds = %8
%12 = tail call i64 @split_24bit(i8* %0, i64* %1, i32 8, i32 4, i32 2, i32 8, i32 14)
%13 = icmp slt i64 %12, 0
br i1 %13, label %35, label %14
14: ; preds = %11
%15 = tail call i64 @split_24bit(i8* %0, i64* %1, i32 12, i32 4, i32 3, i32 9, i32 15)
%16 = icmp slt i64 %15, 0
br i1 %16, label %35, label %17
17: ; preds = %14
%18 = tail call i64 @split_24bit(i8* %0, i64* %1, i32 16, i32 4, i32 4, i32 10, i32 5)
%19 = icmp slt i64 %18, 0
br i1 %19, label %35, label %20
20: ; preds = %17
%21 = getelementptr inbounds i8, i8* %0, i64 21
%22 = load i8, i8* %21
%23 = tail call i32 @b64_to_int(i8 signext %22)
%24 = icmp slt i32 %23, 0
br i1 %24, label %35, label %25
25: ; preds = %20
%26 = getelementptr inbounds i8, i8* %0, i64 20
%27 = load i8, i8* %26
%28 = tail call i32 @b64_to_int(i8 signext %27)
%29 = icmp slt i32 %28, 0
br i1 %29, label %35, label %30
30: ; preds = %25
%31 = shl i32 %23, 6
%32 = or i32 %28, %31
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i64, i64* %1, i64 11
store i64 %33, i64* %34
br label %35
35: ; preds = %25, %20, %17, %14, %11, %8, %5, %2, %30
%36 = phi i32 [ 0, %30 ], [ -1, %2 ], [ -1, %5 ], [ -1, %8 ], [ -1, %11 ], [ -1, %14 ], [ -1, %17 ], [ -1, %20 ], [ -1, %25 ]
ret i32 %36
}