#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 strlen(char *);
int base64_decsize(char *src) {
  int slen, size, i;
  if (src == NULL) {
    return 0;
  }
  slen = strlen(src);
  size = slen / 4 * 3;
  for (i = 0; src[slen - i - 1] == '='; ++i)
    ;
  return size - (i >= 2 ? 2 : i);
}


x86 assembly (clang, -O0):
<base64_decsize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1133 <base64_decsize+0x23>
movl   $0x0,-0x4(%rbp)
jmp    11b5 <base64_decsize+0xa5>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
imul   $0x3,%eax,%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3d,%eax
jne    1187 <base64_decsize+0x77>
jmp    1179 <base64_decsize+0x69>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1157 <base64_decsize+0x47>
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x2,-0x1c(%rbp)
jl     11a4 <base64_decsize+0x94>
mov    $0x2,%eax
mov    %eax,-0x24(%rbp)
jmp    11aa <base64_decsize+0x9a>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x24(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<base64_decsize>:
test   %rdi,%rdi
je     1161 <base64_decsize+0x51>
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
lea    0x3(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
sar    $0x2,%ecx
add    $0xffffffff,%eax
mov    $0xffffffff,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movslq %eax,%rsi
add    $0x1,%edx
lea    -0x1(%rsi),%eax
cmpb   $0x3d,(%rbx,%rsi,1)
je     1140 <base64_decsize+0x30>
lea    (%rcx,%rcx,2),%eax
cmp    $0x2,%edx
mov    $0x2,%ecx
cmovb  %edx,%ecx
sub    %ecx,%eax
pop    %rbx
ret
xor    %eax,%eax
ret

LLVM IR (-O0):
define i32 @base64_decsize(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %10
9: ; preds = %1
store i32 0, i32* %2
br label %41
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = call i32 @strlen(i8* %11)
store i32 %12, i32* %4
%13 = load i32, i32* %4
%14 = sdiv i32 %13, 4
%15 = mul nsw i32 %14, 3
store i32 %15, i32* %5
store i32 0, i32* %6
br label %16
16: ; preds = %28, %10
%17 = load i8*, i8** %3
%18 = load i32, i32* %4
%19 = load i32, i32* %6
%20 = sub nsw i32 %18, %19
%21 = sub nsw i32 %20, 1
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %17, i64 %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 61
br i1 %26, label %27, label %31
27: ; preds = %16
br label %28
28: ; preds = %27
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 1
store i32 %30, i32* %6
br label %16
31: ; preds = %16
%32 = load i32, i32* %5
%33 = load i32, i32* %6
%34 = icmp sge i32 %33, 2
br i1 %34, label %35, label %36
35: ; preds = %31
br label %38
36: ; preds = %31
%37 = load i32, i32* %6
br label %38
38: ; preds = %36, %35
%39 = phi i32 [ 2, %35 ], [ %37, %36 ]
%40 = sub nsw i32 %32, %39
store i32 %40, i32* %2
br label %41
41: ; preds = %38, %9
%42 = load i32, i32* %2
ret i32 %42
}

LLVM IR (-O2):
define i32 @base64_decsize(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %22, label %3
3: ; preds = %1
%4 = tail call i32 @strlen(i8* %0)
%5 = sdiv i32 %4, 4
br label %6
6: ; preds = %6, %3
%7 = phi i64 [ %15, %6 ], [ 0, %3 ]
%8 = trunc i64 %7 to i32
%9 = xor i32 %8, -1
%10 = add i32 %4, %9
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 61
%15 = add nuw i64 %7, 1
br i1 %14, label %6, label %16
16: ; preds = %6
%17 = trunc i64 %7 to i32
%18 = mul nsw i32 %5, 3
%19 = icmp ult i32 %17, 2
%20 = select i1 %19, i32 %17, i32 2
%21 = sub nsw i32 %18, %20
br label %22
22: ; preds = %1, %16
%23 = phi i32 [ %21, %16 ], [ 0, %1 ]
ret i32 %23
}