#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 const *);
size_t decDataLength(const char *encdata) {
  int len = strlen(encdata);
  int padding = 0;
  if (encdata[len - 1] == '=' && encdata[len - 2] == '=')
    padding = 2;
  else if (encdata[len - 1] == '=')
    padding = 1;
  return (size_t)((len * 3) / 4) - padding;
}


x86 assembly (clang, -O0):
<decDataLength>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc(%rbp)
movl   $0x0,-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    116f <decDataLength+0x5f>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3d,%eax
jne    116f <decDataLength+0x5f>
movl   $0x2,-0x10(%rbp)
jmp    1195 <decDataLength+0x85>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3d,%eax
jne    1190 <decDataLength+0x80>
movl   $0x1,-0x10(%rbp)
jmp    1195 <decDataLength+0x85>
imul   $0x3,-0xc(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cltq
movslq -0x10(%rbp),%rcx
sub    %rcx,%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decDataLength>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
movslq %eax,%rsi
mov    -0x1(%rsi,%rbx,1),%dl
cmp    $0x3d,%dl
jne    1133 <decDataLength+0x23>
mov    $0xfffffffffffffffe,%rcx
cmpb   $0x3d,-0x2(%rsi,%rbx,1)
je     113e <decDataLength+0x2e>
xor    %ecx,%ecx
cmp    $0x3d,%dl
sete   %cl
neg    %rcx
lea    (%rax,%rax,2),%edx
lea    (%rax,%rax,2),%eax
add    $0x3,%eax
test   %edx,%edx
cmovns %edx,%eax
sar    $0x2,%eax
cltq
add    %rcx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i64 @decDataLength(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
store i32 0, i32* %4
%7 = load i8*, i8** %2
%8 = load i32, i32* %3
%9 = sub nsw i32 %8, 1
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %7, i64 %10
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 61
br i1 %14, label %15, label %25
15: ; preds = %1
%16 = load i8*, i8** %2
%17 = load i32, i32* %3
%18 = sub nsw i32 %17, 2
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %16, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 61
br i1 %23, label %24, label %25
24: ; preds = %15
store i32 2, i32* %4
br label %36
25: ; preds = %15, %1
%26 = load i8*, i8** %2
%27 = load i32, i32* %3
%28 = sub nsw i32 %27, 1
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %26, i64 %29
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 61
br i1 %33, label %34, label %35
34: ; preds = %25
store i32 1, i32* %4
br label %35
35: ; preds = %34, %25
br label %36
36: ; preds = %35, %24
%37 = load i32, i32* %3
%38 = mul nsw i32 %37, 3
%39 = sdiv i32 %38, 4
%40 = sext i32 %39 to i64
%41 = load i32, i32* %4
%42 = sext i32 %41 to i64
%43 = sub i64 %40, %42
ret i64 %43
}

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