#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 >= 0; 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     1181 <HTS_name2num+0x61>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x39,%ecx
mov    %al,-0x11(%rbp)
jg     1181 <HTS_name2num+0x61>
cmpq   $0x0,-0x10(%rbp)
setae  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1191 <HTS_name2num+0x71>
jmp    11a7 <HTS_name2num+0x87>
jmp    1196 <HTS_name2num+0x76>
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 = %28, %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 %25
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 i1 %21, label %22, label %25
22: ; preds = %15
%23 = load i64, i64* %3
%24 = icmp uge i64 %23, 0
br label %25
25: ; preds = %22, %15, %8
%26 = phi i1 [ false, %15 ], [ false, %8 ], [ %24, %22 ]
br i1 %26, label %27, label %31
27: ; preds = %25
br label %28
28: ; preds = %27
%29 = load i64, i64* %3
%30 = add i64 %29, -1
store i64 %30, i64* %3
br label %8
31: ; preds = %25
%32 = load i64, i64* %3
%33 = add i64 %32, 1
store i64 %33, i64* %3
%34 = load i8*, i8** %2
%35 = load i64, i64* %3
%36 = getelementptr inbounds i8, i8* %34, i64 %35
%37 = call i32 @atoi(i8* %36)
%38 = sext i32 %37 to i64
ret i64 %38
}

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
}