#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__ strchr(char *, char);
int strlen(char *);
void str_strip(char *s, char *stray) {
  char *s1;
  if (s[0] == '\0')
    return;
  s1 = s + strlen(s) - 1;
  while (s1 >= s && strchr(stray, *s1)) {
    *s1-- = '\0';
  }
}


x86 assembly (clang, -O0):
<str_strip>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1145 <str_strip+0x25>
jmp    11be <str_strip+0x9e>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rcx
xor    %eax,%eax
cmp    -0x8(%rbp),%rcx
mov    %al,-0x21(%rbp)
jb     1197 <str_strip+0x77>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
movsbl (%rax),%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    11a7 <str_strip+0x87>
jmp    11be <str_strip+0x9e>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x0,(%rax)
jmp    116a <str_strip+0x4a>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_strip>:
push   %r15
push   %r14
push   %rbx
cmpb   $0x0,(%rdi)
je     116c <str_strip+0x4c>
mov    %rsi,%r14
mov    %rdi,%r15
call   1030 <strlen@plt>
cltq
lea    (%r15,%rax,1),%rbx
add    $0xffffffffffffffff,%rbx
cmp    %r15,%rbx
jb     116c <str_strip+0x4c>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl (%rbx),%esi
mov    %r14,%rdi
call   1040 <strchr@plt>
test   %rax,%rax
je     116c <str_strip+0x4c>
movb   $0x0,(%rbx)
add    $0xffffffffffffffff,%rbx
cmp    %r15,%rbx
jae    1150 <str_strip+0x30>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @str_strip(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %3
%7 = getelementptr inbounds i8, i8* %6, i64 0
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %2
br label %34
12: ; preds = %2
%13 = load i8*, i8** %3
%14 = load i8*, i8** %3
%15 = call i32 @strlen(i8* %14)
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %13, i64 %16
%18 = getelementptr inbounds i8, i8* %17, i64 -1
store i8* %18, i8** %5
br label %19
19: ; preds = %31, %12
%20 = load i8*, i8** %5
%21 = load i8*, i8** %3
%22 = icmp uge i8* %20, %21
br i1 %22, label %23, label %29
23: ; preds = %19
%24 = load i8*, i8** %4
%25 = load i8*, i8** %5
%26 = load i8, i8* %25
%27 = call i64 @strchr(i8* %24, i8 signext %26)
%28 = icmp ne i64 %27, 0
br label %29
29: ; preds = %23, %19
%30 = phi i1 [ false, %19 ], [ %28, %23 ]
br i1 %30, label %31, label %34
31: ; preds = %29
%32 = load i8*, i8** %5
%33 = getelementptr inbounds i8, i8* %32, i32 -1
store i8* %33, i8** %5
store i8 0, i8* %32
br label %19
34: ; preds = %11, %29
ret void
}

LLVM IR (-O2):
define void @str_strip(i8* %0, i8* %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %19, label %5
5: ; preds = %2
%6 = tail call i32 @strlen(i8* %0)
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = getelementptr inbounds i8, i8* %8, i64 -1
%10 = icmp ult i8* %9, %0
br i1 %10, label %19, label %11
11: ; preds = %5, %16
%12 = phi i8* [ %17, %16 ], [ %9, %5 ]
%13 = load i8, i8* %12
%14 = tail call i64 @strchr(i8* %1, i8 signext %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %11
store i8 0, i8* %12
%17 = getelementptr inbounds i8, i8* %12, i64 -1
%18 = icmp ult i8* %17, %0
br i1 %18, label %19, label %11
19: ; preds = %16, %11, %5, %2
ret void
}