#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*/ memmove(char *, char *, size_t);
char *strchr(char *, char);
size_t strlen(char *);
long long strtoll(char *, int /*<<< orphan*/ *, int);
long long numberise(char *str, int base) {
  char *p = str;
  size_t len = strlen(p);
  while ((p = strchr(p, '_')))
    memmove(p, p + 1, len - (size_t)(p - str));
  return strtoll(str, NULL, base);
}


x86 assembly (clang, -O0):
<numberise>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x5f,%esi
call   1040 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11a8 <numberise+0x68>
mov    -0x18(%rbp),%rdi
mov    -0x18(%rbp),%rsi
add    $0x1,%rsi
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
sub    %rax,%rdx
call   1060 <memmove@plt>
jmp    1164 <numberise+0x24>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1050 <strtoll@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<numberise>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%r15
mov    $0x5f,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1197 <numberise+0x57>
mov    %rax,%rbp
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %rax,%rbx
add    %r15,%rbx
nopl   (%rax)
lea    0x1(%rbp),%rsi
mov    %rbx,%rdx
sub    %rbp,%rdx
mov    %rbp,%rdi
call   1060 <memmove@plt>
mov    %rbp,%rdi
mov    $0x5f,%esi
call   1040 <strchr@plt>
mov    %rax,%rbp
test   %rax,%rax
jne    1170 <numberise+0x30>
mov    %r15,%rdi
xor    %esi,%esi
mov    %r14d,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <strtoll@plt>

LLVM IR (-O0):
define i64 @numberise(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = load i8*, i8** %3
store i8* %7, i8** %5
%8 = load i8*, i8** %5
%9 = call i64 @strlen(i8* %8)
store i64 %9, i64* %6
br label %10
10: ; preds = %14, %2
%11 = load i8*, i8** %5
%12 = call i8* @strchr(i8* %11, i8 signext 95)
store i8* %12, i8** %5
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %26
14: ; preds = %10
%15 = load i8*, i8** %5
%16 = load i8*, i8** %5
%17 = getelementptr inbounds i8, i8* %16, i64 1
%18 = load i64, i64* %6
%19 = load i8*, i8** %5
%20 = load i8*, i8** %3
%21 = ptrtoint i8* %19 to i64
%22 = ptrtoint i8* %20 to i64
%23 = sub i64 %21, %22
%24 = sub i64 %18, %23
%25 = call i32 @memmove(i8* %15, i8* %17, i64 %24)
br label %10
26: ; preds = %10
%27 = load i8*, i8** %3
%28 = load i32, i32* %4
%29 = call i64 @strtoll(i8* %27, i32* null, i32 %28)
ret i64 %29
}

LLVM IR (-O2):
define i64 @numberise(i8* %0, i32 %1) {
%3 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 95)
%4 = icmp eq i8* %3, null
br i1 %4, label %17, label %5
5: ; preds = %2
%6 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%7 = ptrtoint i8* %0 to i64
%8 = add i64 %6, %7
br label %9
9: ; preds = %5, %9
%10 = phi i8* [ %3, %5 ], [ %15, %9 ]
%11 = getelementptr inbounds i8, i8* %10, i64 1
%12 = ptrtoint i8* %10 to i64
%13 = sub i64 %8, %12
%14 = tail call i32 @memmove(i8* %10, i8* %11, i64 %13)
%15 = tail call i8* @strchr(i8* dereferenceable(1) %10, i8 signext 95)
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %9
17: ; preds = %9, %2
%18 = tail call i64 @strtoll(i8* nocapture %0, i32* null, i32 %1)
ret i64 %18
}