#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 *);
int calcDecodeLength(const char *b64input) {
  int len = strlen(b64input);
  int padding = 0;
  if (b64input[len - 1] == '=' && b64input[len - 2] == '=')
    padding = 2;
  else if (b64input[len - 1] == '=')
    padding = 1;
  return (int)len * 0.75 - padding;
}


x86 assembly (clang, -O0):
<calcDecodeLength>:
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 <calcDecodeLength+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 <calcDecodeLength+0x5f>
movl   $0x2,-0x10(%rbp)
jmp    1195 <calcDecodeLength+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 <calcDecodeLength+0x80>
movl   $0x1,-0x10(%rbp)
jmp    1195 <calcDecodeLength+0x85>
cvtsi2sdl -0xc(%rbp),%xmm0
cvtsi2sdl -0x10(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xe42(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calcDecodeLength>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
movslq %eax,%rcx
xorpd  %xmm0,%xmm0
cmpb   $0x3d,-0x1(%rcx,%rbx,1)
jne    1140 <calcDecodeLength+0x30>
cmpb   $0x3d,-0x2(%rcx,%rbx,1)
jne    1138 <calcDecodeLength+0x28>
movsd  0xed2(%rip),%xmm0
jmp    1140 <calcDecodeLength+0x30>
movsd  0xec0(%rip),%xmm0
cvtsi2sd %eax,%xmm1
mulsd  0xec4(%rip),%xmm1
subsd  %xmm0,%xmm1
cvttsd2si %xmm1,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @calcDecodeLength(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 = sitofp i32 %37 to double
%39 = load i32, i32* %4
%40 = sitofp i32 %39 to double
%41 = fneg double %40
%42 = call double @llvm.fmuladd.f64(double %38, double 7.500000e-01, double %41)
%43 = fptosi double %42 to i32
ret i32 %43
}

LLVM IR (-O2):
define i32 @calcDecodeLength(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 = phi double [ 1.000000e+00, %8 ], [ 0.000000e+00, %1 ]
br label %16
16: ; preds = %14, %8
%17 = phi double [ 2.000000e+00, %8 ], [ %15, %14 ]
%18 = sitofp i32 %2 to double
%19 = fneg double %17
%20 = tail call double @llvm.fmuladd.f64(double %18, double 7.500000e-01, double %19)
%21 = fptosi double %20 to i32
ret i32 %21
}