#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_sha256_array(const char *string, uint8_t *hash) {
  uint32_t tmp = 0;
  int i, value;
  if (strlen(string) != 43)
    return -1;
  if (split_24bit(string, hash, 0, 4, 0, 10, 20) < 0)
    return -1;
  if (split_24bit(string, hash, 4, 4, 21, 1, 11) < 0)
    return -1;
  if (split_24bit(string, hash, 8, 4, 12, 22, 2) < 0)
    return -1;
  if (split_24bit(string, hash, 12, 4, 3, 13, 23) < 0)
    return -1;
  if (split_24bit(string, hash, 16, 4, 24, 4, 14) < 0)
    return -1;
  if (split_24bit(string, hash, 20, 4, 15, 25, 5) < 0)
    return -1;
  if (split_24bit(string, hash, 24, 4, 6, 16, 26) < 0)
    return -1;
  if (split_24bit(string, hash, 28, 4, 27, 7, 17) < 0)
    return -1;
  if (split_24bit(string, hash, 32, 4, 18, 28, 8) < 0)
    return -1;
  if (split_24bit(string, hash, 36, 4, 9, 19, 29) < 0)
    return -1;
  for (i = 40; i < 43; i++) {
    value = b64_to_int(string[i]);
    if (value < 0)
      return -1;
    tmp |= value << (6 * (i - 40));
  }
  hash[30] = (uint8_t)(tmp & 0xff);
  hash[31] = (uint8_t)((tmp >> 8) & 0xff);
  return 0;
}


x86 assembly (clang, -O0):
<restore_sha256_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    $0x2b,%eax
je     1165 <restore_sha256_array+0x35>
movl   $0xffffffff,-0x4(%rbp)
jmp    146e <restore_sha256_array+0x33e>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
xor    %r8d,%r8d
mov    $0x4,%ecx
mov    $0xa,%r9d
mov    %r8d,%edx
movl   $0x14,(%rsp)
call   1040 <split_24bit@plt>
cmp    $0x0,%rax
jge    11a0 <restore_sha256_array+0x70>
movl   $0xffffffff,-0x4(%rbp)
jmp    146e <restore_sha256_array+0x33e>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x4,%ecx
mov    $0x15,%r8d
mov    $0x1,%r9d
mov    %ecx,%edx
movl   $0xb,(%rsp)
call   1040 <split_24bit@plt>
cmp    $0x0,%rax
jge    11dd <restore_sha256_array+0xad>
movl   $0xffffffff,-0x4(%rbp)
jmp    146e <restore_sha256_array+0x33e>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x8,%edx
mov    $0x4,%ecx
mov    $0xc,%r8d
mov    $0x16,%r9d
movl   $0x2,(%rsp)
call   1040 <split_24bit@plt>
cmp    $0x0,%rax
jge    121d <restore_sha256_array+0xed>
movl   $0xffffffff,-0x4(%rbp)
jmp    146e <restore_sha256_array+0x33e>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0xc,%edx
mov    $0x4,%ecx
mov    $0x3,%r8d
mov    $0xd,%r9d
movl   $0x17,(%rsp)
call   1040 <split_24bit@plt>
cmp    $0x0,%rax
jge    125d <restore_sha256_array+0x12d>
movl   $0xffffffff,-0x4(%rbp)
jmp    146e <restore_sha256_array+0x33e>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x10,%edx
mov    $0x4,%r9d
mov    $0x18,%r8d
mov    %r9d,%ecx
movl   $0xe,(%rsp)
call   1040 <split_24bit@plt>
cmp    $0x0,%rax
jge    129b <restore_sha256_array+0x16b>
movl   $0xffffffff,-0x4(%rbp)
jmp    146e <restore_sha256_array+0x33e>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x14,%edx
mov    $0x4,%ecx
mov    $0xf,%r8d
mov    $0x19,%r9d
movl   $0x5,(%rsp)
call   1040 <split_24bit@plt>
cmp    $0x0,%rax
jge    12db <restore_sha256_array+0x1ab>
movl   $0xffffffff,-0x4(%rbp)
jmp    146e <restore_sha256_array+0x33e>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x18,%edx
mov    $0x4,%ecx
mov    $0x6,%r8d
mov    $0x10,%r9d
movl   $0x1a,(%rsp)
call   1040 <split_24bit@plt>
cmp    $0x0,%rax
jge    131b <restore_sha256_array+0x1eb>
movl   $0xffffffff,-0x4(%rbp)
jmp    146e <restore_sha256_array+0x33e>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x1c,%edx
mov    $0x4,%ecx
mov    $0x1b,%r8d
mov    $0x7,%r9d
movl   $0x11,(%rsp)
call   1040 <split_24bit@plt>
cmp    $0x0,%rax
jge    135b <restore_sha256_array+0x22b>
movl   $0xffffffff,-0x4(%rbp)
jmp    146e <restore_sha256_array+0x33e>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x20,%edx
mov    $0x4,%ecx
mov    $0x12,%r8d
mov    $0x1c,%r9d
movl   $0x8,(%rsp)
call   1040 <split_24bit@plt>
cmp    $0x0,%rax
jge    139b <restore_sha256_array+0x26b>
movl   $0xffffffff,-0x4(%rbp)
jmp    146e <restore_sha256_array+0x33e>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x24,%edx
mov    $0x4,%ecx
mov    $0x9,%r8d
mov    $0x13,%r9d
movl   $0x1d,(%rsp)
call   1040 <split_24bit@plt>
cmp    $0x0,%rax
jge    13db <restore_sha256_array+0x2ab>
movl   $0xffffffff,-0x4(%rbp)
jmp    146e <restore_sha256_array+0x33e>
movl   $0x28,-0x20(%rbp)
cmpl   $0x2b,-0x20(%rbp)
jge    1438 <restore_sha256_array+0x308>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1050 <b64_to_int@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    1416 <restore_sha256_array+0x2e6>
movl   $0xffffffff,-0x4(%rbp)
jmp    146e <restore_sha256_array+0x33e>
mov    -0x24(%rbp),%eax
mov    -0x20(%rbp),%ecx
sub    $0x28,%ecx
imul   $0x6,%ecx,%ecx
shl    %cl,%eax
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    13e2 <restore_sha256_array+0x2b2>
mov    -0x1c(%rbp),%eax
and    $0xff,%eax
movslq %eax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0xf0(%rax)
mov    -0x1c(%rbp),%eax
sar    $0x8,%eax
and    $0xff,%eax
movslq %eax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0xf8(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<restore_sha256_array>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %rdi,%rbp
call   1030 <strlen@plt>
mov    $0xffffffff,%r14d
cmp    $0x2b,%eax
jne    1384 <restore_sha256_array+0x254>
movl   $0x14,(%rsp)
mov    %rbp,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
mov    $0x4,%ecx
xor    %r8d,%r8d
mov    $0xa,%r9d
call   1040 <split_24bit@plt>
test   %rax,%rax
js     1384 <restore_sha256_array+0x254>
movl   $0xb,(%rsp)
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    $0x4,%edx
mov    $0x4,%ecx
mov    $0x15,%r8d
mov    $0x1,%r9d
call   1040 <split_24bit@plt>
test   %rax,%rax
js     1384 <restore_sha256_array+0x254>
movl   $0x2,(%rsp)
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    $0x8,%edx
mov    $0x4,%ecx
mov    $0xc,%r8d
mov    $0x16,%r9d
call   1040 <split_24bit@plt>
test   %rax,%rax
js     1384 <restore_sha256_array+0x254>
movl   $0x17,(%rsp)
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    $0xc,%edx
mov    $0x4,%ecx
mov    $0x3,%r8d
mov    $0xd,%r9d
call   1040 <split_24bit@plt>
test   %rax,%rax
js     1384 <restore_sha256_array+0x254>
movl   $0xe,(%rsp)
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    $0x10,%edx
mov    $0x4,%ecx
mov    $0x18,%r8d
mov    $0x4,%r9d
call   1040 <split_24bit@plt>
test   %rax,%rax
js     1384 <restore_sha256_array+0x254>
movl   $0x5,(%rsp)
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    $0x14,%edx
mov    $0x4,%ecx
mov    $0xf,%r8d
mov    $0x19,%r9d
call   1040 <split_24bit@plt>
test   %rax,%rax
js     1384 <restore_sha256_array+0x254>
movl   $0x1a,(%rsp)
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    $0x18,%edx
mov    $0x4,%ecx
mov    $0x6,%r8d
mov    $0x10,%r9d
call   1040 <split_24bit@plt>
test   %rax,%rax
js     1384 <restore_sha256_array+0x254>
movl   $0x11,(%rsp)
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    $0x1c,%edx
mov    $0x4,%ecx
mov    $0x1b,%r8d
mov    $0x7,%r9d
call   1040 <split_24bit@plt>
test   %rax,%rax
js     1384 <restore_sha256_array+0x254>
movl   $0x8,(%rsp)
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    $0x20,%edx
mov    $0x4,%ecx
mov    $0x12,%r8d
mov    $0x1c,%r9d
call   1040 <split_24bit@plt>
test   %rax,%rax
js     1384 <restore_sha256_array+0x254>
movl   $0x1d,(%rsp)
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    $0x24,%edx
mov    $0x4,%ecx
mov    $0x9,%r8d
mov    $0x13,%r9d
call   1040 <split_24bit@plt>
test   %rax,%rax
js     1384 <restore_sha256_array+0x254>
movsbl 0x28(%rbp),%edi
call   1050 <b64_to_int@plt>
test   %eax,%eax
js     1384 <restore_sha256_array+0x254>
mov    %eax,%r15d
movsbl 0x29(%rbp),%edi
call   1050 <b64_to_int@plt>
test   %eax,%eax
js     1384 <restore_sha256_array+0x254>
mov    %eax,%r12d
movsbl 0x2a(%rbp),%edi
call   1050 <b64_to_int@plt>
test   %eax,%eax
js     1384 <restore_sha256_array+0x254>
shl    $0x6,%r12d
or     %r15d,%r12d
shl    $0xc,%eax
or     %r12d,%eax
movzbl %r12b,%ecx
mov    %rcx,0xf0(%rbx)
movzbl %ah,%eax
mov    %rax,0xf8(%rbx)
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @restore_sha256_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, 43
br i1 %11, label %12, label %13
12: ; preds = %2
store i32 -1, i32* %3
br label %110
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 10, i32 20)
%17 = icmp slt i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %13
store i32 -1, i32* %3
br label %110
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 21, i32 1, i32 11)
%23 = icmp slt i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %19
store i32 -1, i32* %3
br label %110
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 12, i32 22, i32 2)
%29 = icmp slt i64 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %25
store i32 -1, i32* %3
br label %110
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 13, i32 23)
%35 = icmp slt i64 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %31
store i32 -1, i32* %3
br label %110
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 24, i32 4, i32 14)
%41 = icmp slt i64 %40, 0
br i1 %41, label %42, label %43
42: ; preds = %37
store i32 -1, i32* %3
br label %110
43: ; preds = %37
%44 = load i8*, i8** %4
%45 = load i64*, i64** %5
%46 = call i64 @split_24bit(i8* %44, i64* %45, i32 20, i32 4, i32 15, i32 25, i32 5)
%47 = icmp slt i64 %46, 0
br i1 %47, label %48, label %49
48: ; preds = %43
store i32 -1, i32* %3
br label %110
49: ; preds = %43
%50 = load i8*, i8** %4
%51 = load i64*, i64** %5
%52 = call i64 @split_24bit(i8* %50, i64* %51, i32 24, i32 4, i32 6, i32 16, i32 26)
%53 = icmp slt i64 %52, 0
br i1 %53, label %54, label %55
54: ; preds = %49
store i32 -1, i32* %3
br label %110
55: ; preds = %49
%56 = load i8*, i8** %4
%57 = load i64*, i64** %5
%58 = call i64 @split_24bit(i8* %56, i64* %57, i32 28, i32 4, i32 27, i32 7, i32 17)
%59 = icmp slt i64 %58, 0
br i1 %59, label %60, label %61
60: ; preds = %55
store i32 -1, i32* %3
br label %110
61: ; preds = %55
%62 = load i8*, i8** %4
%63 = load i64*, i64** %5
%64 = call i64 @split_24bit(i8* %62, i64* %63, i32 32, i32 4, i32 18, i32 28, i32 8)
%65 = icmp slt i64 %64, 0
br i1 %65, label %66, label %67
66: ; preds = %61
store i32 -1, i32* %3
br label %110
67: ; preds = %61
%68 = load i8*, i8** %4
%69 = load i64*, i64** %5
%70 = call i64 @split_24bit(i8* %68, i64* %69, i32 36, i32 4, i32 9, i32 19, i32 29)
%71 = icmp slt i64 %70, 0
br i1 %71, label %72, label %73
72: ; preds = %67
store i32 -1, i32* %3
br label %110
73: ; preds = %67
store i32 40, i32* %7
br label %74
74: ; preds = %95, %73
%75 = load i32, i32* %7
%76 = icmp slt i32 %75, 43
br i1 %76, label %77, label %98
77: ; preds = %74
%78 = load i8*, i8** %4
%79 = load i32, i32* %7
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds i8, i8* %78, i64 %80
%82 = load i8, i8* %81
%83 = call i32 @b64_to_int(i8 signext %82)
store i32 %83, i32* %8
%84 = load i32, i32* %8
%85 = icmp slt i32 %84, 0
br i1 %85, label %86, label %87
86: ; preds = %77
store i32 -1, i32* %3
br label %110
87: ; preds = %77
%88 = load i32, i32* %8
%89 = load i32, i32* %7
%90 = sub nsw i32 %89, 40
%91 = mul nsw i32 6, %90
%92 = shl i32 %88, %91
%93 = load i32, i32* %6
%94 = or i32 %93, %92
store i32 %94, i32* %6
br label %95
95: ; preds = %87
%96 = load i32, i32* %7
%97 = add nsw i32 %96, 1
store i32 %97, i32* %7
br label %74
98: ; preds = %74
%99 = load i32, i32* %6
%100 = and i32 %99, 255
%101 = sext i32 %100 to i64
%102 = load i64*, i64** %5
%103 = getelementptr inbounds i64, i64* %102, i64 30
store i64 %101, i64* %103
%104 = load i32, i32* %6
%105 = ashr i32 %104, 8
%106 = and i32 %105, 255
%107 = sext i32 %106 to i64
%108 = load i64*, i64** %5
%109 = getelementptr inbounds i64, i64* %108, i64 31
store i64 %107, i64* %109
store i32 0, i32* %3
br label %110
110: ; preds = %98, %86, %72, %66, %60, %54, %48, %42, %36, %30, %24, %18, %12
%111 = load i32, i32* %3
ret i32 %111
}

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