int element_number_convert(const char *symbol) {
  char proper[3];
  char c;
  assert(symbol);
  assert(*symbol);
  c = symbol[0];
  if (isalpha(c)) {
    proper[0] = toupper(c);
    c = symbol[1];
    if (c && isalpha(c)) {
      proper[1] = tolower(c);
      proper[2] = '\0';
    } else {
      proper[1] = '\0';
    }
  } else {
    c = symbol[1];
    if (c && isalpha(c)) {
      proper[0] = c;
      proper[1] = '\0';
    } else {
      return 0;
    }
  }
  return element_number(proper);
}


x86 assembly (clang, -O0):
<element_number_convert>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1040 <assert@plt>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
mov    $0x0,%al
call   1040 <assert@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x14(%rbp)
movsbl -0x14(%rbp),%edi
call   1060 <isalpha@plt>
cmp    $0x0,%eax
je     11e3 <element_number_convert+0x93>
movsbl -0x14(%rbp),%edi
call   1030 <toupper@plt>
mov    %al,-0x13(%rbp)
mov    -0x10(%rbp),%rax
mov    0x1(%rax),%al
mov    %al,-0x14(%rbp)
movsbl -0x14(%rbp),%eax
cmp    $0x0,%eax
je     11da <element_number_convert+0x8a>
movsbl -0x14(%rbp),%edi
call   1060 <isalpha@plt>
cmp    $0x0,%eax
je     11da <element_number_convert+0x8a>
movsbl -0x14(%rbp),%edi
call   1050 <tolower@plt>
mov    %al,-0x12(%rbp)
movb   $0x0,-0x11(%rbp)
jmp    11de <element_number_convert+0x8e>
movb   $0x0,-0x12(%rbp)
jmp    122c <element_number_convert+0xdc>
mov    -0x10(%rbp),%rax
mov    0x1(%rax),%al
mov    %al,-0x14(%rbp)
movsbl -0x14(%rbp),%eax
cmp    $0x0,%eax
je     121b <element_number_convert+0xcb>
movsbl -0x14(%rbp),%edi
call   1060 <isalpha@plt>
cmp    $0x0,%eax
je     121b <element_number_convert+0xcb>
mov    -0x14(%rbp),%al
mov    %al,-0x13(%rbp)
movb   $0x0,-0x12(%rbp)
jmp    1227 <element_number_convert+0xd7>
movl   $0x0,-0x4(%rbp)
jmp    123a <element_number_convert+0xea>
jmp    122c <element_number_convert+0xdc>
lea    -0x13(%rbp),%rdi
mov    $0x0,%al
call   1070 <element_number@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<element_number_convert>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
xor    %r14d,%r14d
xor    %eax,%eax
call   1040 <assert@plt>
movsbl (%rbx),%edi
xor    %eax,%eax
call   1040 <assert@plt>
movsbl (%rbx),%ebp
mov    %ebp,%edi
call   1060 <isalpha@plt>
test   %eax,%eax
je     11b2 <element_number_convert+0x62>
mov    %ebp,%edi
call   1030 <toupper@plt>
mov    %al,0xd(%rsp)
movsbl 0x1(%rbx),%ebx
mov    $0x1,%ebp
test   %ebx,%ebx
je     11ce <element_number_convert+0x7e>
mov    %ebx,%edi
call   1060 <isalpha@plt>
test   %eax,%eax
je     11ce <element_number_convert+0x7e>
mov    %ebx,%edi
call   1050 <tolower@plt>
mov    %al,0xe(%rsp)
mov    $0x2,%ebp
jmp    11ce <element_number_convert+0x7e>
movsbl 0x1(%rbx),%ebx
test   %ebx,%ebx
je     11e2 <element_number_convert+0x92>
mov    %ebx,%edi
call   1060 <isalpha@plt>
test   %eax,%eax
je     11e2 <element_number_convert+0x92>
mov    %bl,0xd(%rsp)
mov    $0x1,%ebp
movb   $0x0,0xd(%rsp,%rbp,1)
lea    0xd(%rsp),%rdi
xor    %eax,%eax
call   1070 <element_number@plt>
mov    %eax,%r14d
mov    %r14d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @element_number_convert(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [3 x i8]
%5 = alloca i8
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i32 (i8*, ...) bitcast (i32 (...)* @assert to i32 (i8*, ...)*)(i8* %6)
%8 = load i8*, i8** %3
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %10)
%12 = load i8*, i8** %3
%13 = getelementptr inbounds i8, i8* %12, i64 0
%14 = load i8, i8* %13
store i8 %14, i8* %5
%15 = load i8, i8* %5
%16 = sext i8 %15 to i32
%17 = call i32 @isalpha(i32 %16)
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %46
19: ; preds = %1
%20 = load i8, i8* %5
%21 = sext i8 %20 to i32
%22 = call i32 @toupper(i32 %21)
%23 = trunc i32 %22 to i8
%24 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
store i8 %23, i8* %24
%25 = load i8*, i8** %3
%26 = getelementptr inbounds i8, i8* %25, i64 1
%27 = load i8, i8* %26
store i8 %27, i8* %5
%28 = load i8, i8* %5
%29 = sext i8 %28 to i32
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %43
31: ; preds = %19
%32 = load i8, i8* %5
%33 = sext i8 %32 to i32
%34 = call i32 @isalpha(i32 %33)
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %43
36: ; preds = %31
%37 = load i8, i8* %5
%38 = sext i8 %37 to i32
%39 = call i32 @tolower(i32 %38)
%40 = trunc i32 %39 to i8
%41 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 1
store i8 %40, i8* %41
%42 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 2
store i8 0, i8* %42
br label %45
43: ; preds = %31, %19
%44 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 1
store i8 0, i8* %44
br label %45
45: ; preds = %43, %36
br label %64
46: ; preds = %1
%47 = load i8*, i8** %3
%48 = getelementptr inbounds i8, i8* %47, i64 1
%49 = load i8, i8* %48
store i8 %49, i8* %5
%50 = load i8, i8* %5
%51 = sext i8 %50 to i32
%52 = icmp ne i32 %51, 0
br i1 %52, label %53, label %62
53: ; preds = %46
%54 = load i8, i8* %5
%55 = sext i8 %54 to i32
%56 = call i32 @isalpha(i32 %55)
%57 = icmp ne i32 %56, 0
br i1 %57, label %58, label %62
58: ; preds = %53
%59 = load i8, i8* %5
%60 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
store i8 %59, i8* %60
%61 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 1
store i8 0, i8* %61
br label %63
62: ; preds = %53, %46
store i32 0, i32* %2
br label %67
63: ; preds = %58
br label %64
64: ; preds = %63, %45
%65 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%66 = call i32 (i8*, ...) bitcast (i32 (...)* @element_number to i32 (i8*, ...)*)(i8* %65)
store i32 %66, i32* %2
br label %67
67: ; preds = %64, %62
%68 = load i32, i32* %2
ret i32 %68
}

LLVM IR (-O2):
define i32 @element_number_convert(i8* %0) {
%2 = alloca [3 x i8]
%3 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%4 = tail call i32 (i8*, ...) bitcast (i32 (...)* @assert to i32 (i8*, ...)*)(i8* %0)
%5 = load i8, i8* %0
%6 = sext i8 %5 to i32
%7 = tail call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %6)
%8 = load i8, i8* %0
%9 = sext i8 %8 to i32
%10 = tail call i32 @isalpha(i32 %9)
%11 = icmp eq i32 %10, 0
br i1 %11, label %26, label %12
12: ; preds = %1
%13 = tail call i32 @toupper(i32 %9)
%14 = trunc i32 %13 to i8
store i8 %14, i8* %3
%15 = getelementptr inbounds i8, i8* %0, i64 1
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i8 %16, 0
br i1 %18, label %35, label %19
19: ; preds = %12
%20 = tail call i32 @isalpha(i32 %17)
%21 = icmp eq i32 %20, 0
br i1 %21, label %35, label %22
22: ; preds = %19
%23 = tail call i32 @tolower(i32 %17)
%24 = trunc i32 %23 to i8
%25 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 1
store i8 %24, i8* %25
br label %35
26: ; preds = %1
%27 = getelementptr inbounds i8, i8* %0, i64 1
%28 = load i8, i8* %27
%29 = icmp eq i8 %28, 0
br i1 %29, label %39, label %30
30: ; preds = %26
%31 = sext i8 %28 to i32
%32 = tail call i32 @isalpha(i32 %31)
%33 = icmp eq i32 %32, 0
br i1 %33, label %39, label %34
34: ; preds = %30
store i8 %28, i8* %3
br label %35
35: ; preds = %12, %19, %22, %34
%36 = phi i64 [ 2, %22 ], [ 1, %34 ], [ 1, %19 ], [ 1, %12 ]
%37 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 %36
store i8 0, i8* %37
%38 = call i32 (i8*, ...) bitcast (i32 (...)* @element_number to i32 (i8*, ...)*)(i8* %3)
br label %39
39: ; preds = %26, %30, %35
%40 = phi i32 [ %38, %35 ], [ 0, %30 ], [ 0, %26 ]
ret i32 %40
}