#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 int /*<<< orphan*/ uint8_t;

/* Variables and functions */
int /*<<< orphan*/ EINVAL;
int b64_pton(char const *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
int /*<<< orphan*/ memcpy(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ stderr;
void unbase64(uint8_t dstkey[32], const char *srckey) {
  uint8_t buf[33];
  if (b64_pton(srckey, buf, 33) != 32) {
    fprintf(stderr, "Could not parse base64 key: %s\n", srckey);
    exit(EINVAL);
  }
  memcpy(dstkey, buf, 32);
}


x86 assembly (clang, -O0):
<unbase64>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
mov    $0x21,%edx
call   1030 <b64_pton@plt>
cmp    $0x20,%eax
je     1198 <unbase64+0x58>
mov    0x2e68(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe7b(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x8(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
mov    $0x20,%edx
call   1050 <memcpy@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unbase64>:
push   %r14
push   %rbx
sub    $0x88,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsp,%rsi
mov    %r14,%rdi
mov    $0x21,%edx
call   1030 <b64_pton@plt>
cmp    $0x20,%eax
jne    1180 <unbase64+0x40>
mov    %rsp,%rsi
mov    %rbx,%rdi
mov    $0x20,%edx
call   1050 <memcpy@plt>
add    $0x88,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
lea    0xe70(%rip),%rsi
mov    %r14,%rdx
call   1040 <fprintf@plt>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [32 x i8] c"Could not parse base64 key: %s\0A\00"
@EINVAL = global i32 0
define void @unbase64(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca [33 x i32]
store i32* %0, i32** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %4
%7 = getelementptr inbounds [33 x i32], [33 x i32]* %5, i64 0, i64 0
%8 = call i32 @b64_pton(i8* %6, i32* %7, i32 33)
%9 = icmp ne i32 %8, 32
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8*, i8** %4
%13 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = load i32, i32* @EINVAL
%15 = call i32 @exit(i32 %14)
unreachable
16: ; preds = %2
%17 = load i32*, i32** %3
%18 = getelementptr inbounds [33 x i32], [33 x i32]* %5, i64 0, i64 0
%19 = call i32 @memcpy(i32* %17, i32* %18, i32 32)
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [32 x i8] c"Could not parse base64 key: %s\0A\00"
@EINVAL = global i32 0
define void @unbase64(i32* %0, i8* %1) {
%3 = alloca [33 x i32]
%4 = bitcast [33 x i32]* %3 to i8*
%5 = getelementptr inbounds [33 x i32], [33 x i32]* %3, i64 0, i64 0
%6 = call i32 @b64_pton(i8* %1, i32* %5, i32 33)
%7 = icmp eq i32 %6, 32
br i1 %7, label %13, label %8
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %1)
%11 = load i32, i32* @EINVAL
%12 = call i32 @exit(i32 %11)
unreachable
13: ; preds = %2
%14 = call i32 @memcpy(i32* %0, i32* %5, i32 32)
ret void
}