#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__ isprint(unsigned char);
char *string_remove_control(char *input) {
  static char remove_control[256];
  char *ptr = remove_control;
  unsigned char ch;
  while (*input) {
    ch = *input;
    if (isprint(ch))
      *ptr++ = ch;
    input++;
  }
  *ptr = '\0';
  return remove_control;
}


x86 assembly (clang, -O0):
<string_remove_control>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0x2f1d(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     1175 <string_remove_control+0x65>
mov    -0x8(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x11(%rbp)
movzbl -0x11(%rbp),%edi
call   1030 <isprint@plt>
cmp    $0x0,%rax
je     1164 <string_remove_control+0x54>
mov    -0x11(%rbp),%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1127 <string_remove_control+0x17>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
lea    0x2ebd(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<string_remove_control>:
push   %rbp
push   %r14
push   %rbx
mov    (%rdi),%bpl
test   %bpl,%bpl
je     1153 <string_remove_control+0x43>
mov    %rdi,%rbx
add    $0x1,%rbx
lea    0x2f16(%rip),%r14
jmp    113c <string_remove_control+0x2c>
nopl   0x0(%rax)
movzbl (%rbx),%ebp
add    $0x1,%rbx
test   %bpl,%bpl
je     115a <string_remove_control+0x4a>
movzbl %bpl,%edi
call   1030 <isprint@plt>
test   %rax,%rax
je     1130 <string_remove_control+0x20>
mov    %bpl,(%r14)
add    $0x1,%r14
jmp    1130 <string_remove_control+0x20>
lea    0x2ee6(%rip),%r14
movb   $0x0,(%r14)
lea    0x2edb(%rip),%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@string_remove_control.remove_control = internal global [256 x i8] zeroinitializer
define i8* @string_remove_control(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8
store i8* %0, i8** %2
store i8* getelementptr inbounds ([256 x i8], [256 x i8]* @string_remove_control.remove_control, i64 0, i64 0), i8** %3
br label %5
5: ; preds = %19, %1
%6 = load i8*, i8** %2
%7 = load i8, i8* %6
%8 = icmp ne i8 %7, 0
br i1 %8, label %9, label %22
9: ; preds = %5
%10 = load i8*, i8** %2
%11 = load i8, i8* %10
store i8 %11, i8* %4
%12 = load i8, i8* %4
%13 = call i64 @isprint(i8 zeroext %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %9
%16 = load i8, i8* %4
%17 = load i8*, i8** %3
%18 = getelementptr inbounds i8, i8* %17, i32 1
store i8* %18, i8** %3
store i8 %16, i8* %17
br label %19
19: ; preds = %15, %9
%20 = load i8*, i8** %2
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %2
br label %5
22: ; preds = %5
%23 = load i8*, i8** %3
store i8 0, i8* %23
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @string_remove_control.remove_control, i64 0, i64 0)
}

LLVM IR (-O2):
@string_remove_control.remove_control = internal global [256 x i8] zeroinitializer
define i8* @string_remove_control(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %17, label %4
4: ; preds = %1, %12
%5 = phi i8 [ %15, %12 ], [ %2, %1 ]
%6 = phi i8* [ %14, %12 ], [ %0, %1 ]
%7 = phi i8* [ %13, %12 ], [ getelementptr inbounds ([256 x i8], [256 x i8]* @string_remove_control.remove_control, i64 0, i64 0), %1 ]
%8 = tail call i64 @isprint(i8 zeroext %5)
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %4
%11 = getelementptr inbounds i8, i8* %7, i64 1
store i8 %5, i8* %7
br label %12
12: ; preds = %10, %4
%13 = phi i8* [ %11, %10 ], [ %7, %4 ]
%14 = getelementptr inbounds i8, i8* %6, i64 1
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 0
br i1 %16, label %17, label %4
17: ; preds = %12, %1
%18 = phi i8* [ getelementptr inbounds ([256 x i8], [256 x i8]* @string_remove_control.remove_control, i64 0, i64 0), %1 ], [ %13, %12 ]
store i8 0, i8* %18
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @string_remove_control.remove_control, i64 0, i64 0)
}