#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 */
size_t strspn(char *, char *);
int read_tube_name(char **tubename, char *buf, char **end) {
  size_t len;
  while (buf[0] == ' ')
    buf++;
  len = strspn(buf, "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
                    "abcdefghijklmnopqrstuvwxyz"
                    "0123456789-+/;.$_()");
  if (len == 0)
    return -1;
  if (tubename)
    *tubename = buf;
  if (end)
    *end = buf + len;
  return 0;
}


x86 assembly (clang, -O0):
<read_tube_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    1145 <read_tube_name+0x35>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1124 <read_tube_name+0x14>
mov    -0x18(%rbp),%rdi
lea    0xeb0(%rip),%rsi
call   1030 <strspn@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1170 <read_tube_name+0x60>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a7 <read_tube_name+0x97>
cmpq   $0x0,-0x10(%rbp)
je     1186 <read_tube_name+0x76>
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
cmpq   $0x0,-0x20(%rbp)
je     11a0 <read_tube_name+0x90>
mov    -0x18(%rbp),%rcx
add    -0x28(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_tube_name>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
add    $0xffffffffffffffff,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmpb   $0x20,0x1(%rbx)
lea    0x1(%rbx),%rbx
je     1130 <read_tube_name+0x20>
lea    0xebf(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strspn@plt>
test   %rax,%rax
je     1168 <read_tube_name+0x58>
mov    %rax,%rcx
test   %r15,%r15
je     1159 <read_tube_name+0x49>
mov    %rbx,(%r15)
xor    %eax,%eax
test   %r14,%r14
je     116d <read_tube_name+0x5d>
add    %rcx,%rbx
mov    %rbx,(%r14)
jmp    116d <read_tube_name+0x5d>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [72 x i8] c"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-+/;.$_()\00"
define i32 @read_tube_name(i8** %0, i8* %1, i8** %2) {
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8**
%8 = alloca i64
store i8** %0, i8*** %5
store i8* %1, i8** %6
store i8** %2, i8*** %7
br label %9
9: ; preds = %15, %3
%10 = load i8*, i8** %6
%11 = getelementptr inbounds i8, i8* %10, i64 0
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 32
br i1 %14, label %15, label %18
15: ; preds = %9
%16 = load i8*, i8** %6
%17 = getelementptr inbounds i8, i8* %16, i32 1
store i8* %17, i8** %6
br label %9
18: ; preds = %9
%19 = load i8*, i8** %6
%20 = call i64 @strspn(i8* %19, i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str, i64 0, i64 0))
store i64 %20, i64* %8
%21 = load i64, i64* %8
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %18
store i32 -1, i32* %4
br label %39
24: ; preds = %18
%25 = load i8**, i8*** %5
%26 = icmp ne i8** %25, null
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = load i8*, i8** %6
%29 = load i8**, i8*** %5
store i8* %28, i8** %29
br label %30
30: ; preds = %27, %24
%31 = load i8**, i8*** %7
%32 = icmp ne i8** %31, null
br i1 %32, label %33, label %38
33: ; preds = %30
%34 = load i8*, i8** %6
%35 = load i64, i64* %8
%36 = getelementptr inbounds i8, i8* %34, i64 %35
%37 = load i8**, i8*** %7
store i8* %36, i8** %37
br label %38
38: ; preds = %33, %30
store i32 0, i32* %4
br label %39
39: ; preds = %38, %23
%40 = load i32, i32* %4
ret i32 %40
}

LLVM IR (-O2):
@.str = [72 x i8] c"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-+/;.$_()\00"
define i32 @read_tube_name(i8** writeonly %0, i8* %1, i8** writeonly %2) {
br label %4
4: ; preds = %4, %3
%5 = phi i8* [ %1, %3 ], [ %8, %4 ]
%6 = load i8, i8* %5
%7 = icmp eq i8 %6, 32
%8 = getelementptr inbounds i8, i8* %5, i64 1
br i1 %7, label %4, label %9
9: ; preds = %4
%10 = tail call i64 @strspn(i8* %5, i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %19, label %12
12: ; preds = %9
%13 = icmp eq i8** %0, null
br i1 %13, label %15, label %14
14: ; preds = %12
store i8* %5, i8** %0
br label %15
15: ; preds = %14, %12
%16 = icmp eq i8** %2, null
br i1 %16, label %19, label %17
17: ; preds = %15
%18 = getelementptr inbounds i8, i8* %5, i64 %10
store i8* %18, i8** %2
br label %19
19: ; preds = %15, %17, %9
%20 = phi i32 [ -1, %9 ], [ 0, %17 ], [ 0, %15 ]
ret i32 %20
}