#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 */
size_t strlen(char const *);
size_t b64decsize_str(const char *s) {
  size_t len;
  size_t r;
  len = strlen(s);
  r = ((len + 3) / 4) * 3;
  if (s[len - 1] == '=') {
    r--;
  }
  if (s[len - 2] == '=') {
    r--;
  }
  return (r);
}


x86 assembly (clang, -O0):
<b64decsize_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x3,%rax
shr    $0x2,%rax
imul   $0x3,%rax,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    $0x1,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3d,%eax
jne    1162 <b64decsize_str+0x52>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    $0x2,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3d,%eax
jne    1187 <b64decsize_str+0x77>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<b64decsize_str>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
lea    0x3(%rax),%rcx
shr    $0x2,%rcx
xor    %edx,%edx
cmpb   $0x3d,-0x1(%rax,%rbx,1)
lea    (%rcx,%rcx,2),%rcx
sete   %dl
sub    %rdx,%rcx
xor    %edx,%edx
cmpb   $0x3d,-0x2(%rax,%rbx,1)
sete   %dl
sub    %rdx,%rcx
mov    %rcx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i64 @b64decsize_str(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i64
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i64 @strlen(i8* %5)
store i64 %6, i64* %3
%7 = load i64, i64* %3
%8 = add i64 %7, 3
%9 = udiv i64 %8, 4
%10 = mul i64 %9, 3
store i64 %10, i64* %4
%11 = load i8*, i8** %2
%12 = load i64, i64* %3
%13 = sub i64 %12, 1
%14 = getelementptr inbounds i8, i8* %11, i64 %13
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 61
br i1 %17, label %18, label %21
18: ; preds = %1
%19 = load i64, i64* %4
%20 = add i64 %19, -1
store i64 %20, i64* %4
br label %21
21: ; preds = %18, %1
%22 = load i8*, i8** %2
%23 = load i64, i64* %3
%24 = sub i64 %23, 2
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 61
br i1 %28, label %29, label %32
29: ; preds = %21
%30 = load i64, i64* %4
%31 = add i64 %30, -1
store i64 %31, i64* %4
br label %32
32: ; preds = %29, %21
%33 = load i64, i64* %4
ret i64 %33
}

LLVM IR (-O2):
define i64 @b64decsize_str(i8* nocapture %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = add i64 %2, 3
%4 = lshr i64 %3, 2
%5 = mul nuw i64 %4, 3
%6 = add i64 %2, -1
%7 = getelementptr inbounds i8, i8* %0, i64 %6
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 61
%10 = sext i1 %9 to i64
%11 = add i64 %5, %10
%12 = add i64 %2, -2
%13 = getelementptr inbounds i8, i8* %0, i64 %12
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 61
%16 = sext i1 %15 to i64
%17 = add i64 %11, %16
ret i64 %17
}