#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 */
unsigned int mz_base64_decode_step(char *, int, unsigned char *, int *,
                                   unsigned int *);
int strlen(char *);
unsigned char *mz_base64_decode_inplace(char *text, unsigned int *out_len) {
  int input_length, state = 0;
  unsigned int save = 0;
  if (!text)
    return NULL;
  if (!out_len)
    return NULL;
  input_length = strlen(text);
  if (input_length <= 1)
    return NULL;
  *out_len = mz_base64_decode_step(text, input_length, (unsigned char *)text,
                                   &state, &save);
  return (unsigned char *)text;
}


x86 assembly (clang, -O0):
<mz_base64_decode_inplace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1156 <mz_base64_decode_inplace+0x36>
movq   $0x0,-0x8(%rbp)
jmp    11b9 <mz_base64_decode_inplace+0x99>
cmpq   $0x0,-0x18(%rbp)
jne    116e <mz_base64_decode_inplace+0x4e>
movq   $0x0,-0x8(%rbp)
jmp    11b9 <mz_base64_decode_inplace+0x99>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jg     1191 <mz_base64_decode_inplace+0x71>
movq   $0x0,-0x8(%rbp)
jmp    11b9 <mz_base64_decode_inplace+0x99>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x10(%rbp),%rdx
lea    -0x20(%rbp),%rcx
lea    -0x24(%rbp),%r8
call   1040 <mz_base64_decode_step@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mz_base64_decode_inplace>:
push   %r14
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
movl   $0x0,(%rsp)
xor    %eax,%eax
test   %rdi,%rdi
je     116e <mz_base64_decode_inplace+0x4e>
mov    %rsi,%r14
test   %rsi,%rsi
je     116e <mz_base64_decode_inplace+0x4e>
mov    %rdi,%rbx
call   1030 <strlen@plt>
cmp    $0x2,%eax
jge    1153 <mz_base64_decode_inplace+0x33>
xor    %eax,%eax
jmp    116e <mz_base64_decode_inplace+0x4e>
lea    0x4(%rsp),%rcx
mov    %rsp,%r8
mov    %rbx,%rdi
mov    %eax,%esi
mov    %rbx,%rdx
call   1040 <mz_base64_decode_step@plt>
mov    %eax,(%r14)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @mz_base64_decode_inplace(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %4
store i32* %1, i32** %5
store i32 0, i32* %7
store i32 0, i32* %8
%9 = load i8*, i8** %4
%10 = icmp ne i8* %9, null
br i1 %10, label %12, label %11
11: ; preds = %2
store i8* null, i8** %3
br label %29
12: ; preds = %2
%13 = load i32*, i32** %5
%14 = icmp ne i32* %13, null
br i1 %14, label %16, label %15
15: ; preds = %12
store i8* null, i8** %3
br label %29
16: ; preds = %12
%17 = load i8*, i8** %4
%18 = call i32 @strlen(i8* %17)
store i32 %18, i32* %6
%19 = load i32, i32* %6
%20 = icmp sle i32 %19, 1
br i1 %20, label %21, label %22
21: ; preds = %16
store i8* null, i8** %3
br label %29
22: ; preds = %16
%23 = load i8*, i8** %4
%24 = load i32, i32* %6
%25 = load i8*, i8** %4
%26 = call i32 @mz_base64_decode_step(i8* %23, i32 %24, i8* %25, i32* %7, i32* %8)
%27 = load i32*, i32** %5
store i32 %26, i32* %27
%28 = load i8*, i8** %4
store i8* %28, i8** %3
br label %29
29: ; preds = %22, %21, %15, %11
%30 = load i8*, i8** %3
ret i8* %30
}

LLVM IR (-O2):
define i8* @mz_base64_decode_inplace(i8* %0, i32* writeonly %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%6 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%7 = icmp eq i8* %0, null
%8 = icmp eq i32* %1, null
%9 = or i1 %7, %8
br i1 %9, label %15, label %10
10: ; preds = %2
%11 = tail call i32 @strlen(i8* %0)
%12 = icmp slt i32 %11, 2
br i1 %12, label %15, label %13
13: ; preds = %10
%14 = call i32 @mz_base64_decode_step(i8* %0, i32 %11, i8* %0, i32* %3, i32* %4)
store i32 %14, i32* %1
br label %15
15: ; preds = %10, %2, %13
%16 = phi i8* [ %0, %13 ], [ null, %2 ], [ null, %10 ]
ret i8* %16
}