#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 */
typedef size_t ssize_t;

/* Variables and functions */
int /*<<< orphan*/ isgraph(char);
size_t strlen(char *);
char *config_trim_line(char *in) {
  ssize_t n;
  for (; *in && !isgraph(*in); in++) {
  }
  for (n = strlen(in); n >= 0 && !isgraph(in[n]); n--) {
    in[n] = 0;
  }
  return in;
}


x86 assembly (clang, -O0):
<config_trim_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x11(%rbp)
je     1158 <config_trim_line+0x38>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isgraph@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1168 <config_trim_line+0x48>
jmp    117e <config_trim_line+0x5e>
jmp    116d <config_trim_line+0x4d>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    112c <config_trim_line+0xc>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x10(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x10(%rbp)
mov    %al,-0x12(%rbp)
jb     11b7 <config_trim_line+0x97>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <isgraph@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x12(%rbp)
mov    -0x12(%rbp),%al
test   $0x1,%al
jne    11c7 <config_trim_line+0xa7>
jmp    11e4 <config_trim_line+0xc4>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
jmp    118b <config_trim_line+0x6b>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<config_trim_line>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    (%rdi),%al
test   %al,%al
je     1149 <config_trim_line+0x29>
nopl   (%rax)
movsbl %al,%edi
call   1040 <isgraph@plt>
test   %eax,%eax
jne    1149 <config_trim_line+0x29>
movzbl 0x1(%r14),%eax
add    $0x1,%r14
test   %al,%al
jne    1130 <config_trim_line+0x10>
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %rax,%rbx
movsbl (%r14,%rax,1),%edi
call   1040 <isgraph@plt>
test   %eax,%eax
jne    1184 <config_trim_line+0x64>
add    %r14,%rbx
cs nopw 0x0(%rax,%rax,1)
nop
movb   $0x0,(%rbx)
movsbl -0x1(%rbx),%edi
add    $0xffffffffffffffff,%rbx
call   1040 <isgraph@plt>
test   %eax,%eax
je     1170 <config_trim_line+0x50>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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