#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 asciiToHex(char const);
char binToBase64(char);
int /*<<< orphan*/ strncat(char *, char *, int);
void threeHexTo2Base64(char *dest, const char *src) {
  char val = 0;
  char tmp;
  val = (asciiToHex(*(src)) & 0x0f) | ((asciiToHex(*(src + 1)) & 0x03) << 4);
  tmp = binToBase64(val);
  strncat(dest, &tmp, 1);
  val = ((asciiToHex(*(src + 2)) & 0x0f) << 2) |
        ((asciiToHex(*(src + 1)) & 0x0c) >> 2);
  tmp = binToBase64(val);
  strncat(dest, &tmp, 1);
}


x86 assembly (clang, -O0):
<threeHexTo2Base64>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x0,-0x11(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1050 <asciiToHex@plt>
and    $0xf,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%edi
call   1050 <asciiToHex@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
and    $0x3,%ecx
shl    $0x4,%ecx
or     %ecx,%eax
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%edi
call   1040 <binToBase64@plt>
mov    %al,-0x12(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x12(%rbp),%rsi
mov    $0x1,%edx
call   1030 <strncat@plt>
mov    -0x10(%rbp),%rax
movsbl 0x2(%rax),%edi
call   1050 <asciiToHex@plt>
and    $0xf,%eax
shl    $0x2,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%edi
call   1050 <asciiToHex@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
and    $0xc,%ecx
sar    $0x2,%ecx
or     %ecx,%eax
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%edi
call   1040 <binToBase64@plt>
mov    %al,-0x12(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x12(%rbp),%rsi
mov    $0x1,%edx
call   1030 <strncat@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<threeHexTo2Base64>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
movsbl (%rsi),%edi
call   1050 <asciiToHex@plt>
mov    %eax,%ebp
and    $0xf,%ebp
movsbl 0x1(%rbx),%edi
call   1050 <asciiToHex@plt>
shl    $0x4,%eax
and    $0x30,%eax
or     %eax,%ebp
mov    %ebp,%edi
call   1040 <binToBase64@plt>
mov    %al,0x7(%rsp)
lea    0x7(%rsp),%r15
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x1,%edx
call   1030 <strncat@plt>
movsbl 0x2(%rbx),%edi
call   1050 <asciiToHex@plt>
mov    %eax,%ebp
and    $0xf,%ebp
movsbl 0x1(%rbx),%edi
call   1050 <asciiToHex@plt>
shr    $0x2,%eax
and    $0x3,%eax
lea    (%rax,%rbp,4),%edi
call   1040 <binToBase64@plt>
mov    %al,0x7(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x1,%edx
call   1030 <strncat@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @threeHexTo2Base64(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8
%6 = alloca i8
store i8* %0, i8** %3
store i8* %1, i8** %4
store i8 0, i8* %5
%7 = load i8*, i8** %4
%8 = load i8, i8* %7
%9 = call i32 @asciiToHex(i8 signext %8)
%10 = and i32 %9, 15
%11 = load i8*, i8** %4
%12 = getelementptr inbounds i8, i8* %11, i64 1
%13 = load i8, i8* %12
%14 = call i32 @asciiToHex(i8 signext %13)
%15 = and i32 %14, 3
%16 = shl i32 %15, 4
%17 = or i32 %10, %16
%18 = trunc i32 %17 to i8
store i8 %18, i8* %5
%19 = load i8, i8* %5
%20 = call signext i8 @binToBase64(i8 signext %19)
store i8 %20, i8* %6
%21 = load i8*, i8** %3
%22 = call i32 @strncat(i8* %21, i8* %6, i32 1)
%23 = load i8*, i8** %4
%24 = getelementptr inbounds i8, i8* %23, i64 2
%25 = load i8, i8* %24
%26 = call i32 @asciiToHex(i8 signext %25)
%27 = and i32 %26, 15
%28 = shl i32 %27, 2
%29 = load i8*, i8** %4
%30 = getelementptr inbounds i8, i8* %29, i64 1
%31 = load i8, i8* %30
%32 = call i32 @asciiToHex(i8 signext %31)
%33 = and i32 %32, 12
%34 = ashr i32 %33, 2
%35 = or i32 %28, %34
%36 = trunc i32 %35 to i8
store i8 %36, i8* %5
%37 = load i8, i8* %5
%38 = call signext i8 @binToBase64(i8 signext %37)
store i8 %38, i8* %6
%39 = load i8*, i8** %3
%40 = call i32 @strncat(i8* %39, i8* %6, i32 1)
ret void
}

LLVM IR (-O2):
define void @threeHexTo2Base64(i8* %0, i8* nocapture %1) {
%3 = alloca i8
%4 = load i8, i8* %1
%5 = tail call i32 @asciiToHex(i8 signext %4)
%6 = and i32 %5, 15
%7 = getelementptr inbounds i8, i8* %1, i64 1
%8 = load i8, i8* %7
%9 = tail call i32 @asciiToHex(i8 signext %8)
%10 = shl i32 %9, 4
%11 = and i32 %10, 48
%12 = or i32 %11, %6
%13 = trunc i32 %12 to i8
%14 = tail call signext i8 @binToBase64(i8 signext %13)
store i8 %14, i8* %3
%15 = call i32 @strncat(i8* %0, i8* %3, i32 1)
%16 = getelementptr inbounds i8, i8* %1, i64 2
%17 = load i8, i8* %16
%18 = call i32 @asciiToHex(i8 signext %17)
%19 = shl i32 %18, 2
%20 = and i32 %19, 60
%21 = load i8, i8* %7
%22 = call i32 @asciiToHex(i8 signext %21)
%23 = lshr i32 %22, 2
%24 = and i32 %23, 3
%25 = or i32 %24, %20
%26 = trunc i32 %25 to i8
%27 = call signext i8 @binToBase64(i8 signext %26)
store i8 %27, i8* %3
%28 = call i32 @strncat(i8* %0, i8* %3, i32 1)
ret void
}