#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__ isspace(unsigned char);
scalar_t__ strchr(char const *, char);
int strlen(char *);
char *normalize7bit_generic(char *str, const char *rm_chars) {
  char *p, *pe;
  for (p = str; *p && isspace(*(unsigned char *)p); p++)
    ;
  for (pe = p + strlen(p) - 1; pe > p && strchr(rm_chars, *pe); pe--)
    *pe = '\0';
  return p;
}


x86 assembly (clang, -O0):
<normalize7bit_generic>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x21(%rbp)
je     1173 <normalize7bit_generic+0x43>
mov    -0x18(%rbp),%rax
movzbl (%rax),%edi
call   1050 <isspace@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1183 <normalize7bit_generic+0x53>
jmp    1199 <normalize7bit_generic+0x69>
jmp    1188 <normalize7bit_generic+0x58>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1148 <normalize7bit_generic+0x18>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rcx
xor    %eax,%eax
cmp    -0x18(%rbp),%rcx
mov    %al,-0x31(%rbp)
jbe    11eb <normalize7bit_generic+0xbb>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rax
movsbl (%rax),%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    11fb <normalize7bit_generic+0xcb>
jmp    1213 <normalize7bit_generic+0xe3>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
jmp    11be <normalize7bit_generic+0x8e>
mov    -0x18(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<normalize7bit_generic>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    (%rdi),%al
test   %al,%al
je     116a <normalize7bit_generic+0x3a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl %al,%edi
call   1050 <isspace@plt>
test   %rax,%rax
je     116a <normalize7bit_generic+0x3a>
movzbl 0x1(%r15),%eax
add    $0x1,%r15
test   %al,%al
jne    1150 <normalize7bit_generic+0x20>
mov    %r15,%rdi
call   1030 <strlen@plt>
cltq
lea    (%r15,%rax,1),%rbx
add    $0xffffffffffffffff,%rbx
cmp    %r15,%rbx
jbe    11ac <normalize7bit_generic+0x7c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl (%rbx),%esi
mov    %r14,%rdi
call   1040 <strchr@plt>
test   %rax,%rax
je     11ac <normalize7bit_generic+0x7c>
movb   $0x0,(%rbx)
add    $0xffffffffffffffff,%rbx
cmp    %r15,%rbx
ja     1190 <normalize7bit_generic+0x60>
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @normalize7bit_generic(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
store i8* %7, i8** %5
br label %8
8: ; preds = %21, %2
%9 = load i8*, i8** %5
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %8
%14 = load i8*, i8** %5
%15 = load i8, i8* %14
%16 = call i64 @isspace(i8 zeroext %15)
%17 = icmp ne i64 %16, 0
br label %18
18: ; preds = %13, %8
%19 = phi i1 [ false, %8 ], [ %17, %13 ]
br i1 %19, label %20, label %24
20: ; preds = %18
br label %21
21: ; preds = %20
%22 = load i8*, i8** %5
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %5
br label %8
24: ; preds = %18
%25 = load i8*, i8** %5
%26 = load i8*, i8** %5
%27 = call i32 @strlen(i8* %26)
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %25, i64 %28
%30 = getelementptr inbounds i8, i8* %29, i64 -1
store i8* %30, i8** %6
br label %31
31: ; preds = %45, %24
%32 = load i8*, i8** %6
%33 = load i8*, i8** %5
%34 = icmp ugt i8* %32, %33
br i1 %34, label %35, label %41
35: ; preds = %31
%36 = load i8*, i8** %4
%37 = load i8*, i8** %6
%38 = load i8, i8* %37
%39 = call i64 @strchr(i8* %36, i8 signext %38)
%40 = icmp ne i64 %39, 0
br label %41
41: ; preds = %35, %31
%42 = phi i1 [ false, %31 ], [ %40, %35 ]
br i1 %42, label %43, label %48
43: ; preds = %41
%44 = load i8*, i8** %6
store i8 0, i8* %44
br label %45
45: ; preds = %43
%46 = load i8*, i8** %6
%47 = getelementptr inbounds i8, i8* %46, i32 -1
store i8* %47, i8** %6
br label %31
48: ; preds = %41
%49 = load i8*, i8** %5
ret i8* %49
}

LLVM IR (-O2):
define i8* @normalize7bit_generic(i8* %0, i8* %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %14, label %5
5: ; preds = %2, %10
%6 = phi i8 [ %12, %10 ], [ %3, %2 ]
%7 = phi i8* [ %11, %10 ], [ %0, %2 ]
%8 = tail call i64 @isspace(i8 zeroext %6)
%9 = icmp eq i64 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %5
%11 = getelementptr inbounds i8, i8* %7, i64 1
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 0
br i1 %13, label %14, label %5
14: ; preds = %5, %10, %2
%15 = phi i8* [ %0, %2 ], [ %11, %10 ], [ %7, %5 ]
%16 = tail call i32 @strlen(i8* %15)
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = getelementptr inbounds i8, i8* %18, i64 -1
%20 = icmp ugt i8* %19, %15
br i1 %20, label %21, label %29
21: ; preds = %14, %26
%22 = phi i8* [ %27, %26 ], [ %19, %14 ]
%23 = load i8, i8* %22
%24 = tail call i64 @strchr(i8* %1, i8 signext %23)
%25 = icmp eq i64 %24, 0
br i1 %25, label %29, label %26
26: ; preds = %21
store i8 0, i8* %22
%27 = getelementptr inbounds i8, i8* %22, i64 -1
%28 = icmp ugt i8* %27, %15
br i1 %28, label %21, label %29
29: ; preds = %21, %26, %14
ret i8* %15
}