#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*/ isalnum(char);
int strlen(char *);
void strip(char *b) {
  while (!isalnum(b[0]) && strlen(b)) {
    int ll = strlen(b);
    for (int l = 0; l < ll - 1; l++) {
      b[l] = b[l + 1];
    }
  }
  while (!isalnum(b[strlen(b) - 1]) && strlen(b))
    b[strlen(b) - 1] = 0;
}


x86 assembly (clang, -O0):
<strip>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isalnum@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x11(%rbp)
jne    115a <strip+0x3a>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%eax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    116a <strip+0x4a>
jmp    11bc <strip+0x9c>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11b7 <strip+0x97>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    117d <strip+0x5d>
jmp    112c <strip+0xc>
jmp    11c1 <strip+0xa1>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <isalnum@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x12(%rbp)
jne    1209 <strip+0xe9>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%eax
setne  %al
mov    %al,-0x12(%rbp)
mov    -0x12(%rbp),%al
test   $0x1,%al
jne    1219 <strip+0xf9>
jmp    123f <strip+0x11f>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    11c1 <strip+0xa1>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strip>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
movsbl (%rdi),%edi
call   1040 <isalnum@plt>
test   %eax,%eax
jne    11ab <strip+0x7b>
lea    0x1(%rbx),%r14
jmp    115c <strip+0x2c>
nopl   0x0(%rax)
movsbl (%rbx),%edi
call   1040 <isalnum@plt>
test   %eax,%eax
jne    11ab <strip+0x7b>
mov    %rbx,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
je     11ab <strip+0x7b>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    $0x2,%eax
jl     1150 <strip+0x20>
add    $0xffffffff,%eax
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rax,%rdx
call   1050 <memmove@plt>
jmp    1150 <strip+0x20>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
je     11c3 <strip+0x93>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
movsbl -0x1(%rax,%rbx,1),%edi
call   1040 <isalnum@plt>
test   %eax,%eax
je     1190 <strip+0x60>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define void @strip(i8* %0) {
%2 = load i8, i8* %0
%3 = tail call i32 @isalnum(i8 signext %2)
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %20
5: ; preds = %1
%6 = getelementptr i8, i8* %0, i64 1
br label %11
7: ; preds = %17, %14
%8 = load i8, i8* %0
%9 = tail call i32 @isalnum(i8 signext %8)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %20
11: ; preds = %5, %7
%12 = tail call i32 @strlen(i8* %0)
%13 = icmp eq i32 %12, 0
br i1 %13, label %20, label %14
14: ; preds = %11
%15 = tail call i32 @strlen(i8* %0)
%16 = icmp sgt i32 %15, 1
br i1 %16, label %17, label %7
17: ; preds = %14
%18 = add nsw i32 %15, -1
%19 = zext i32 %18 to i64
br label %7
20: ; preds = %11, %7, %1
%21 = tail call i32 @strlen(i8* %0)
%22 = add nsw i32 %21, -1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %0, i64 %23
%25 = load i8, i8* %24
%26 = tail call i32 @isalnum(i8 signext %25)
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %43
28: ; preds = %20, %31
%29 = tail call i32 @strlen(i8* %0)
%30 = icmp eq i32 %29, 0
br i1 %30, label %43, label %31
31: ; preds = %28
%32 = tail call i32 @strlen(i8* %0)
%33 = add nsw i32 %32, -1
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %0, i64 %34
store i8 0, i8* %35
%36 = tail call i32 @strlen(i8* %0)
%37 = add nsw i32 %36, -1
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %0, i64 %38
%40 = load i8, i8* %39
%41 = tail call i32 @isalnum(i8 signext %40)
%42 = icmp eq i32 %41, 0
br i1 %42, label %28, label %43
43: ; preds = %28, %31, %20
ret void
}