#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*/ atoi(char const *);
int strlen(char const *);
size_t HTS_name2num(const char *buff) {
  size_t i;
  for (i = strlen(buff) - 1; '0' <= buff[i] && buff[i] <= '9'; i--)
    ;
  i++;
  return (size_t)atoi(&buff[i]);
}


x86 assembly (clang, -O0):
<HTS_name2num>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
cltq
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%edx
xor    %eax,%eax
mov    $0x30,%ecx
cmp    %edx,%ecx
mov    %al,-0x11(%rbp)
jg     1171 <HTS_name2num+0x51>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x39,%eax
setle  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1181 <HTS_name2num+0x61>
jmp    1197 <HTS_name2num+0x77>
jmp    1186 <HTS_name2num+0x66>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
jmp    113e <HTS_name2num+0x1e>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
add    -0x10(%rbp),%rdi
call   1040 <atoi@plt>
cltq
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HTS_name2num>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
cltq
lea    (%rax,%rbx,1),%rdi
add    $0x1,%rdi
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl -0x2(%rdi),%eax
add    $0xd0,%al
add    $0xffffffffffffffff,%rdi
cmp    $0xa,%al
jb     1140 <HTS_name2num+0x20>
call   1040 <atoi@plt>
cltq
pop    %rbx
ret

LLVM IR (-O0):
define i64 @HTS_name2num(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 @strlen(i8* %4)
%6 = sub nsw i32 %5, 1
%7 = sext i32 %6 to i64
store i64 %7, i64* %3
br label %8
8: ; preds = %25, %1
%9 = load i8*, i8** %2
%10 = load i64, i64* %3
%11 = getelementptr inbounds i8, i8* %9, i64 %10
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp sle i32 48, %13
br i1 %14, label %15, label %22
15: ; preds = %8
%16 = load i8*, i8** %2
%17 = load i64, i64* %3
%18 = getelementptr inbounds i8, i8* %16, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp sle i32 %20, 57
br label %22
22: ; preds = %15, %8
%23 = phi i1 [ false, %8 ], [ %21, %15 ]
br i1 %23, label %24, label %28
24: ; preds = %22
br label %25
25: ; preds = %24
%26 = load i64, i64* %3
%27 = add i64 %26, -1
store i64 %27, i64* %3
br label %8
28: ; preds = %22
%29 = load i64, i64* %3
%30 = add i64 %29, 1
store i64 %30, i64* %3
%31 = load i8*, i8** %2
%32 = load i64, i64* %3
%33 = getelementptr inbounds i8, i8* %31, i64 %32
%34 = call i32 @atoi(i8* %33)
%35 = sext i32 %34 to i64
ret i64 %35
}

LLVM IR (-O2):
define i64 @HTS_name2num(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = add nsw i32 %2, -1
%4 = sext i32 %3 to i64
br label %5
5: ; preds = %5, %1
%6 = phi i64 [ %4, %1 ], [ %11, %5 ]
%7 = getelementptr inbounds i8, i8* %0, i64 %6
%8 = load i8, i8* %7
%9 = add i8 %8, -48
%10 = icmp ult i8 %9, 10
%11 = add i64 %6, -1
br i1 %10, label %5, label %12
12: ; preds = %5
%13 = add i64 %6, 1
%14 = getelementptr inbounds i8, i8* %0, i64 %13
%15 = tail call i32 @atoi(i8* %14)
%16 = sext i32 %15 to i64
ret i64 %16
}