#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 /*<<< orphan*/ isalpha(char);
int lowercase_position(char);
int strlen(char *);
int uppercase_position(char);
int get_excel_col_number_from_col_name(char *s) {
  int col_num;
  int len, index;
  if (!s || !strlen(s)) {
    return (0);
  }
  len = strlen(s);
  for (index = 0; index < len; ++index) {
    if (!isalpha(s[index])) {
      return (0);
    }
  }
  col_num = 0;
  for (index = 0; index < len; ++index) {
    col_num = col_num * 26 + lowercase_position(s[index]) +
              uppercase_position(s[index]);
  }
  return (col_num);
}


x86 assembly (clang, -O0):
<get_excel_col_number_from_col_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1169 <get_excel_col_number_from_col_name+0x29>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%eax
jne    1175 <get_excel_col_number_from_col_name+0x35>
movl   $0x0,-0x4(%rbp)
jmp    1238 <get_excel_col_number_from_col_name+0xf8>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11cd <get_excel_col_number_from_col_name+0x8d>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1050 <isalpha@plt>
cmp    $0x0,%eax
jne    11ba <get_excel_col_number_from_col_name+0x7a>
movl   $0x0,-0x4(%rbp)
jmp    1238 <get_excel_col_number_from_col_name+0xf8>
jmp    11bf <get_excel_col_number_from_col_name+0x7f>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1188 <get_excel_col_number_from_col_name+0x48>
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1232 <get_excel_col_number_from_col_name+0xf2>
imul   $0x1a,-0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1060 <lowercase_position@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <uppercase_position@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11db <get_excel_col_number_from_col_name+0x9b>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_excel_col_number_from_col_name>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %ebx,%ebx
test   %rdi,%rdi
je     11d2 <get_excel_col_number_from_col_name+0x92>
mov    %rdi,%r14
call   1030 <strlen@plt>
test   %eax,%eax
je     11d2 <get_excel_col_number_from_col_name+0x92>
mov    %r14,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    11d2 <get_excel_col_number_from_col_name+0x92>
mov    %eax,%r12d
mov    %eax,%r15d
xor    %ebx,%ebx
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
movsbl (%r14,%rbp,1),%edi
call   1050 <isalpha@plt>
test   %eax,%eax
je     11d2 <get_excel_col_number_from_col_name+0x92>
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1180 <get_excel_col_number_from_col_name+0x40>
test   %r12d,%r12d
jle    11d2 <get_excel_col_number_from_col_name+0x92>
xor    %ebp,%ebp
xor    %ebx,%ebx
lea    (%rbx,%rbx,4),%eax
lea    (%rax,%rax,4),%r13d
add    %ebx,%r13d
movsbl (%r14,%rbp,1),%edi
call   1060 <lowercase_position@plt>
mov    %eax,%r12d
add    %r13d,%r12d
movsbl (%r14,%rbp,1),%edi
call   1040 <uppercase_position@plt>
mov    %eax,%ebx
add    %r12d,%ebx
add    $0x1,%rbp
cmp    %rbp,%r15
jne    11a0 <get_excel_col_number_from_col_name+0x60>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @get_excel_col_number_from_col_name(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %13
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = call i32 @strlen(i8* %10)
%12 = icmp ne i32 %11, 0
br i1 %12, label %14, label %13
13: ; preds = %9, %1
store i32 0, i32* %2
br label %61
14: ; preds = %9
%15 = load i8*, i8** %3
%16 = call i32 @strlen(i8* %15)
store i32 %16, i32* %5
store i32 0, i32* %6
br label %17
17: ; preds = %31, %14
%18 = load i32, i32* %6
%19 = load i32, i32* %5
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %34
21: ; preds = %17
%22 = load i8*, i8** %3
%23 = load i32, i32* %6
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = load i8, i8* %25
%27 = call i32 @isalpha(i8 signext %26)
%28 = icmp ne i32 %27, 0
br i1 %28, label %30, label %29
29: ; preds = %21
store i32 0, i32* %2
br label %61
30: ; preds = %21
br label %31
31: ; preds = %30
%32 = load i32, i32* %6
%33 = add nsw i32 %32, 1
store i32 %33, i32* %6
br label %17
34: ; preds = %17
store i32 0, i32* %4
store i32 0, i32* %6
br label %35
35: ; preds = %56, %34
%36 = load i32, i32* %6
%37 = load i32, i32* %5
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %59
39: ; preds = %35
%40 = load i32, i32* %4
%41 = mul nsw i32 %40, 26
%42 = load i8*, i8** %3
%43 = load i32, i32* %6
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %42, i64 %44
%46 = load i8, i8* %45
%47 = call i32 @lowercase_position(i8 signext %46)
%48 = add nsw i32 %41, %47
%49 = load i8*, i8** %3
%50 = load i32, i32* %6
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8, i8* %49, i64 %51
%53 = load i8, i8* %52
%54 = call i32 @uppercase_position(i8 signext %53)
%55 = add nsw i32 %48, %54
store i32 %55, i32* %4
br label %56
56: ; preds = %39
%57 = load i32, i32* %6
%58 = add nsw i32 %57, 1
store i32 %58, i32* %6
br label %35
59: ; preds = %35
%60 = load i32, i32* %4
store i32 %60, i32* %2
br label %61
61: ; preds = %59, %29, %13
%62 = load i32, i32* %2
ret i32 %62
}

LLVM IR (-O2):
define i32 @get_excel_col_number_from_col_name(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %36, label %3
3: ; preds = %1
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp eq i32 %4, 0
br i1 %5, label %36, label %6
6: ; preds = %3
%7 = tail call i32 @strlen(i8* %0)
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %36
9: ; preds = %6
%10 = zext i32 %7 to i64
br label %16
11: ; preds = %16
%12 = icmp eq i64 %22, %10
br i1 %12, label %13, label %16
13: ; preds = %11
br i1 %8, label %14, label %36
14: ; preds = %13
%15 = zext i32 %7 to i64
br label %23
16: ; preds = %9, %11
%17 = phi i64 [ 0, %9 ], [ %22, %11 ]
%18 = getelementptr inbounds i8, i8* %0, i64 %17
%19 = load i8, i8* %18
%20 = tail call i32 @isalpha(i8 signext %19)
%21 = icmp eq i32 %20, 0
%22 = add nuw nsw i64 %17, 1
br i1 %21, label %36, label %11
23: ; preds = %14, %23
%24 = phi i64 [ 0, %14 ], [ %34, %23 ]
%25 = phi i32 [ 0, %14 ], [ %33, %23 ]
%26 = mul nsw i32 %25, 26
%27 = getelementptr inbounds i8, i8* %0, i64 %24
%28 = load i8, i8* %27
%29 = tail call i32 @lowercase_position(i8 signext %28)
%30 = add nsw i32 %29, %26
%31 = load i8, i8* %27
%32 = tail call i32 @uppercase_position(i8 signext %31)
%33 = add nsw i32 %30, %32
%34 = add nuw nsw i64 %24, 1
%35 = icmp eq i64 %34, %15
br i1 %35, label %36, label %23
36: ; preds = %16, %23, %6, %13, %1, %3
%37 = phi i32 [ 0, %3 ], [ 0, %1 ], [ 0, %13 ], [ 0, %6 ], [ %33, %23 ], [ 0, %16 ]
ret i32 %37
}