#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 uint32_t;

/* Variables and functions */
int /*<<< orphan*/ strlen(char const *);
uint32_t Base64DecodedLength(const char *EncodedString) {
  uint32_t length = (uint32_t)strlen(EncodedString);
  uint32_t result;
  if (length == 0) {
    result = 0;
  } else {
    result = length / 4 * 3;
    if (EncodedString[length - 1] == '=') {
      if (EncodedString[length - 2] == '=') {
        result--;
      }
      result--;
    }
  }
  return result;
}


x86 assembly (clang, -O0):
<Base64DecodedLength>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    113e <Base64DecodedLength+0x2e>
movl   $0x0,-0x10(%rbp)
jmp    119a <Base64DecodedLength+0x8a>
mov    -0xc(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
imul   $0x3,%eax,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3d,%eax
jne    1195 <Base64DecodedLength+0x85>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3d,%eax
jne    118c <Base64DecodedLength+0x7c>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    119a <Base64DecodedLength+0x8a>
mov    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Base64DecodedLength>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
test   %eax,%eax
je     1147 <Base64DecodedLength+0x37>
mov    %eax,%ecx
lea    0x3(%rcx),%eax
test   %ecx,%ecx
cmovns %ecx,%eax
sar    $0x2,%eax
lea    (%rax,%rax,2),%eax
movslq %ecx,%rcx
cmpb   $0x3d,-0x1(%rcx,%rbx,1)
jne    1145 <Base64DecodedLength+0x35>
xor    %edx,%edx
cmpb   $0x3d,-0x2(%rcx,%rbx,1)
sete   %dl
not    %edx
add    %edx,%eax
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret

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

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