#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 uint8_t;
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
char code_to_char(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, char *);
int /*<<< orphan*/ stderr;
int bin_to_b64_nopad(const uint8_t *in, int size, char *out, int max_len) {
  int i;
  int result_len;
  int full_blocks;
  int last_bytes;
  int last_chars;
  uint32_t b;
  if ((out == NULL) || (in == NULL)) {
    ;
    return -1;
  }
  if (size == 0) {
    *out = 0;
    return 0;
  }
  full_blocks = size / 3;
  last_bytes = size % 3;
  switch (last_bytes) {
  case 0:
    last_chars = 0;
    break;
  case 1:
    last_chars = 2;
    break;
  case 2:
    last_chars = 3;
    break;
  default:
    fprintf(stderr, "\nCRITICAL file:%s line:%u msg:%s\n",
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/Ebiroll/qemu_esp32/refs/heads/master/"
            "examples/33_pkt_fwd/main/base64.c",
            130, "switch default that should not be possible");
    exit(EXIT_FAILURE);
  }
  result_len = (4 * full_blocks) + last_chars;
  if (max_len < (result_len + 1)) {
    ;
    return -1;
  }
  for (i = 0; i < full_blocks; ++i) {
    b = (0xFF & in[3 * i]) << 16;
    b |= (0xFF & in[3 * i + 1]) << 8;
    b |= 0xFF & in[3 * i + 2];
    out[4 * i + 0] = code_to_char((b >> 18) & 0x3F);
    out[4 * i + 1] = code_to_char((b >> 12) & 0x3F);
    out[4 * i + 2] = code_to_char((b >> 6) & 0x3F);
    out[4 * i + 3] = code_to_char(b & 0x3F);
  }
  i = full_blocks;
  if (last_chars == 0) {
    out[4 * i] = 0;
  } else if (last_chars == 2) {
    b = (0xFF & in[3 * i]) << 16;
    out[4 * i + 0] = code_to_char((b >> 18) & 0x3F);
    out[4 * i + 1] = code_to_char((b >> 12) & 0x3F);
    out[4 * i + 2] = 0;
  } else if (last_chars == 3) {
    b = (0xFF & in[3 * i]) << 16;
    b |= (0xFF & in[3 * i + 1]) << 8;
    out[4 * i + 0] = code_to_char((b >> 18) & 0x3F);
    out[4 * i + 1] = code_to_char((b >> 12) & 0x3F);
    out[4 * i + 2] = code_to_char((b >> 6) & 0x3F);
    out[4 * i + 3] = 0;
  }
  return result_len;
}


x86 assembly (clang, -O0):
<bin_to_b64_nopad>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     115c <bin_to_b64_nopad+0x2c>
cmpq   $0x0,-0x10(%rbp)
jne    1168 <bin_to_b64_nopad+0x38>
movl   $0xffffffff,-0x4(%rbp)
jmp    14f1 <bin_to_b64_nopad+0x3c1>
cmpl   $0x0,-0x14(%rbp)
jne    1185 <bin_to_b64_nopad+0x55>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    14f1 <bin_to_b64_nopad+0x3c1>
movslq -0x14(%rbp),%rax
imul   $0x55555556,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
mov    %eax,-0x30(%rbp)
movslq -0x14(%rbp),%rcx
mov    %ecx,%eax
imul   $0x55555556,%rcx,%rdx
mov    %rdx,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rdx
add    %ecx,%edx
mov    %edx,%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %ecx,%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x40(%rbp)
test   %eax,%eax
je     11f9 <bin_to_b64_nopad+0xc9>
jmp    11d7 <bin_to_b64_nopad+0xa7>
mov    -0x40(%rbp),%eax
sub    $0x1,%eax
je     1205 <bin_to_b64_nopad+0xd5>
jmp    11e8 <bin_to_b64_nopad+0xb8>
mov    -0x40(%rbp),%eax
sub    $0x2,%eax
je     1211 <bin_to_b64_nopad+0xe1>
jmp    121d <bin_to_b64_nopad+0xed>
movl   $0x0,-0x38(%rbp)
jmp    1253 <bin_to_b64_nopad+0x123>
movl   $0x2,-0x38(%rbp)
jmp    1253 <bin_to_b64_nopad+0x123>
movl   $0x3,-0x38(%rbp)
jmp    1253 <bin_to_b64_nopad+0x123>
mov    0x2dbc(%rip),%rax
mov    (%rax),%edi
lea    0xdd3(%rip),%rsi
lea    0xdee(%rip),%rdx
mov    $0x82,%ecx
lea    0xe83(%rip),%r8
call   1040 <fprintf@plt>
mov    0x2d8c(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
mov    -0x30(%rbp),%eax
shl    $0x2,%eax
add    -0x38(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x2c(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    127c <bin_to_b64_nopad+0x14c>
movl   $0xffffffff,-0x4(%rbp)
jmp    14f1 <bin_to_b64_nopad+0x3c1>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    137a <bin_to_b64_nopad+0x24a>
mov    -0x10(%rbp),%rax
imul   $0x3,-0x28(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
and    $0xff,%eax
shl    $0x10,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x10(%rbp),%rax
imul   $0x3,-0x28(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
and    $0xff,%eax
shl    $0x8,%eax
or     -0x3c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x10(%rbp),%rax
imul   $0x3,-0x28(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
and    $0xff,%eax
or     -0x3c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%edi
sar    $0x12,%edi
and    $0x3f,%edi
call   1030 <code_to_char@plt>
mov    %al,%dl
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%ecx
shl    $0x2,%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x3c(%rbp),%edi
sar    $0xc,%edi
and    $0x3f,%edi
call   1030 <code_to_char@plt>
mov    %al,%dl
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%ecx
shl    $0x2,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x3c(%rbp),%edi
sar    $0x6,%edi
and    $0x3f,%edi
call   1030 <code_to_char@plt>
mov    %al,%dl
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%ecx
shl    $0x2,%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x3c(%rbp),%edi
and    $0x3f,%edi
call   1030 <code_to_char@plt>
mov    %al,%dl
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%ecx
shl    $0x2,%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1283 <bin_to_b64_nopad+0x153>
mov    -0x30(%rbp),%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x38(%rbp)
jne    13a0 <bin_to_b64_nopad+0x270>
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%ecx
shl    $0x2,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    14eb <bin_to_b64_nopad+0x3bb>
cmpl   $0x2,-0x38(%rbp)
jne    1422 <bin_to_b64_nopad+0x2f2>
mov    -0x10(%rbp),%rax
imul   $0x3,-0x28(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
and    $0xff,%eax
shl    $0x10,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%edi
sar    $0x12,%edi
and    $0x3f,%edi
call   1030 <code_to_char@plt>
mov    %al,%dl
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%ecx
shl    $0x2,%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x3c(%rbp),%edi
sar    $0xc,%edi
and    $0x3f,%edi
call   1030 <code_to_char@plt>
mov    %al,%dl
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%ecx
shl    $0x2,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%ecx
shl    $0x2,%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    14e6 <bin_to_b64_nopad+0x3b6>
cmpl   $0x3,-0x38(%rbp)
jne    14e1 <bin_to_b64_nopad+0x3b1>
mov    -0x10(%rbp),%rax
imul   $0x3,-0x28(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
and    $0xff,%eax
shl    $0x10,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x10(%rbp),%rax
imul   $0x3,-0x28(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
and    $0xff,%eax
shl    $0x8,%eax
or     -0x3c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%edi
sar    $0x12,%edi
and    $0x3f,%edi
call   1030 <code_to_char@plt>
mov    %al,%dl
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%ecx
shl    $0x2,%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x3c(%rbp),%edi
sar    $0xc,%edi
and    $0x3f,%edi
call   1030 <code_to_char@plt>
mov    %al,%dl
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%ecx
shl    $0x2,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x3c(%rbp),%edi
sar    $0x6,%edi
and    $0x3f,%edi
call   1030 <code_to_char@plt>
mov    %al,%dl
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%ecx
shl    $0x2,%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%ecx
shl    $0x2,%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    14e6 <bin_to_b64_nopad+0x3b6>
jmp    14eb <bin_to_b64_nopad+0x3bb>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bin_to_b64_nopad>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    $0xffffffff,%eax
test   %rdi,%rdi
je     1378 <bin_to_b64_nopad+0x248>
mov    %rdx,%r15
test   %rdx,%rdx
je     1378 <bin_to_b64_nopad+0x248>
test   %esi,%esi
je     119a <bin_to_b64_nopad+0x6a>
movslq %esi,%rdx
imul   $0x55555556,%rdx,%rbx
mov    %rbx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rbx
add    %edx,%ebx
lea    (%rbx,%rbx,2),%edx
mov    %esi,%ebp
sub    %edx,%ebp
je     11a1 <bin_to_b64_nopad+0x71>
cmp    $0x2,%ebp
je     11ac <bin_to_b64_nopad+0x7c>
cmp    $0x1,%ebp
jne    138d <bin_to_b64_nopad+0x25d>
mov    $0x2,%ebp
mov    $0x1,%r8b
xor    %r9d,%r9d
xor    %r10d,%r10d
jmp    11ba <bin_to_b64_nopad+0x8a>
xor    %eax,%eax
jmp    1374 <bin_to_b64_nopad+0x244>
mov    $0x1,%r9b
xor    %r8d,%r8d
xor    %r10d,%r10d
jmp    11ba <bin_to_b64_nopad+0x8a>
mov    $0x3,%ebp
mov    $0x1,%r10b
xor    %r9d,%r9d
xor    %r8d,%r8d
movslq %ebx,%rdx
shl    $0x2,%rdx
or     %edx,%ebp
cmp    %ecx,%ebp
jge    1378 <bin_to_b64_nopad+0x248>
mov    %r10d,0x24(%rsp)
mov    %r9d,0x2c(%rsp)
mov    %r8d,0x28(%rsp)
mov    %rbx,0x10(%rsp)
mov    %rdx,0x8(%rsp)
mov    %rdi,0x18(%rsp)
mov    %ebp,0x4(%rsp)
cmp    $0x3,%esi
jl     128a <bin_to_b64_nopad+0x15a>
mov    0x10(%rsp),%eax
mov    %rax,0x30(%rsp)
mov    0x18(%rsp),%rax
lea    0x8(%rax),%r13
xor    %r14d,%r14d
nopl   0x0(%rax,%rax,1)
mov    -0x8(%r13),%edi
mov    -0x4(%r13),%ebx
mov    %edi,%eax
shl    $0x10,%eax
shl    $0x8,%ebx
mov    0x0(%r13),%r12d
mov    %r12d,%ebp
and    $0xc0,%ebp
or     %ebx,%ebp
and    $0xf000,%ebx
or     %eax,%ebx
shr    $0x2,%edi
and    $0x3f,%edi
call   1030 <code_to_char@plt>
mov    %al,(%r15,%r14,4)
shr    $0xc,%ebx
and    $0x3f,%ebx
mov    %ebx,%edi
call   1030 <code_to_char@plt>
mov    %al,0x1(%r15,%r14,4)
shr    $0x6,%ebp
and    $0x3f,%ebp
mov    %ebp,%edi
call   1030 <code_to_char@plt>
mov    %al,0x2(%r15,%r14,4)
and    $0x3f,%r12d
mov    %r12d,%edi
call   1030 <code_to_char@plt>
mov    %al,0x3(%r15,%r14,4)
add    $0x1,%r14
add    $0xc,%r13
cmp    %r14,0x30(%rsp)
jne    1210 <bin_to_b64_nopad+0xe0>
cmpb   $0x0,0x2c(%rsp)
je     129b <bin_to_b64_nopad+0x16b>
movslq 0x8(%rsp),%rax
jmp    136d <bin_to_b64_nopad+0x23d>
cmpb   $0x0,0x28(%rsp)
je     12ed <bin_to_b64_nopad+0x1bd>
mov    0x10(%rsp),%rax
lea    (%rax,%rax,2),%eax
cltq
mov    0x18(%rsp),%rcx
mov    (%rcx,%rax,4),%ebx
mov    %ebx,%edi
shr    $0x2,%edi
and    $0x3f,%edi
call   1030 <code_to_char@plt>
mov    0x8(%rsp),%rbp
mov    %al,(%r15,%rbp,1)
shl    $0x4,%ebx
and    $0x30,%ebx
mov    %ebx,%edi
call   1030 <code_to_char@plt>
movslq %ebp,%rcx
or     $0x1,%rcx
mov    %al,(%r15,%rcx,1)
or     $0x2,%ebp
movslq %ebp,%rax
jmp    136d <bin_to_b64_nopad+0x23d>
cmpb   $0x0,0x24(%rsp)
mov    0x18(%rsp),%rcx
mov    0x10(%rsp),%rax
je     1387 <bin_to_b64_nopad+0x257>
lea    (%rax,%rax,2),%eax
cltq
mov    (%rcx,%rax,4),%edi
mov    0x4(%rcx,%rax,4),%ebp
mov    %edi,%eax
shl    $0x10,%eax
mov    %ebp,%ebx
shl    $0x8,%ebx
and    $0xf000,%ebx
or     %eax,%ebx
shr    $0x2,%edi
and    $0x3f,%edi
call   1030 <code_to_char@plt>
mov    0x8(%rsp),%r14
mov    %al,(%r15,%r14,1)
shr    $0xc,%ebx
and    $0x3f,%ebx
mov    %ebx,%edi
call   1030 <code_to_char@plt>
movslq %r14d,%rbx
mov    %rbx,%rcx
or     $0x1,%rcx
mov    %al,(%r15,%rcx,1)
shl    $0x2,%ebp
and    $0x3c,%ebp
mov    %ebp,%edi
call   1030 <code_to_char@plt>
mov    %rbx,%rcx
or     $0x2,%rcx
mov    %al,(%r15,%rcx,1)
or     $0x3,%ebx
movslq %ebx,%rax
add    %rax,%r15
mov    0x4(%rsp),%eax
movb   $0x0,(%r15)
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x4(%rsp),%eax
jmp    1378 <bin_to_b64_nopad+0x248>
mov    0x2c4c(%rip),%rax
mov    (%rax),%edi
lea    0xc63(%rip),%rsi
lea    0xc7e(%rip),%rdx
lea    0xd18(%rip),%r8
mov    $0x82,%ecx
call   1040 <fprintf@plt>
mov    0x2c1c(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [34 x i8] c"\0ACRITICAL file:%s line:%u msg:%s\0A\00"
@.str.1 = [161 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Ebiroll/qemu_esp32/refs/heads/master/examples/33_pkt_fwd/main/base64.c\00"
@.str.2 = [43 x i8] c"switch default that should not be possible\00"
@EXIT_FAILURE = global i32 0
define i32 @bin_to_b64_nopad(i32* %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store i32* %0, i32** %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i32 %3, i32* %9
%16 = load i8*, i8** %8
%17 = icmp eq i8* %16, null
br i1 %17, label %21, label %18
18: ; preds = %4
%19 = load i32*, i32** %6
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %22
21: ; preds = %18, %4
store i32 -1, i32* %5
br label %239
22: ; preds = %18
%23 = load i32, i32* %7
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = load i8*, i8** %8
store i8 0, i8* %26
store i32 0, i32* %5
br label %239
27: ; preds = %22
%28 = load i32, i32* %7
%29 = sdiv i32 %28, 3
store i32 %29, i32* %12
%30 = load i32, i32* %7
%31 = srem i32 %30, 3
store i32 %31, i32* %13
%32 = load i32, i32* %13
switch i32 %32, label %36 [
i32 0, label %33
i32 1, label %34
i32 2, label %35
]
33: ; preds = %27
store i32 0, i32* %14
br label %41
34: ; preds = %27
store i32 2, i32* %14
br label %41
35: ; preds = %27
store i32 3, i32* %14
br label %41
36: ; preds = %27
%37 = load i32, i32* @stderr
%38 = call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([161 x i8], [161 x i8]* @.str.1, i64 0, i64 0), i32 130, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
%39 = load i32, i32* @EXIT_FAILURE
%40 = call i32 @exit(i32 %39)
unreachable
41: ; preds = %35, %34, %33
%42 = load i32, i32* %12
%43 = mul nsw i32 4, %42
%44 = load i32, i32* %14
%45 = add nsw i32 %43, %44
store i32 %45, i32* %11
%46 = load i32, i32* %9
%47 = load i32, i32* %11
%48 = add nsw i32 %47, 1
%49 = icmp slt i32 %46, %48
br i1 %49, label %50, label %51
50: ; preds = %41
store i32 -1, i32* %5
br label %239
51: ; preds = %41
store i32 0, i32* %10
br label %52
52: ; preds = %125, %51
%53 = load i32, i32* %10
%54 = load i32, i32* %12
%55 = icmp slt i32 %53, %54
br i1 %55, label %56, label %128
56: ; preds = %52
%57 = load i32*, i32** %6
%58 = load i32, i32* %10
%59 = mul nsw i32 3, %58
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i32, i32* %57, i64 %60
%62 = load i32, i32* %61
%63 = and i32 255, %62
%64 = shl i32 %63, 16
store i32 %64, i32* %15
%65 = load i32*, i32** %6
%66 = load i32, i32* %10
%67 = mul nsw i32 3, %66
%68 = add nsw i32 %67, 1
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i32, i32* %65, i64 %69
%71 = load i32, i32* %70
%72 = and i32 255, %71
%73 = shl i32 %72, 8
%74 = load i32, i32* %15
%75 = or i32 %74, %73
store i32 %75, i32* %15
%76 = load i32*, i32** %6
%77 = load i32, i32* %10
%78 = mul nsw i32 3, %77
%79 = add nsw i32 %78, 2
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds i32, i32* %76, i64 %80
%82 = load i32, i32* %81
%83 = and i32 255, %82
%84 = load i32, i32* %15
%85 = or i32 %84, %83
store i32 %85, i32* %15
%86 = load i32, i32* %15
%87 = ashr i32 %86, 18
%88 = and i32 %87, 63
%89 = call signext i8 @code_to_char(i32 %88)
%90 = load i8*, i8** %8
%91 = load i32, i32* %10
%92 = mul nsw i32 4, %91
%93 = add nsw i32 %92, 0
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds i8, i8* %90, i64 %94
store i8 %89, i8* %95
%96 = load i32, i32* %15
%97 = ashr i32 %96, 12
%98 = and i32 %97, 63
%99 = call signext i8 @code_to_char(i32 %98)
%100 = load i8*, i8** %8
%101 = load i32, i32* %10
%102 = mul nsw i32 4, %101
%103 = add nsw i32 %102, 1
%104 = sext i32 %103 to i64
%105 = getelementptr inbounds i8, i8* %100, i64 %104
store i8 %99, i8* %105
%106 = load i32, i32* %15
%107 = ashr i32 %106, 6
%108 = and i32 %107, 63
%109 = call signext i8 @code_to_char(i32 %108)
%110 = load i8*, i8** %8
%111 = load i32, i32* %10
%112 = mul nsw i32 4, %111
%113 = add nsw i32 %112, 2
%114 = sext i32 %113 to i64
%115 = getelementptr inbounds i8, i8* %110, i64 %114
store i8 %109, i8* %115
%116 = load i32, i32* %15
%117 = and i32 %116, 63
%118 = call signext i8 @code_to_char(i32 %117)
%119 = load i8*, i8** %8
%120 = load i32, i32* %10
%121 = mul nsw i32 4, %120
%122 = add nsw i32 %121, 3
%123 = sext i32 %122 to i64
%124 = getelementptr inbounds i8, i8* %119, i64 %123
store i8 %118, i8* %124
br label %125
125: ; preds = %56
%126 = load i32, i32* %10
%127 = add nsw i32 %126, 1
store i32 %127, i32* %10
br label %52
128: ; preds = %52
%129 = load i32, i32* %12
store i32 %129, i32* %10
%130 = load i32, i32* %14
%131 = icmp eq i32 %130, 0
br i1 %131, label %132, label %138
132: ; preds = %128
%133 = load i8*, i8** %8
%134 = load i32, i32* %10
%135 = mul nsw i32 4, %134
%136 = sext i32 %135 to i64
%137 = getelementptr inbounds i8, i8* %133, i64 %136
store i8 0, i8* %137
br label %237
138: ; preds = %128
%139 = load i32, i32* %14
%140 = icmp eq i32 %139, 2
br i1 %140, label %141, label %176
141: ; preds = %138
%142 = load i32*, i32** %6
%143 = load i32, i32* %10
%144 = mul nsw i32 3, %143
%145 = sext i32 %144 to i64
%146 = getelementptr inbounds i32, i32* %142, i64 %145
%147 = load i32, i32* %146
%148 = and i32 255, %147
%149 = shl i32 %148, 16
store i32 %149, i32* %15
%150 = load i32, i32* %15
%151 = ashr i32 %150, 18
%152 = and i32 %151, 63
%153 = call signext i8 @code_to_char(i32 %152)
%154 = load i8*, i8** %8
%155 = load i32, i32* %10
%156 = mul nsw i32 4, %155
%157 = add nsw i32 %156, 0
%158 = sext i32 %157 to i64
%159 = getelementptr inbounds i8, i8* %154, i64 %158
store i8 %153, i8* %159
%160 = load i32, i32* %15
%161 = ashr i32 %160, 12
%162 = and i32 %161, 63
%163 = call signext i8 @code_to_char(i32 %162)
%164 = load i8*, i8** %8
%165 = load i32, i32* %10
%166 = mul nsw i32 4, %165
%167 = add nsw i32 %166, 1
%168 = sext i32 %167 to i64
%169 = getelementptr inbounds i8, i8* %164, i64 %168
store i8 %163, i8* %169
%170 = load i8*, i8** %8
%171 = load i32, i32* %10
%172 = mul nsw i32 4, %171
%173 = add nsw i32 %172, 2
%174 = sext i32 %173 to i64
%175 = getelementptr inbounds i8, i8* %170, i64 %174
store i8 0, i8* %175
br label %236
176: ; preds = %138
%177 = load i32, i32* %14
%178 = icmp eq i32 %177, 3
br i1 %178, label %179, label %235
179: ; preds = %176
%180 = load i32*, i32** %6
%181 = load i32, i32* %10
%182 = mul nsw i32 3, %181
%183 = sext i32 %182 to i64
%184 = getelementptr inbounds i32, i32* %180, i64 %183
%185 = load i32, i32* %184
%186 = and i32 255, %185
%187 = shl i32 %186, 16
store i32 %187, i32* %15
%188 = load i32*, i32** %6
%189 = load i32, i32* %10
%190 = mul nsw i32 3, %189
%191 = add nsw i32 %190, 1
%192 = sext i32 %191 to i64
%193 = getelementptr inbounds i32, i32* %188, i64 %192
%194 = load i32, i32* %193
%195 = and i32 255, %194
%196 = shl i32 %195, 8
%197 = load i32, i32* %15
%198 = or i32 %197, %196
store i32 %198, i32* %15
%199 = load i32, i32* %15
%200 = ashr i32 %199, 18
%201 = and i32 %200, 63
%202 = call signext i8 @code_to_char(i32 %201)
%203 = load i8*, i8** %8
%204 = load i32, i32* %10
%205 = mul nsw i32 4, %204
%206 = add nsw i32 %205, 0
%207 = sext i32 %206 to i64
%208 = getelementptr inbounds i8, i8* %203, i64 %207
store i8 %202, i8* %208
%209 = load i32, i32* %15
%210 = ashr i32 %209, 12
%211 = and i32 %210, 63
%212 = call signext i8 @code_to_char(i32 %211)
%213 = load i8*, i8** %8
%214 = load i32, i32* %10
%215 = mul nsw i32 4, %214
%216 = add nsw i32 %215, 1
%217 = sext i32 %216 to i64
%218 = getelementptr inbounds i8, i8* %213, i64 %217
store i8 %212, i8* %218
%219 = load i32, i32* %15
%220 = ashr i32 %219, 6
%221 = and i32 %220, 63
%222 = call signext i8 @code_to_char(i32 %221)
%223 = load i8*, i8** %8
%224 = load i32, i32* %10
%225 = mul nsw i32 4, %224
%226 = add nsw i32 %225, 2
%227 = sext i32 %226 to i64
%228 = getelementptr inbounds i8, i8* %223, i64 %227
store i8 %222, i8* %228
%229 = load i8*, i8** %8
%230 = load i32, i32* %10
%231 = mul nsw i32 4, %230
%232 = add nsw i32 %231, 3
%233 = sext i32 %232 to i64
%234 = getelementptr inbounds i8, i8* %229, i64 %233
store i8 0, i8* %234
br label %235
235: ; preds = %179, %176
br label %236
236: ; preds = %235, %141
br label %237
237: ; preds = %236, %132
%238 = load i32, i32* %11
store i32 %238, i32* %5
br label %239
239: ; preds = %237, %50, %25, %21
%240 = load i32, i32* %5
ret i32 %240
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [34 x i8] c"\0ACRITICAL file:%s line:%u msg:%s\0A\00"
@.str.1 = [161 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Ebiroll/qemu_esp32/refs/heads/master/examples/33_pkt_fwd/main/base64.c\00"
@.str.2 = [43 x i8] c"switch default that should not be possible\00"
@EXIT_FAILURE = global i32 0
define i32 @bin_to_b64_nopad(i32* %0, i32 %1, i8* writeonly %2, i32 %3) {
%5 = icmp eq i8* %2, null
%6 = icmp eq i32* %0, null
%7 = or i1 %6, %5
br i1 %7, label %132, label %8
8: ; preds = %4
%9 = icmp eq i32 %1, 0
br i1 %9, label %129, label %10
10: ; preds = %8
%11 = sdiv i32 %1, 3
%12 = srem i32 %1, 3
switch i32 %12, label %15 [
i32 0, label %20
i32 1, label %13
i32 2, label %14
]
13: ; preds = %10
br label %20
14: ; preds = %10
br label %20
15: ; preds = %10
%16 = load i32, i32* @stderr
%17 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([161 x i8], [161 x i8]* @.str.1, i64 0, i64 0), i32 130, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
%18 = load i32, i32* @EXIT_FAILURE
%19 = tail call i32 @exit(i32 %18)
unreachable
20: ; preds = %10, %14, %13
%21 = phi i1 [ false, %14 ], [ false, %13 ], [ true, %10 ]
%22 = phi i1 [ false, %14 ], [ true, %13 ], [ false, %10 ]
%23 = phi i1 [ true, %14 ], [ false, %13 ], [ false, %10 ]
%24 = phi i32 [ 3, %14 ], [ 2, %13 ], [ %12, %10 ]
%25 = shl nsw i32 %11, 2
%26 = or i32 %24, %25
%27 = icmp slt i32 %26, %3
br i1 %27, label %28, label %132
28: ; preds = %20
%29 = icmp sgt i32 %1, 2
br i1 %29, label %30, label %70
30: ; preds = %28
%31 = zext i32 %11 to i64
br label %32
32: ; preds = %30, %32
%33 = phi i64 [ 0, %30 ], [ %68, %32 ]
%34 = mul nuw nsw i64 %33, 3
%35 = getelementptr inbounds i32, i32* %0, i64 %34
%36 = load i32, i32* %35
%37 = shl i32 %36, 16
%38 = add nuw nsw i64 %34, 1
%39 = getelementptr inbounds i32, i32* %0, i64 %38
%40 = load i32, i32* %39
%41 = shl i32 %40, 8
%42 = and i32 %41, 61440
%43 = or i32 %42, %37
%44 = add nuw nsw i64 %34, 2
%45 = getelementptr inbounds i32, i32* %0, i64 %44
%46 = load i32, i32* %45
%47 = and i32 %46, 192
%48 = or i32 %47, %41
%49 = lshr i32 %37, 18
%50 = and i32 %49, 63
%51 = tail call signext i8 @code_to_char(i32 %50)
%52 = shl nsw i64 %33, 2
%53 = getelementptr inbounds i8, i8* %2, i64 %52
store i8 %51, i8* %53
%54 = lshr exact i32 %43, 12
%55 = and i32 %54, 63
%56 = tail call signext i8 @code_to_char(i32 %55)
%57 = or i64 %52, 1
%58 = getelementptr inbounds i8, i8* %2, i64 %57
store i8 %56, i8* %58
%59 = lshr exact i32 %48, 6
%60 = and i32 %59, 63
%61 = tail call signext i8 @code_to_char(i32 %60)
%62 = or i64 %52, 2
%63 = getelementptr inbounds i8, i8* %2, i64 %62
store i8 %61, i8* %63
%64 = and i32 %46, 63
%65 = tail call signext i8 @code_to_char(i32 %64)
%66 = or i64 %52, 3
%67 = getelementptr inbounds i8, i8* %2, i64 %66
store i8 %65, i8* %67
%68 = add nuw nsw i64 %33, 1
%69 = icmp eq i64 %68, %31
br i1 %69, label %70, label %32
70: ; preds = %32, %28
br i1 %21, label %71, label %74
71: ; preds = %70
%72 = sext i32 %25 to i64
%73 = getelementptr inbounds i8, i8* %2, i64 %72
br label %129
74: ; preds = %70
br i1 %22, label %75, label %95
75: ; preds = %74
%76 = mul nsw i32 %11, 3
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds i32, i32* %0, i64 %77
%79 = load i32, i32* %78
%80 = shl i32 %79, 16
%81 = lshr i32 %80, 18
%82 = and i32 %81, 63
%83 = tail call signext i8 @code_to_char(i32 %82)
%84 = sext i32 %25 to i64
%85 = getelementptr inbounds i8, i8* %2, i64 %84
store i8 %83, i8* %85
%86 = lshr exact i32 %80, 12
%87 = and i32 %86, 48
%88 = tail call signext i8 @code_to_char(i32 %87)
%89 = or i32 %25, 1
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds i8, i8* %2, i64 %90
store i8 %88, i8* %91
%92 = or i32 %25, 2
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds i8, i8* %2, i64 %93
br label %129
95: ; preds = %74
br i1 %23, label %96, label %132
96: ; preds = %95
%97 = mul nsw i32 %11, 3
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds i32, i32* %0, i64 %98
%100 = load i32, i32* %99
%101 = shl i32 %100, 16
%102 = add nsw i32 %97, 1
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds i32, i32* %0, i64 %103
%105 = load i32, i32* %104
%106 = shl i32 %105, 8
%107 = and i32 %106, 61440
%108 = or i32 %107, %101
%109 = lshr i32 %101, 18
%110 = and i32 %109, 63
%111 = tail call signext i8 @code_to_char(i32 %110)
%112 = sext i32 %25 to i64
%113 = getelementptr inbounds i8, i8* %2, i64 %112
store i8 %111, i8* %113
%114 = lshr exact i32 %108, 12
%115 = and i32 %114, 63
%116 = tail call signext i8 @code_to_char(i32 %115)
%117 = or i32 %25, 1
%118 = sext i32 %117 to i64
%119 = getelementptr inbounds i8, i8* %2, i64 %118
store i8 %116, i8* %119
%120 = lshr exact i32 %106, 6
%121 = and i32 %120, 60
%122 = tail call signext i8 @code_to_char(i32 %121)
%123 = or i32 %25, 2
%124 = sext i32 %123 to i64
%125 = getelementptr inbounds i8, i8* %2, i64 %124
store i8 %122, i8* %125
%126 = or i32 %25, 3
%127 = sext i32 %126 to i64
%128 = getelementptr inbounds i8, i8* %2, i64 %127
br label %129
129: ; preds = %8, %75, %96, %71
%130 = phi i8* [ %73, %71 ], [ %128, %96 ], [ %94, %75 ], [ %2, %8 ]
%131 = phi i32 [ %26, %71 ], [ %26, %96 ], [ %26, %75 ], [ 0, %8 ]
store i8 0, i8* %130
br label %132
132: ; preds = %129, %95, %20, %4
%133 = phi i32 [ -1, %4 ], [ -1, %20 ], [ %26, %95 ], [ %131, %129 ]
ret i32 %133
}