#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 get_hash_id(char const *);
int strlen(char const *);
int strspn(char const *, char const *);
int get_passwd_len(const char *password) {
  static const char *allowed_chars =
      "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./";
  int passwdlen = strlen(password);
  int hash_id = get_hash_id(password);
  if (passwdlen > 13 && (hash_id == 0 || hash_id == 1))
    passwdlen = 13 + strspn(password + 13, allowed_chars);
  if (passwdlen > 38 && (hash_id == 5 || hash_id == 6))
    passwdlen = 38 + strspn(password + 38, allowed_chars);
  return passwdlen;
}


x86 assembly (clang, -O0):
<get_passwd_len>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <get_hash_id@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0xd,-0xc(%rbp)
jle    118c <get_passwd_len+0x5c>
cmpl   $0x0,-0x10(%rbp)
je     1172 <get_passwd_len+0x42>
cmpl   $0x1,-0x10(%rbp)
jne    118c <get_passwd_len+0x5c>
mov    -0x8(%rbp),%rdi
add    $0xd,%rdi
mov    0x2eb7(%rip),%rsi
call   1040 <strspn@plt>
add    $0xd,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x26,-0xc(%rbp)
jle    11c4 <get_passwd_len+0x94>
cmpl   $0x5,-0x10(%rbp)
je     11aa <get_passwd_len+0x7a>
cmpl   $0x6,-0x10(%rbp)
jne    11c4 <get_passwd_len+0x94>
mov    -0x8(%rbp),%rdi
add    $0x26,%rdi
mov    0x2e7f(%rip),%rsi
call   1040 <strspn@plt>
add    $0x26,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_passwd_len>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1050 <get_hash_id@plt>
cmp    $0xe,%ebp
jl     115d <get_passwd_len+0x2d>
cmp    $0x2,%eax
jae    115d <get_passwd_len+0x2d>
mov    $0xd,%r14d
mov    $0xd,%eax
jmp    1175 <get_passwd_len+0x45>
cmp    $0x27,%ebp
jl     118c <get_passwd_len+0x5c>
add    $0xfffffffb,%eax
cmp    $0x1,%eax
ja     118c <get_passwd_len+0x5c>
mov    $0x26,%r14d
mov    $0x26,%eax
add    %rax,%rbx
lea    0xe81(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strspn@plt>
mov    %eax,%ebp
add    %r14d,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@get_passwd_len.allowed_chars = internal global i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i32 0, i32 0)
@.str = [65 x i8] c"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./\00"
define i32 @get_passwd_len(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 i8*, i8** %2
%8 = call i32 @get_hash_id(i8* %7)
store i32 %8, i32* %4
%9 = load i32, i32* %3
%10 = icmp sgt i32 %9, 13
br i1 %10, label %11, label %23
11: ; preds = %1
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %11
%15 = load i32, i32* %4
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %23
17: ; preds = %14, %11
%18 = load i8*, i8** %2
%19 = getelementptr inbounds i8, i8* %18, i64 13
%20 = load i8*, i8** @get_passwd_len.allowed_chars
%21 = call i32 @strspn(i8* %19, i8* %20)
%22 = add nsw i32 13, %21
store i32 %22, i32* %3
br label %23
23: ; preds = %17, %14, %1
%24 = load i32, i32* %3
%25 = icmp sgt i32 %24, 38
br i1 %25, label %26, label %38
26: ; preds = %23
%27 = load i32, i32* %4
%28 = icmp eq i32 %27, 5
br i1 %28, label %32, label %29
29: ; preds = %26
%30 = load i32, i32* %4
%31 = icmp eq i32 %30, 6
br i1 %31, label %32, label %38
32: ; preds = %29, %26
%33 = load i8*, i8** %2
%34 = getelementptr inbounds i8, i8* %33, i64 38
%35 = load i8*, i8** @get_passwd_len.allowed_chars
%36 = call i32 @strspn(i8* %34, i8* %35)
%37 = add nsw i32 38, %36
store i32 %37, i32* %3
br label %38
38: ; preds = %32, %29, %23
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
@.str = [65 x i8] c"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./\00"
define i32 @get_passwd_len(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = tail call i32 @get_hash_id(i8* %0)
%4 = icmp sgt i32 %2, 13
%5 = icmp ult i32 %3, 2
%6 = select i1 %4, i1 %5, i1 false
br i1 %6, label %12, label %7
7: ; preds = %1
%8 = icmp sgt i32 %2, 38
%9 = add i32 %3, -5
%10 = icmp ult i32 %9, 2
%11 = select i1 %8, i1 %10, i1 false
br i1 %11, label %12, label %18
12: ; preds = %7, %1
%13 = phi i64 [ 13, %1 ], [ 38, %7 ]
%14 = phi i32 [ 13, %1 ], [ 38, %7 ]
%15 = getelementptr inbounds i8, i8* %0, i64 %13
%16 = tail call i32 @strspn(i8* %15, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0))
%17 = add nsw i32 %16, %14
br label %18
18: ; preds = %12, %7
%19 = phi i32 [ %2, %7 ], [ %17, %12 ]
ret i32 %19
}