#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 strlen(char *);
char *rmbinary(char *line) {
  char *pt;
  for (pt = line; *pt; ++pt) {
    if ((*pt < ' ' || *pt >= 0x7f) && *pt != '\n') {
      if (strlen(pt) > 5) {
        pt[0] = '.';
        pt[1] = '.';
        pt[2] = '.';
        pt[3] = '\n';
        pt[4] = '\0';
      } else {
        pt[0] = '\n';
        pt[1] = '\0';
      }
      break;
    }
  }
  return (line);
}


x86 assembly (clang, -O0):
<rmbinary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     11c9 <rmbinary+0xb9>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jl     1151 <rmbinary+0x41>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7f,%eax
jl     11b3 <rmbinary+0xa3>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
je     11b3 <rmbinary+0xa3>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x5,%eax
jle    119f <rmbinary+0x8f>
mov    -0x10(%rbp),%rax
movb   $0x2e,(%rax)
mov    -0x10(%rbp),%rax
movb   $0x2e,0x1(%rax)
mov    -0x10(%rbp),%rax
movb   $0x2e,0x2(%rax)
mov    -0x10(%rbp),%rax
movb   $0xa,0x3(%rax)
mov    -0x10(%rbp),%rax
movb   $0x0,0x4(%rax)
jmp    11ae <rmbinary+0x9e>
mov    -0x10(%rbp),%rax
movb   $0xa,(%rax)
mov    -0x10(%rbp),%rax
movb   $0x0,0x1(%rax)
jmp    11c9 <rmbinary+0xb9>
jmp    11b8 <rmbinary+0xa8>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1124 <rmbinary+0x14>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rmbinary>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    (%rdi),%al
test   %al,%al
je     1174 <rmbinary+0x64>
mov    %r14,%rbx
jmp    113c <rmbinary+0x2c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1174 <rmbinary+0x64>
cmp    $0xa,%al
je     1130 <rmbinary+0x20>
add    $0xe0,%al
cmp    $0x5f,%al
jb     1130 <rmbinary+0x20>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    $0x1,%ecx
mov    %rbx,%rdx
cmp    $0x6,%eax
jl     116d <rmbinary+0x5d>
movw   $0x2e2e,(%rbx)
movb   $0x2e,0x2(%rbx)
lea    0x3(%rbx),%rdx
mov    $0x4,%ecx
movb   $0xa,(%rdx)
movb   $0x0,(%rbx,%rcx,1)
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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