#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 */
scalar_t__ contains(char const, char *, size_t);
size_t strlen(char const *);
int char_to_int(const char *str) {
  int buf;
  size_t i, len, mlen;
  buf = 0;
  len = strlen(str);
  mlen = strlen("0123456789"
                "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
                "."
                "-"
                "+");
  for (i = 0; i < len; i++)
    if (contains(str[i],
                 "0123456789"
                 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
                 "."
                 "-"
                 "+",
                 mlen))
      buf += (int)str[i];
  return buf;
}


x86 assembly (clang, -O0):
<char_to_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x20(%rbp)
movq   $0x41,-0x28(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    11ae <char_to_int+0x8e>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    -0x28(%rbp),%rdx
lea    0xe8c(%rip),%rsi
movsbl %al,%edi
call   1040 <contains@plt>
cmp    $0x0,%rax
je     1198 <char_to_int+0x78>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    119d <char_to_int+0x7d>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1150 <char_to_int+0x30>
mov    -0xc(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<char_to_int>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdi,%r13
call   1030 <strlen@plt>
test   %rax,%rax
je     117c <char_to_int+0x5c>
mov    %rax,%r15
xor    %r14d,%r14d
lea    0xebd(%rip),%r12
xor    %ebx,%ebx
jmp    1159 <char_to_int+0x39>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    %rbx,%r15
je     117f <char_to_int+0x5f>
movsbl 0x0(%r13,%rbx,1),%edi
mov    $0x41,%edx
mov    %r12,%rsi
call   1040 <contains@plt>
test   %rax,%rax
je     1150 <char_to_int+0x30>
movsbl 0x0(%r13,%rbx,1),%eax
add    %eax,%r14d
jmp    1150 <char_to_int+0x30>
xor    %r14d,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [66 x i8] c"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-+\00"
define i32 @char_to_int(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
store i8* %0, i8** %2
store i32 0, i32* %3
%7 = load i8*, i8** %2
%8 = call i64 @strlen(i8* %7)
store i64 %8, i64* %5
store i64 65, i64* %6
store i64 0, i64* %4
br label %9
9: ; preds = %30, %1
%10 = load i64, i64* %4
%11 = load i64, i64* %5
%12 = icmp ult i64 %10, %11
br i1 %12, label %13, label %33
13: ; preds = %9
%14 = load i8*, i8** %2
%15 = load i64, i64* %4
%16 = getelementptr inbounds i8, i8* %14, i64 %15
%17 = load i8, i8* %16
%18 = load i64, i64* %6
%19 = call i64 @contains(i8 signext %17, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0), i64 %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %29
21: ; preds = %13
%22 = load i8*, i8** %2
%23 = load i64, i64* %4
%24 = getelementptr inbounds i8, i8* %22, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = load i32, i32* %3
%28 = add nsw i32 %27, %26
store i32 %28, i32* %3
br label %29
29: ; preds = %21, %13
br label %30
30: ; preds = %29
%31 = load i64, i64* %4
%32 = add i64 %31, 1
store i64 %32, i64* %4
br label %9
33: ; preds = %9
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
@.str = [66 x i8] c"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-+\00"
define i32 @char_to_int(i8* nocapture %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %19, label %4
4: ; preds = %1, %15
%5 = phi i32 [ %16, %15 ], [ 0, %1 ]
%6 = phi i64 [ %17, %15 ], [ 0, %1 ]
%7 = getelementptr inbounds i8, i8* %0, i64 %6
%8 = load i8, i8* %7
%9 = tail call i64 @contains(i8 signext %8, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0), i64 65)
%10 = icmp eq i64 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %4
%12 = load i8, i8* %7
%13 = sext i8 %12 to i32
%14 = add nsw i32 %5, %13
br label %15
15: ; preds = %4, %11
%16 = phi i32 [ %14, %11 ], [ %5, %4 ]
%17 = add nuw i64 %6, 1
%18 = icmp eq i64 %17, %2
br i1 %18, label %19, label %4
19: ; preds = %15, %1
%20 = phi i32 [ 0, %1 ], [ %16, %15 ]
ret i32 %20
}