#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 */
scalar_t__ calloc(size_t, int);
int /*<<< orphan*/ memcpy(char *, char const *, size_t);
void extract_trimmed_inchi(char **buf, const char *str, size_t slen) {
  size_t i;
  int c;
  *buf = NULL;
  for (i = 0; i < slen; i++) {
    c = (int)(unsigned char)str[i];
    if (c >= 'A' && c <= 'Z')
      continue;
    if (c >= 'a' && c <= 'z')
      continue;
    if (c >= '0' && c <= '9')
      continue;
    switch (c) {
    case '(':
    case ')':
    case '*':
    case '+':
    case ',':
    case '-':
    case '.':
    case '/':
    case ';':
    case '=':
    case '?':
    case '@':
      continue;
    default:
      break;
    }
    break;
  }
  *buf = (char *)calloc(i + 1, sizeof(char));
  memcpy(*buf, str, i);
  (*buf)[i] = '\0';
  return;
}


x86 assembly (clang, -O0):
<extract_trimmed_inchi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movq   $0x0,(%rax)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    121c <extract_trimmed_inchi+0xfc>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x41,-0x24(%rbp)
jl     117d <extract_trimmed_inchi+0x5d>
cmpl   $0x5a,-0x24(%rbp)
jg     117d <extract_trimmed_inchi+0x5d>
jmp    120b <extract_trimmed_inchi+0xeb>
cmpl   $0x61,-0x24(%rbp)
jl     1196 <extract_trimmed_inchi+0x76>
cmpl   $0x7a,-0x24(%rbp)
jg     1196 <extract_trimmed_inchi+0x76>
jmp    120b <extract_trimmed_inchi+0xeb>
cmpl   $0x30,-0x24(%rbp)
jl     11af <extract_trimmed_inchi+0x8f>
cmpl   $0x39,-0x24(%rbp)
jg     11af <extract_trimmed_inchi+0x8f>
jmp    120b <extract_trimmed_inchi+0xeb>
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
add    $0xffffffd8,%eax
sub    $0x8,%eax
jb     11fc <extract_trimmed_inchi+0xdc>
jmp    11c6 <extract_trimmed_inchi+0xa6>
mov    -0x28(%rbp),%eax
sub    $0x3b,%eax
je     11fc <extract_trimmed_inchi+0xdc>
jmp    11d7 <extract_trimmed_inchi+0xb7>
mov    -0x28(%rbp),%eax
sub    $0x3d,%eax
je     11fc <extract_trimmed_inchi+0xdc>
jmp    11e8 <extract_trimmed_inchi+0xc8>
mov    -0x28(%rbp),%eax
add    $0xffffffc1,%eax
sub    $0x1,%eax
ja     1201 <extract_trimmed_inchi+0xe1>
jmp    11fc <extract_trimmed_inchi+0xdc>
jmp    120b <extract_trimmed_inchi+0xeb>
jmp    1206 <extract_trimmed_inchi+0xe6>
jmp    121c <extract_trimmed_inchi+0xfc>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1147 <extract_trimmed_inchi+0x27>
mov    -0x20(%rbp),%rdi
add    $0x1,%rdi
mov    $0x1,%esi
call   1030 <calloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <memcpy@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0x20(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extract_trimmed_inchi>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
movq   $0x0,(%rdi)
xor    %ebx,%ebx
test   %rdx,%rdx
je     117b <extract_trimmed_inchi+0x5b>
mov    $0x35,%esi
jmp    1149 <extract_trimmed_inchi+0x29>
add    $0x1,%rbx
cmp    %rbx,%rdx
je     1178 <extract_trimmed_inchi+0x58>
movzbl (%r15,%rbx,1),%ecx
mov    %ecx,%eax
and    $0xdf,%al
add    $0xbf,%al
cmp    $0x1a,%al
jb     1140 <extract_trimmed_inchi+0x20>
lea    -0x30(%rcx),%eax
cmp    $0xa,%al
jb     1140 <extract_trimmed_inchi+0x20>
lea    -0x28(%rcx),%eax
cmp    $0x8,%al
jb     1140 <extract_trimmed_inchi+0x20>
add    $0xc5,%cl
cmp    $0x5,%cl
ja     117b <extract_trimmed_inchi+0x5b>
movzbl %cl,%eax
bt     %eax,%esi
jb     1140 <extract_trimmed_inchi+0x20>
jmp    117b <extract_trimmed_inchi+0x5b>
mov    %rdx,%rbx
lea    0x1(%rbx),%rdi
mov    $0x1,%esi
call   1030 <calloc@plt>
mov    %rax,(%r14)
mov    %rax,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1040 <memcpy@plt>
mov    (%r14),%rax
movb   $0x0,(%rax,%rbx,1)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @extract_trimmed_inchi(i8** %0, i8* %1, i64 %2) {
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
store i8** %0, i8*** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%9 = load i8**, i8*** %4
store i8* null, i8** %9
store i64 0, i64* %7
br label %10
10: ; preds = %45, %3
%11 = load i64, i64* %7
%12 = load i64, i64* %6
%13 = icmp ult i64 %11, %12
br i1 %13, label %14, label %48
14: ; preds = %10
%15 = load i8*, i8** %5
%16 = load i64, i64* %7
%17 = getelementptr inbounds i8, i8* %15, i64 %16
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
store i32 %19, i32* %8
%20 = load i32, i32* %8
%21 = icmp sge i32 %20, 65
br i1 %21, label %22, label %26
22: ; preds = %14
%23 = load i32, i32* %8
%24 = icmp sle i32 %23, 90
br i1 %24, label %25, label %26
25: ; preds = %22
br label %45
26: ; preds = %22, %14
%27 = load i32, i32* %8
%28 = icmp sge i32 %27, 97
br i1 %28, label %29, label %33
29: ; preds = %26
%30 = load i32, i32* %8
%31 = icmp sle i32 %30, 122
br i1 %31, label %32, label %33
32: ; preds = %29
br label %45
33: ; preds = %29, %26
%34 = load i32, i32* %8
%35 = icmp sge i32 %34, 48
br i1 %35, label %36, label %40
36: ; preds = %33
%37 = load i32, i32* %8
%38 = icmp sle i32 %37, 57
br i1 %38, label %39, label %40
39: ; preds = %36
br label %45
40: ; preds = %36, %33
%41 = load i32, i32* %8
switch i32 %41, label %43 [
i32 40, label %42
i32 41, label %42
i32 42, label %42
i32 43, label %42
i32 44, label %42
i32 45, label %42
i32 46, label %42
i32 47, label %42
i32 59, label %42
i32 61, label %42
i32 63, label %42
i32 64, label %42
]
42: ; preds = %40, %40, %40, %40, %40, %40, %40, %40, %40, %40, %40, %40
br label %45
43: ; preds = %40
br label %44
44: ; preds = %43
br label %48
45: ; preds = %42, %39, %32, %25
%46 = load i64, i64* %7
%47 = add i64 %46, 1
store i64 %47, i64* %7
br label %10
48: ; preds = %44, %10
%49 = load i64, i64* %7
%50 = add i64 %49, 1
%51 = call i64 @calloc(i64 %50, i32 1)
%52 = inttoptr i64 %51 to i8*
%53 = load i8**, i8*** %4
store i8* %52, i8** %53
%54 = load i8**, i8*** %4
%55 = load i8*, i8** %54
%56 = load i8*, i8** %5
%57 = load i64, i64* %7
%58 = call i32 @memcpy(i8* %55, i8* %56, i64 %57)
%59 = load i8**, i8*** %4
%60 = load i8*, i8** %59
%61 = load i64, i64* %7
%62 = getelementptr inbounds i8, i8* %60, i64 %61
store i8 0, i8* %62
ret void
}

LLVM IR (-O2):
define void @extract_trimmed_inchi(i8** nocapture %0, i8* %1, i64 %2) {
store i8* null, i8** %0
%4 = icmp eq i64 %2, 0
br i1 %4, label %19, label %5
5: ; preds = %3, %16
%6 = phi i64 [ %17, %16 ], [ 0, %3 ]
%7 = getelementptr inbounds i8, i8* %1, i64 %6
%8 = load i8, i8* %7
%9 = and i8 %8, -33
%10 = add i8 %9, -65
%11 = icmp ult i8 %10, 26
%12 = add i8 %8, -48
%13 = icmp ult i8 %12, 10
%14 = select i1 %11, i1 true, i1 %13
br i1 %14, label %16, label %15
15: ; preds = %5
switch i8 %8, label %19 [
i8 40, label %16
i8 41, label %16
i8 42, label %16
i8 43, label %16
i8 44, label %16
i8 45, label %16
i8 46, label %16
i8 47, label %16
i8 59, label %16
i8 61, label %16
i8 63, label %16
i8 64, label %16
]
16: ; preds = %15, %15, %15, %15, %15, %15, %15, %15, %15, %15, %15, %15, %5
%17 = add nuw i64 %6, 1
%18 = icmp eq i64 %17, %2
br i1 %18, label %19, label %5
19: ; preds = %16, %15, %3
%20 = phi i64 [ 0, %3 ], [ %6, %15 ], [ %2, %16 ]
%21 = add i64 %20, 1
%22 = tail call i64 @calloc(i64 %21, i32 1)
%23 = inttoptr i64 %22 to i8*
store i8* %23, i8** %0
%24 = tail call i32 @memcpy(i8* %23, i8* %1, i64 %20)
%25 = load i8*, i8** %0
%26 = getelementptr inbounds i8, i8* %25, i64 %20
store i8 0, i8* %26
ret void
}