#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*/ invalid_strings;
typedef int /*<<< orphan*/ invalid_set;

/* Variables and functions */
scalar_t__ base64_decode(char const *, size_t, char *, size_t *, int);
int /*<<< orphan*/ base64_encode(char *, int, char *, size_t *, int);
int /*<<< orphan*/ printf(char *, ...);
size_t strlen(char const *);
int test_invalid_dec_input(int flags) {
  static const char invalid_set[] = {'\0', -1, '!', '-', ';', '_', '|'};
  static const char *invalid_strings[] = {"Zm9vYg=", "Zm9vYg", "Zm9vY",
                                          "Zm9vYmF=Zm9v"};
  bool fail = false;
  char chr[256];
  char enc[400], dec[400];
  size_t enclen, declen;
  for (int i = 0; i < 256; i++)
    chr[i] = (unsigned char)i;
  base64_encode(chr, 256, enc, &enclen, (1 << 3));
  for (size_t i = 0U; i < sizeof(invalid_strings) / sizeof(invalid_strings[0]);
       ++i) {
    if (base64_decode(invalid_strings[i], strlen(invalid_strings[i]), dec,
                      &declen, flags)) {
      printf("FAIL: decoding invalid input \"%s\": no decoding error\n",
             invalid_strings[i]);
      fail = true;
    }
  }
  for (size_t c = 0U; c < sizeof(invalid_set); ++c) {
    for (size_t i = 0U; i < enclen; i++) {
      char backup = enc[i];
      enc[i] = invalid_set[c];
      if (base64_decode(enc, enclen, dec, &declen, flags)) {
        printf("FAIL: decoding invalid input @ %d: no decoding error\n",
               (int)i);
        fail = true;
        enc[i] = backup;
        continue;
      }
      enc[i] = backup;
    }
  }
  for (size_t c = 0U; c < sizeof(invalid_set); ++c) {
    for (size_t i = 0U; i < enclen - 2U; i++) {
      char backup = enc[i + 0];
      char backup2 = enc[i + 2];
      enc[i + 0] = invalid_set[c];
      enc[i + 2] = invalid_set[c];
      if (base64_decode(enc, enclen, dec, &declen, flags)) {
        printf("FAIL: decoding invalid input @ %d: no decoding error\n",
               (int)i);
        fail = true;
        enc[i + 0] = backup;
        enc[i + 2] = backup2;
        continue;
      }
      enc[i + 0] = backup;
      enc[i + 2] = backup2;
    }
  }
  return fail;
}


x86 assembly (clang, -O0):
<test_invalid_dec_input>:
push   %rbp
mov    %rsp,%rbp
sub    $0x490,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0x444(%rbp)
cmpl   $0x100,-0x444(%rbp)
jge    1199 <test_invalid_dec_input+0x59>
mov    -0x444(%rbp),%eax
mov    %al,%cl
movslq -0x444(%rbp),%rax
mov    %cl,-0x110(%rbp,%rax,1)
mov    -0x444(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x444(%rbp)
jmp    115f <test_invalid_dec_input+0x1f>
lea    -0x110(%rbp),%rdi
lea    -0x2a0(%rbp),%rdx
mov    $0x100,%esi
lea    -0x438(%rbp),%rcx
mov    $0x8,%r8d
call   1050 <base64_encode@plt>
movq   $0x0,-0x450(%rbp)
cmpq   $0x4,-0x450(%rbp)
04
jae    1275 <test_invalid_dec_input+0x135>
mov    -0x450(%rbp),%rcx
lea    0x2e6b(%rip),%rax
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x488(%rbp)
mov    -0x450(%rbp),%rcx
lea    0x2e52(%rip),%rax
mov    (%rax,%rcx,8),%rdi
call   1030 <strlen@plt>
mov    -0x488(%rbp),%rdi
mov    %rax,%rsi
lea    -0x430(%rbp),%rdx
mov    -0x4(%rbp),%r8d
lea    -0x440(%rbp),%rcx
call   1060 <base64_decode@plt>
cmp    $0x0,%rax
je     1259 <test_invalid_dec_input+0x119>
mov    -0x450(%rbp),%rcx
lea    0x2e10(%rip),%rax
mov    (%rax,%rcx,8),%rsi
lea    0xdde(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x8(%rbp)
jmp    125e <test_invalid_dec_input+0x11e>
mov    -0x450(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x450(%rbp)
jmp    11c9 <test_invalid_dec_input+0x89>
movq   $0x0,-0x458(%rbp)
cmpq   $0x7,-0x458(%rbp)
07
jae    138d <test_invalid_dec_input+0x24d>
movq   $0x0,-0x460(%rbp)
mov    -0x460(%rbp),%rax
cmp    -0x438(%rbp),%rax
jae    1371 <test_invalid_dec_input+0x231>
mov    -0x460(%rbp),%rax
mov    -0x2a0(%rbp,%rax,1),%al
mov    %al,-0x461(%rbp)
mov    -0x458(%rbp),%rcx
lea    0xd31(%rip),%rax
mov    (%rax,%rcx,1),%cl
mov    -0x460(%rbp),%rax
mov    %cl,-0x2a0(%rbp,%rax,1)
lea    -0x2a0(%rbp),%rdi
mov    -0x438(%rbp),%rsi
lea    -0x430(%rbp),%rdx
mov    -0x4(%rbp),%r8d
lea    -0x440(%rbp),%rcx
call   1060 <base64_decode@plt>
cmp    $0x0,%rax
je     1346 <test_invalid_dec_input+0x206>
mov    -0x460(%rbp),%rax
mov    %eax,%esi
lea    0xd40(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x8(%rbp)
mov    -0x461(%rbp),%cl
mov    -0x460(%rbp),%rax
mov    %cl,-0x2a0(%rbp,%rax,1)
jmp    135a <test_invalid_dec_input+0x21a>
mov    -0x461(%rbp),%cl
mov    -0x460(%rbp),%rax
mov    %cl,-0x2a0(%rbp,%rax,1)
mov    -0x460(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x460(%rbp)
jmp    1299 <test_invalid_dec_input+0x159>
jmp    1376 <test_invalid_dec_input+0x236>
mov    -0x458(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x458(%rbp)
jmp    1280 <test_invalid_dec_input+0x140>
movq   $0x0,-0x470(%rbp)
cmpq   $0x7,-0x470(%rbp)
07
jae    1507 <test_invalid_dec_input+0x3c7>
movq   $0x0,-0x478(%rbp)
mov    -0x478(%rbp),%rax
mov    -0x438(%rbp),%rcx
sub    $0x2,%rcx
cmp    %rcx,%rax
jae    14eb <test_invalid_dec_input+0x3ab>
mov    -0x478(%rbp),%rax
mov    -0x2a0(%rbp,%rax,1),%al
mov    %al,-0x479(%rbp)
mov    -0x478(%rbp),%rax
mov    -0x29e(%rbp,%rax,1),%al
mov    %al,-0x47a(%rbp)
mov    -0x470(%rbp),%rcx
lea    0xbfe(%rip),%rax
mov    (%rax,%rcx,1),%cl
mov    -0x478(%rbp),%rax
mov    %cl,-0x2a0(%rbp,%rax,1)
mov    -0x470(%rbp),%rcx
lea    0xbdf(%rip),%rax
mov    (%rax,%rcx,1),%cl
mov    -0x478(%rbp),%rax
mov    %cl,-0x29e(%rbp,%rax,1)
lea    -0x2a0(%rbp),%rdi
mov    -0x438(%rbp),%rsi
lea    -0x430(%rbp),%rdx
mov    -0x4(%rbp),%r8d
lea    -0x440(%rbp),%rcx
call   1060 <base64_decode@plt>
cmp    $0x0,%rax
je     14ac <test_invalid_dec_input+0x36c>
mov    -0x478(%rbp),%rax
mov    %eax,%esi
lea    0xbee(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x8(%rbp)
mov    -0x479(%rbp),%cl
mov    -0x478(%rbp),%rax
mov    %cl,-0x2a0(%rbp,%rax,1)
mov    -0x47a(%rbp),%cl
mov    -0x478(%rbp),%rax
mov    %cl,-0x29e(%rbp,%rax,1)
jmp    14d4 <test_invalid_dec_input+0x394>
mov    -0x479(%rbp),%cl
mov    -0x478(%rbp),%rax
mov    %cl,-0x2a0(%rbp,%rax,1)
mov    -0x47a(%rbp),%cl
mov    -0x478(%rbp),%rax
mov    %cl,-0x29e(%rbp,%rax,1)
mov    -0x478(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x478(%rbp)
jmp    13b1 <test_invalid_dec_input+0x271>
jmp    14f0 <test_invalid_dec_input+0x3b0>
mov    -0x470(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x470(%rbp)
jmp    1398 <test_invalid_dec_input+0x258>
mov    -0x8(%rbp),%eax
add    $0x490,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_invalid_dec_input>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x448,%rsp
mov    %edi,%r12d
movaps 0xeb5(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xeb9(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xebd(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xec1(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xec5(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xec9(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xecd(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movaps 0xece(%rip),%xmm0
movaps %xmm0,0x90(%rsp)
movaps 0xecf(%rip),%xmm0
movaps %xmm0,0xa0(%rsp)
movaps 0xed0(%rip),%xmm0
movaps %xmm0,0xb0(%rsp)
movaps 0xed1(%rip),%xmm0
movaps %xmm0,0xc0(%rsp)
movaps 0xed2(%rip),%xmm0
movaps %xmm0,0xd0(%rsp)
movaps 0xed3(%rip),%xmm0
movaps %xmm0,0xe0(%rsp)
movaps 0xed4(%rip),%xmm0
movaps %xmm0,0xf0(%rsp)
movaps 0xed5(%rip),%xmm0
movaps %xmm0,0x100(%rsp)
movaps 0xed6(%rip),%xmm0
movaps %xmm0,0x110(%rsp)
lea    0x20(%rsp),%rdi
lea    0x120(%rsp),%rdx
lea    0x18(%rsp),%rcx
mov    $0x100,%esi
mov    $0x8,%r8d
call   1040 <base64_encode@plt>
lea    0xebc(%rip),%rdi
lea    0x2b0(%rsp),%rdx
lea    0x8(%rsp),%rcx
mov    $0x7,%esi
mov    %r12d,%r8d
call   1050 <base64_decode@plt>
test   %rax,%rax
je     1286 <test_invalid_dec_input+0x156>
lea    0xeb8(%rip),%rdi
lea    0xe8f(%rip),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%ebp
jmp    1288 <test_invalid_dec_input+0x158>
xor    %ebp,%ebp
lea    0xe80(%rip),%rdi
lea    0x2b0(%rsp),%rdx
lea    0x8(%rsp),%rcx
mov    $0x6,%esi
mov    %r12d,%r8d
call   1050 <base64_decode@plt>
test   %rax,%rax
je     12c8 <test_invalid_dec_input+0x198>
lea    0xe74(%rip),%rdi
lea    0xe53(%rip),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%ebp
lea    0xe47(%rip),%rdi
lea    0x2b0(%rsp),%rdx
lea    0x8(%rsp),%rcx
mov    $0x5,%esi
mov    %r12d,%r8d
call   1050 <base64_decode@plt>
test   %rax,%rax
je     1308 <test_invalid_dec_input+0x1d8>
lea    0xe34(%rip),%rdi
lea    0xe1a(%rip),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%ebp
lea    0xe0d(%rip),%rdi
lea    0x2b0(%rsp),%rdx
lea    0x8(%rsp),%rcx
mov    $0xc,%esi
mov    %r12d,%r8d
call   1050 <base64_decode@plt>
test   %rax,%rax
je     1348 <test_invalid_dec_input+0x218>
lea    0xdf4(%rip),%rdi
lea    0xde0(%rip),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%ebp
mov    0x18(%rsp),%rsi
lea    0x8(%rsp),%rbx
mov    %rsi,%rax
xor    %edx,%edx
jmp    1375 <test_invalid_dec_input+0x245>
nopl   0x0(%rax)
xor    %eax,%eax
mov    0x10(%rsp),%rdx
add    $0x1,%rdx
cmp    $0x7,%rdx
je     1402 <test_invalid_dec_input+0x2d2>
test   %rax,%rax
mov    %rdx,0x10(%rsp)
je     1360 <test_invalid_dec_input+0x230>
lea    0xd7a(%rip),%rcx
mov    (%rdx,%rcx,1),%r14b
mov    %rax,%rsi
xor    %r13d,%r13d
jmp    13b9 <test_invalid_dec_input+0x289>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15b,0x120(%rsp,%r13,1)
add    $0x1,%r13
mov    0x18(%rsp),%rsi
mov    %rsi,%rax
cmp    %rsi,%r13
jae    1362 <test_invalid_dec_input+0x232>
movzbl 0x120(%rsp,%r13,1),%r15d
mov    %r14b,0x120(%rsp,%r13,1)
lea    0x120(%rsp),%rdi
lea    0x2b0(%rsp),%rdx
mov    %rbx,%rcx
mov    %r12d,%r8d
call   1050 <base64_decode@plt>
test   %rax,%rax
je     13a0 <test_invalid_dec_input+0x270>
lea    0xd6e(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%ebp
jmp    13a0 <test_invalid_dec_input+0x270>
xor    %ecx,%ecx
jmp    1428 <test_invalid_dec_input+0x2f8>
cs nopw 0x0(%rax,%rax,1)
mov    $0x2,%esi
mov    0x10(%rsp),%rcx
add    $0x1,%rcx
cmp    $0x7,%rcx
je     14ce <test_invalid_dec_input+0x39e>
cmp    $0x2,%rsi
mov    %rcx,0x10(%rsp)
je     1410 <test_invalid_dec_input+0x2e0>
lea    0xcc6(%rip),%rax
mov    (%rcx,%rax,1),%r15b
xor    %r13d,%r13d
jmp    1472 <test_invalid_dec_input+0x342>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %bl,0x120(%rsp,%r13,1)
mov    %r14b,0x122(%rsp,%r13,1)
add    $0x1,%r13
mov    0x18(%rsp),%rsi
lea    -0x2(%rsi),%rax
cmp    %rax,%r13
jae    1415 <test_invalid_dec_input+0x2e5>
movzbl 0x120(%rsp,%r13,1),%ebx
movzbl 0x122(%rsp,%r13,1),%r14d
mov    %r15b,0x120(%rsp,%r13,1)
mov    %r15b,0x122(%rsp,%r13,1)
lea    0x120(%rsp),%rdi
lea    0x2b0(%rsp),%rdx
lea    0x8(%rsp),%rcx
mov    %r12d,%r8d
call   1050 <base64_decode@plt>
test   %rax,%rax
je     1450 <test_invalid_dec_input+0x320>
lea    0xca2(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%ebp
jmp    1450 <test_invalid_dec_input+0x320>
mov    %ebp,%eax
add    $0x448,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@test_invalid_dec_input.invalid_set = internal constant [7 x i8] c"\00\FF!-;_|"
@test_invalid_dec_input.invalid_strings = internal global [4 x i8*] [i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i32 0, i32 0)]
@.str = [8 x i8] c"Zm9vYg=\00"
@.str.1 = [7 x i8] c"Zm9vYg\00"
@.str.2 = [6 x i8] c"Zm9vY\00"
@.str.3 = [13 x i8] c"Zm9vYmF=Zm9v\00"
@.str.4 = [54 x i8] c"FAIL: decoding invalid input \22%s\22: no decoding error\0A\00"
@.str.5 = [54 x i8] c"FAIL: decoding invalid input @ %d: no decoding error\0A\00"
define i32 @test_invalid_dec_input(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [256 x i8]
%5 = alloca [400 x i8]
%6 = alloca [400 x i8]
%7 = alloca i64
%8 = alloca i64
%9 = alloca i32
%10 = alloca i64
%11 = alloca i64
%12 = alloca i64
%13 = alloca i8
%14 = alloca i64
%15 = alloca i64
%16 = alloca i8
%17 = alloca i8
store i32 %0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %9
br label %18
18: ; preds = %27, %1
%19 = load i32, i32* %9
%20 = icmp slt i32 %19, 256
br i1 %20, label %21, label %30
21: ; preds = %18
%22 = load i32, i32* %9
%23 = trunc i32 %22 to i8
%24 = load i32, i32* %9
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 %25
store i8 %23, i8* %26
br label %27
27: ; preds = %21
%28 = load i32, i32* %9
%29 = add nsw i32 %28, 1
store i32 %29, i32* %9
br label %18
30: ; preds = %18
%31 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%32 = getelementptr inbounds [400 x i8], [400 x i8]* %5, i64 0, i64 0
%33 = call i32 @base64_encode(i8* %31, i32 256, i8* %32, i64* %7, i32 8)
store i64 0, i64* %10
br label %34
34: ; preds = %55, %30
%35 = load i64, i64* %10
%36 = icmp ult i64 %35, 4
br i1 %36, label %37, label %58
37: ; preds = %34
%38 = load i64, i64* %10
%39 = getelementptr inbounds [4 x i8*], [4 x i8*]* @test_invalid_dec_input.invalid_strings, i64 0, i64 %38
%40 = load i8*, i8** %39
%41 = load i64, i64* %10
%42 = getelementptr inbounds [4 x i8*], [4 x i8*]* @test_invalid_dec_input.invalid_strings, i64 0, i64 %41
%43 = load i8*, i8** %42
%44 = call i64 @strlen(i8* %43)
%45 = getelementptr inbounds [400 x i8], [400 x i8]* %6, i64 0, i64 0
%46 = load i32, i32* %2
%47 = call i64 @base64_decode(i8* %40, i64 %44, i8* %45, i64* %8, i32 %46)
%48 = icmp ne i64 %47, 0
br i1 %48, label %49, label %54
49: ; preds = %37
%50 = load i64, i64* %10
%51 = getelementptr inbounds [4 x i8*], [4 x i8*]* @test_invalid_dec_input.invalid_strings, i64 0, i64 %50
%52 = load i8*, i8** %51
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.4, i64 0, i64 0), i8* %52)
store i32 1, i32* %3
br label %54
54: ; preds = %49, %37
br label %55
55: ; preds = %54
%56 = load i64, i64* %10
%57 = add i64 %56, 1
store i64 %57, i64* %10
br label %34
58: ; preds = %34
store i64 0, i64* %11
br label %59
59: ; preds = %97, %58
%60 = load i64, i64* %11
%61 = icmp ult i64 %60, 7
br i1 %61, label %62, label %100
62: ; preds = %59
store i64 0, i64* %12
br label %63
63: ; preds = %93, %62
%64 = load i64, i64* %12
%65 = load i64, i64* %7
%66 = icmp ult i64 %64, %65
br i1 %66, label %67, label %96
67: ; preds = %63
%68 = load i64, i64* %12
%69 = getelementptr inbounds [400 x i8], [400 x i8]* %5, i64 0, i64 %68
%70 = load i8, i8* %69
store i8 %70, i8* %13
%71 = load i64, i64* %11
%72 = getelementptr inbounds [7 x i8], [7 x i8]* @test_invalid_dec_input.invalid_set, i64 0, i64 %71
%73 = load i8, i8* %72
%74 = load i64, i64* %12
%75 = getelementptr inbounds [400 x i8], [400 x i8]* %5, i64 0, i64 %74
store i8 %73, i8* %75
%76 = getelementptr inbounds [400 x i8], [400 x i8]* %5, i64 0, i64 0
%77 = load i64, i64* %7
%78 = getelementptr inbounds [400 x i8], [400 x i8]* %6, i64 0, i64 0
%79 = load i32, i32* %2
%80 = call i64 @base64_decode(i8* %76, i64 %77, i8* %78, i64* %8, i32 %79)
%81 = icmp ne i64 %80, 0
br i1 %81, label %82, label %89
82: ; preds = %67
%83 = load i64, i64* %12
%84 = trunc i64 %83 to i32
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.5, i64 0, i64 0), i32 %84)
store i32 1, i32* %3
%86 = load i8, i8* %13
%87 = load i64, i64* %12
%88 = getelementptr inbounds [400 x i8], [400 x i8]* %5, i64 0, i64 %87
store i8 %86, i8* %88
br label %93
89: ; preds = %67
%90 = load i8, i8* %13
%91 = load i64, i64* %12
%92 = getelementptr inbounds [400 x i8], [400 x i8]* %5, i64 0, i64 %91
store i8 %90, i8* %92
br label %93
93: ; preds = %89, %82
%94 = load i64, i64* %12
%95 = add i64 %94, 1
store i64 %95, i64* %12
br label %63
96: ; preds = %63
br label %97
97: ; preds = %96
%98 = load i64, i64* %11
%99 = add i64 %98, 1
store i64 %99, i64* %11
br label %59
100: ; preds = %59
store i64 0, i64* %14
br label %101
101: ; preds = %162, %100
%102 = load i64, i64* %14
%103 = icmp ult i64 %102, 7
br i1 %103, label %104, label %165
104: ; preds = %101
store i64 0, i64* %15
br label %105
105: ; preds = %158, %104
%106 = load i64, i64* %15
%107 = load i64, i64* %7
%108 = sub i64 %107, 2
%109 = icmp ult i64 %106, %108
br i1 %109, label %110, label %161
110: ; preds = %105
%111 = load i64, i64* %15
%112 = add i64 %111, 0
%113 = getelementptr inbounds [400 x i8], [400 x i8]* %5, i64 0, i64 %112
%114 = load i8, i8* %113
store i8 %114, i8* %16
%115 = load i64, i64* %15
%116 = add i64 %115, 2
%117 = getelementptr inbounds [400 x i8], [400 x i8]* %5, i64 0, i64 %116
%118 = load i8, i8* %117
store i8 %118, i8* %17
%119 = load i64, i64* %14
%120 = getelementptr inbounds [7 x i8], [7 x i8]* @test_invalid_dec_input.invalid_set, i64 0, i64 %119
%121 = load i8, i8* %120
%122 = load i64, i64* %15
%123 = add i64 %122, 0
%124 = getelementptr inbounds [400 x i8], [400 x i8]* %5, i64 0, i64 %123
store i8 %121, i8* %124
%125 = load i64, i64* %14
%126 = getelementptr inbounds [7 x i8], [7 x i8]* @test_invalid_dec_input.invalid_set, i64 0, i64 %125
%127 = load i8, i8* %126
%128 = load i64, i64* %15
%129 = add i64 %128, 2
%130 = getelementptr inbounds [400 x i8], [400 x i8]* %5, i64 0, i64 %129
store i8 %127, i8* %130
%131 = getelementptr inbounds [400 x i8], [400 x i8]* %5, i64 0, i64 0
%132 = load i64, i64* %7
%133 = getelementptr inbounds [400 x i8], [400 x i8]* %6, i64 0, i64 0
%134 = load i32, i32* %2
%135 = call i64 @base64_decode(i8* %131, i64 %132, i8* %133, i64* %8, i32 %134)
%136 = icmp ne i64 %135, 0
br i1 %136, label %137, label %149
137: ; preds = %110
%138 = load i64, i64* %15
%139 = trunc i64 %138 to i32
%140 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.5, i64 0, i64 0), i32 %139)
store i32 1, i32* %3
%141 = load i8, i8* %16
%142 = load i64, i64* %15
%143 = add i64 %142, 0
%144 = getelementptr inbounds [400 x i8], [400 x i8]* %5, i64 0, i64 %143
store i8 %141, i8* %144
%145 = load i8, i8* %17
%146 = load i64, i64* %15
%147 = add i64 %146, 2
%148 = getelementptr inbounds [400 x i8], [400 x i8]* %5, i64 0, i64 %147
store i8 %145, i8* %148
br label %158
149: ; preds = %110
%150 = load i8, i8* %16
%151 = load i64, i64* %15
%152 = add i64 %151, 0
%153 = getelementptr inbounds [400 x i8], [400 x i8]* %5, i64 0, i64 %152
store i8 %150, i8* %153
%154 = load i8, i8* %17
%155 = load i64, i64* %15
%156 = add i64 %155, 2
%157 = getelementptr inbounds [400 x i8], [400 x i8]* %5, i64 0, i64 %156
store i8 %154, i8* %157
br label %158
158: ; preds = %149, %137
%159 = load i64, i64* %15
%160 = add i64 %159, 1
store i64 %160, i64* %15
br label %105
161: ; preds = %105
br label %162
162: ; preds = %161
%163 = load i64, i64* %14
%164 = add i64 %163, 1
store i64 %164, i64* %14
br label %101
165: ; preds = %101
%166 = load i32, i32* %3
ret i32 %166
}

LLVM IR (-O2):
@test_invalid_dec_input.invalid_set = internal unnamed_addr constant [7 x i8] c"\00\FF!-;_|"
@.str = [8 x i8] c"Zm9vYg=\00"
@.str.1 = [7 x i8] c"Zm9vYg\00"
@.str.2 = [6 x i8] c"Zm9vY\00"
@.str.3 = [13 x i8] c"Zm9vYmF=Zm9v\00"
@.str.4 = [54 x i8] c"FAIL: decoding invalid input \22%s\22: no decoding error\0A\00"
@.str.5 = [54 x i8] c"FAIL: decoding invalid input @ %d: no decoding error\0A\00"
define i32 @test_invalid_dec_input(i32 %0) {
%2 = alloca [256 x i8]
%3 = alloca [400 x i8]
%4 = alloca [400 x i8]
%5 = alloca i64
%6 = alloca i64
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%8 = getelementptr inbounds [400 x i8], [400 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [400 x i8], [400 x i8]* %4, i64 0, i64 0
%10 = bitcast i64* %5 to i8*
%11 = bitcast i64* %6 to i8*
%12 = bitcast [256 x i8]* %2 to <16 x i8>*
store <16 x i8> <i8 0, i8 1, i8 2, i8 3, i8 4, i8 5, i8 6, i8 7, i8 8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15>, <16 x i8>* %12
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 16
%14 = bitcast i8* %13 to <16 x i8>*
store <16 x i8> <i8 16, i8 17, i8 18, i8 19, i8 20, i8 21, i8 22, i8 23, i8 24, i8 25, i8 26, i8 27, i8 28, i8 29, i8 30, i8 31>, <16 x i8>* %14
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 32
%16 = bitcast i8* %15 to <16 x i8>*
store <16 x i8> <i8 32, i8 33, i8 34, i8 35, i8 36, i8 37, i8 38, i8 39, i8 40, i8 41, i8 42, i8 43, i8 44, i8 45, i8 46, i8 47>, <16 x i8>* %16
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 48
%18 = bitcast i8* %17 to <16 x i8>*
store <16 x i8> <i8 48, i8 49, i8 50, i8 51, i8 52, i8 53, i8 54, i8 55, i8 56, i8 57, i8 58, i8 59, i8 60, i8 61, i8 62, i8 63>, <16 x i8>* %18
%19 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 64
%20 = bitcast i8* %19 to <16 x i8>*
store <16 x i8> <i8 64, i8 65, i8 66, i8 67, i8 68, i8 69, i8 70, i8 71, i8 72, i8 73, i8 74, i8 75, i8 76, i8 77, i8 78, i8 79>, <16 x i8>* %20
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 80
%22 = bitcast i8* %21 to <16 x i8>*
store <16 x i8> <i8 80, i8 81, i8 82, i8 83, i8 84, i8 85, i8 86, i8 87, i8 88, i8 89, i8 90, i8 91, i8 92, i8 93, i8 94, i8 95>, <16 x i8>* %22
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 96
%24 = bitcast i8* %23 to <16 x i8>*
store <16 x i8> <i8 96, i8 97, i8 98, i8 99, i8 100, i8 101, i8 102, i8 103, i8 104, i8 105, i8 106, i8 107, i8 108, i8 109, i8 110, i8 111>, <16 x i8>* %24
%25 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 112
%26 = bitcast i8* %25 to <16 x i8>*
store <16 x i8> <i8 112, i8 113, i8 114, i8 115, i8 116, i8 117, i8 118, i8 119, i8 120, i8 121, i8 122, i8 123, i8 124, i8 125, i8 126, i8 127>, <16 x i8>* %26
%27 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 128
%28 = bitcast i8* %27 to <16 x i8>*
store <16 x i8> <i8 -128, i8 -127, i8 -126, i8 -125, i8 -124, i8 -123, i8 -122, i8 -121, i8 -120, i8 -119, i8 -118, i8 -117, i8 -116, i8 -115, i8 -114, i8 -113>, <16 x i8>* %28
%29 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 144
%30 = bitcast i8* %29 to <16 x i8>*
store <16 x i8> <i8 -112, i8 -111, i8 -110, i8 -109, i8 -108, i8 -107, i8 -106, i8 -105, i8 -104, i8 -103, i8 -102, i8 -101, i8 -100, i8 -99, i8 -98, i8 -97>, <16 x i8>* %30
%31 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 160
%32 = bitcast i8* %31 to <16 x i8>*
store <16 x i8> <i8 -96, i8 -95, i8 -94, i8 -93, i8 -92, i8 -91, i8 -90, i8 -89, i8 -88, i8 -87, i8 -86, i8 -85, i8 -84, i8 -83, i8 -82, i8 -81>, <16 x i8>* %32
%33 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 176
%34 = bitcast i8* %33 to <16 x i8>*
store <16 x i8> <i8 -80, i8 -79, i8 -78, i8 -77, i8 -76, i8 -75, i8 -74, i8 -73, i8 -72, i8 -71, i8 -70, i8 -69, i8 -68, i8 -67, i8 -66, i8 -65>, <16 x i8>* %34
%35 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 192
%36 = bitcast i8* %35 to <16 x i8>*
store <16 x i8> <i8 -64, i8 -63, i8 -62, i8 -61, i8 -60, i8 -59, i8 -58, i8 -57, i8 -56, i8 -55, i8 -54, i8 -53, i8 -52, i8 -51, i8 -50, i8 -49>, <16 x i8>* %36
%37 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 208
%38 = bitcast i8* %37 to <16 x i8>*
store <16 x i8> <i8 -48, i8 -47, i8 -46, i8 -45, i8 -44, i8 -43, i8 -42, i8 -41, i8 -40, i8 -39, i8 -38, i8 -37, i8 -36, i8 -35, i8 -34, i8 -33>, <16 x i8>* %38
%39 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 224
%40 = bitcast i8* %39 to <16 x i8>*
store <16 x i8> <i8 -32, i8 -31, i8 -30, i8 -29, i8 -28, i8 -27, i8 -26, i8 -25, i8 -24, i8 -23, i8 -22, i8 -21, i8 -20, i8 -19, i8 -18, i8 -17>, <16 x i8>* %40
%41 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 240
%42 = bitcast i8* %41 to <16 x i8>*
store <16 x i8> <i8 -16, i8 -15, i8 -14, i8 -13, i8 -12, i8 -11, i8 -10, i8 -9, i8 -8, i8 -7, i8 -6, i8 -5, i8 -4, i8 -3, i8 -2, i8 -1>, <16 x i8>* %42
%43 = call i32 @base64_encode(i8* %7, i32 256, i8* %8, i64* %5, i32 8)
%44 = call i64 @base64_decode(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64 7, i8* %9, i64* %6, i32 %0)
%45 = icmp eq i64 %44, 0
br i1 %45, label %48, label %46
46: ; preds = %1
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %48
48: ; preds = %1, %46
%49 = phi i32 [ 1, %46 ], [ 0, %1 ]
%50 = call i64 @base64_decode(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i64 6, i8* %9, i64* %6, i32 %0)
%51 = icmp eq i64 %50, 0
br i1 %51, label %54, label %52
52: ; preds = %48
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %54
54: ; preds = %52, %48
%55 = phi i32 [ 1, %52 ], [ %49, %48 ]
%56 = call i64 @base64_decode(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 5, i8* %9, i64* %6, i32 %0)
%57 = icmp eq i64 %56, 0
br i1 %57, label %60, label %58
58: ; preds = %54
%59 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %60
60: ; preds = %58, %54
%61 = phi i32 [ 1, %58 ], [ %55, %54 ]
%62 = call i64 @base64_decode(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i64 12, i8* %9, i64* %6, i32 %0)
%63 = icmp eq i64 %62, 0
br i1 %63, label %66, label %64
64: ; preds = %60
%65 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %66
66: ; preds = %64, %60
%67 = phi i32 [ 1, %64 ], [ %61, %60 ]
%68 = load i64, i64* %5
br label %69
69: ; preds = %66, %78
%70 = phi i64 [ %79, %78 ], [ %68, %66 ]
%71 = phi i64 [ %80, %78 ], [ %68, %66 ]
%72 = phi i32 [ %81, %78 ], [ %67, %66 ]
%73 = phi i64 [ %82, %78 ], [ 0, %66 ]
%74 = icmp eq i64 %71, 0
br i1 %74, label %78, label %75
75: ; preds = %69
%76 = getelementptr inbounds [7 x i8], [7 x i8]* @test_invalid_dec_input.invalid_set, i64 0, i64 %73
%77 = load i8, i8* %76
br label %84
78: ; preds = %95, %69
%79 = phi i64 [ %70, %69 ], [ %98, %95 ]
%80 = phi i64 [ 0, %69 ], [ %98, %95 ]
%81 = phi i32 [ %72, %69 ], [ %96, %95 ]
%82 = add nuw nsw i64 %73, 1
%83 = icmp eq i64 %82, 7
br i1 %83, label %100, label %69
84: ; preds = %75, %95
%85 = phi i64 [ %71, %75 ], [ %98, %95 ]
%86 = phi i32 [ %72, %75 ], [ %96, %95 ]
%87 = phi i64 [ 0, %75 ], [ %97, %95 ]
%88 = getelementptr inbounds [400 x i8], [400 x i8]* %3, i64 0, i64 %87
%89 = load i8, i8* %88
store i8 %77, i8* %88
%90 = call i64 @base64_decode(i8* %8, i64 %85, i8* %9, i64* %6, i32 %0)
%91 = icmp eq i64 %90, 0
br i1 %91, label %95, label %92
92: ; preds = %84
%93 = trunc i64 %87 to i32
%94 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.5, i64 0, i64 0), i32 %93)
br label %95
95: ; preds = %84, %92
%96 = phi i32 [ 1, %92 ], [ %86, %84 ]
store i8 %89, i8* %88
%97 = add nuw i64 %87, 1
%98 = load i64, i64* %5
%99 = icmp ult i64 %97, %98
br i1 %99, label %84, label %78
100: ; preds = %78, %109
%101 = phi i64 [ %110, %109 ], [ %79, %78 ]
%102 = phi i32 [ %111, %109 ], [ %81, %78 ]
%103 = phi i64 [ %112, %109 ], [ 0, %78 ]
%104 = icmp eq i64 %101, 2
br i1 %104, label %109, label %105
105: ; preds = %100
%106 = getelementptr inbounds [7 x i8], [7 x i8]* @test_invalid_dec_input.invalid_set, i64 0, i64 %103
%107 = load i8, i8* %106
br label %114
108: ; preds = %109
ret i32 %111
109: ; preds = %128, %100
%110 = phi i64 [ 2, %100 ], [ %131, %128 ]
%111 = phi i32 [ %102, %100 ], [ %129, %128 ]
%112 = add nuw nsw i64 %103, 1
%113 = icmp eq i64 %112, 7
br i1 %113, label %108, label %100
114: ; preds = %105, %128
%115 = phi i64 [ %101, %105 ], [ %131, %128 ]
%116 = phi i32 [ %102, %105 ], [ %129, %128 ]
%117 = phi i64 [ 0, %105 ], [ %130, %128 ]
%118 = getelementptr inbounds [400 x i8], [400 x i8]* %3, i64 0, i64 %117
%119 = load i8, i8* %118
%120 = add i64 %117, 2
%121 = getelementptr inbounds [400 x i8], [400 x i8]* %3, i64 0, i64 %120
%122 = load i8, i8* %121
store i8 %107, i8* %118
store i8 %107, i8* %121
%123 = call i64 @base64_decode(i8* %8, i64 %115, i8* %9, i64* %6, i32 %0)
%124 = icmp eq i64 %123, 0
br i1 %124, label %128, label %125
125: ; preds = %114
%126 = trunc i64 %117 to i32
%127 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.5, i64 0, i64 0), i32 %126)
br label %128
128: ; preds = %114, %125
%129 = phi i32 [ 1, %125 ], [ %116, %114 ]
store i8 %119, i8* %118
store i8 %122, i8* %121
%130 = add nuw i64 %117, 1
%131 = load i64, i64* %5
%132 = add i64 %131, -2
%133 = icmp ult i64 %130, %132
br i1 %133, label %114, label %109
}