#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 */
scalar_t__ strlen(char *);
int /*<<< orphan*/ strncat(char *, char *, scalar_t__);
int decodeblock(char *input, char *output, int oplen) {
  int rc = 0;
  char decodedstr[4 + 1] = "";
  decodedstr[0] = input[0] << 2 | input[1] >> 4;
  decodedstr[1] = input[1] << 4 | input[2] >> 2;
  decodedstr[2] = input[2] << 6 | input[3] >> 0;
  strncat(output, decodedstr, oplen - strlen(output));
  return rc;
}


x86 assembly (clang, -O0):
<decodeblock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
lea    -0x1d(%rbp),%rdi
xor    %esi,%esi
mov    $0x5,%edx
call   1040 <memset@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
shl    $0x2,%eax
mov    -0x8(%rbp),%rcx
movsbl 0x1(%rcx),%ecx
sar    $0x4,%ecx
or     %ecx,%eax
mov    %al,-0x1d(%rbp)
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%eax
shl    $0x4,%eax
mov    -0x8(%rbp),%rcx
movsbl 0x2(%rcx),%ecx
sar    $0x2,%ecx
or     %ecx,%eax
mov    %al,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movsbl 0x2(%rax),%eax
shl    $0x6,%eax
mov    -0x8(%rbp),%rcx
movsbl 0x3(%rcx),%ecx
sar    $0x0,%ecx
or     %ecx,%eax
mov    %al,-0x1b(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
lea    -0x1d(%rbp),%rax
mov    %rax,-0x28(%rbp)
movslq -0x14(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x38(%rbp),%rdx
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
sub    %rax,%rdx
call   1050 <strncat@plt>
mov    -0x18(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decodeblock>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
movw   $0x0,0x6(%rsp)
mov    (%rdi),%al
mov    0x1(%rdi),%bl
shl    $0x2,%al
mov    %ebx,%ecx
sar    $0x4,%cl
or     %al,%cl
mov    %cl,0x3(%rsp)
shl    $0x4,%bl
mov    0x2(%rdi),%al
mov    %eax,%ecx
sar    $0x2,%cl
or     %bl,%cl
mov    %cl,0x4(%rsp)
shl    $0x6,%al
or     0x3(%rdi),%al
mov    %al,0x5(%rsp)
movslq %edx,%rbx
mov    %rsi,%rdi
call   1030 <strlen@plt>
sub    %rax,%rbx
lea    0x3(%rsp),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
call   1040 <strncat@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @decodeblock(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca [5 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
store i32 0, i32* %7
%9 = bitcast [5 x i8]* %8 to i8*
%10 = load i8*, i8** %4
%11 = getelementptr inbounds i8, i8* %10, i64 0
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = shl i32 %13, 2
%15 = load i8*, i8** %4
%16 = getelementptr inbounds i8, i8* %15, i64 1
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = ashr i32 %18, 4
%20 = or i32 %14, %19
%21 = trunc i32 %20 to i8
%22 = getelementptr inbounds [5 x i8], [5 x i8]* %8, i64 0, i64 0
store i8 %21, i8* %22
%23 = load i8*, i8** %4
%24 = getelementptr inbounds i8, i8* %23, i64 1
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = shl i32 %26, 4
%28 = load i8*, i8** %4
%29 = getelementptr inbounds i8, i8* %28, i64 2
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = ashr i32 %31, 2
%33 = or i32 %27, %32
%34 = trunc i32 %33 to i8
%35 = getelementptr inbounds [5 x i8], [5 x i8]* %8, i64 0, i64 1
store i8 %34, i8* %35
%36 = load i8*, i8** %4
%37 = getelementptr inbounds i8, i8* %36, i64 2
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = shl i32 %39, 6
%41 = load i8*, i8** %4
%42 = getelementptr inbounds i8, i8* %41, i64 3
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = ashr i32 %44, 0
%46 = or i32 %40, %45
%47 = trunc i32 %46 to i8
%48 = getelementptr inbounds [5 x i8], [5 x i8]* %8, i64 0, i64 2
store i8 %47, i8* %48
%49 = load i8*, i8** %5
%50 = getelementptr inbounds [5 x i8], [5 x i8]* %8, i64 0, i64 0
%51 = load i32, i32* %6
%52 = sext i32 %51 to i64
%53 = load i8*, i8** %5
%54 = call i64 @strlen(i8* %53)
%55 = sub nsw i64 %52, %54
%56 = call i32 @strncat(i8* %49, i8* %50, i64 %55)
%57 = load i32, i32* %7
ret i32 %57
}

LLVM IR (-O2):
define i32 @decodeblock(i8* nocapture %0, i8* %1, i32 %2) {
%4 = alloca [5 x i8]
%5 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%6 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 3
%7 = bitcast i8* %6 to i16*
store i16 0, i16* %7
%8 = load i8, i8* %0
%9 = shl i8 %8, 2
%10 = getelementptr inbounds i8, i8* %0, i64 1
%11 = load i8, i8* %10
%12 = ashr i8 %11, 4
%13 = or i8 %12, %9
store i8 %13, i8* %5
%14 = shl i8 %11, 4
%15 = getelementptr inbounds i8, i8* %0, i64 2
%16 = load i8, i8* %15
%17 = ashr i8 %16, 2
%18 = or i8 %17, %14
%19 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 1
store i8 %18, i8* %19
%20 = shl i8 %16, 6
%21 = getelementptr inbounds i8, i8* %0, i64 3
%22 = load i8, i8* %21
%23 = or i8 %22, %20
%24 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 2
store i8 %23, i8* %24
%25 = sext i32 %2 to i64
%26 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%27 = sub nsw i64 %25, %26
%28 = call i32 @strncat(i8* %1, i8* %5, i64 %27)
ret i32 0
}