#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__ skip_vt102_codes_non_graph(char *);
void strip_vt102_codes_non_graph(char *str, char *buf) {
  char *pti, *pto;
  pti = str;
  pto = buf;
  while (*pti) {
    while (skip_vt102_codes_non_graph(pti)) {
      pti += skip_vt102_codes_non_graph(pti);
    }
    if (*pti) {
      *pto++ = *pti++;
    }
  }
  *pto = 0;
}


x86 assembly (clang, -O0):
<strip_vt102_codes_non_graph>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     119f <strip_vt102_codes_non_graph+0x8f>
jmp    1142 <strip_vt102_codes_non_graph+0x32>
mov    -0x18(%rbp),%rdi
call   1030 <skip_vt102_codes_non_graph@plt>
cmp    $0x0,%rax
je     116b <strip_vt102_codes_non_graph+0x5b>
mov    -0x18(%rbp),%rdi
call   1030 <skip_vt102_codes_non_graph@plt>
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    1142 <strip_vt102_codes_non_graph+0x32>
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     119a <strip_vt102_codes_non_graph+0x8a>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
mov    (%rax),%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
jmp    1130 <strip_vt102_codes_non_graph+0x20>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strip_vt102_codes_non_graph>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
cmpb   $0x0,(%rdi)
je     1160 <strip_vt102_codes_non_graph+0x50>
mov    %rdi,%rbx
jmp    113b <strip_vt102_codes_non_graph+0x2b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <skip_vt102_codes_non_graph@plt>
add    %rax,%rbx
mov    %rbx,%rdi
call   1030 <skip_vt102_codes_non_graph@plt>
test   %rax,%rax
jne    1130 <strip_vt102_codes_non_graph+0x20>
movzbl (%rbx),%eax
test   %al,%al
je     1160 <strip_vt102_codes_non_graph+0x50>
mov    %al,(%r14)
add    $0x1,%r14
cmpb   $0x0,0x1(%rbx)
lea    0x1(%rbx),%rbx
jne    113b <strip_vt102_codes_non_graph+0x2b>
movb   $0x0,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @strip_vt102_codes_non_graph(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
%8 = load i8*, i8** %4
store i8* %8, i8** %6
br label %9
9: ; preds = %33, %2
%10 = load i8*, i8** %5
%11 = load i8, i8* %10
%12 = icmp ne i8 %11, 0
br i1 %12, label %13, label %34
13: ; preds = %9
br label %14
14: ; preds = %18, %13
%15 = load i8*, i8** %5
%16 = call i64 @skip_vt102_codes_non_graph(i8* %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %23
18: ; preds = %14
%19 = load i8*, i8** %5
%20 = call i64 @skip_vt102_codes_non_graph(i8* %19)
%21 = load i8*, i8** %5
%22 = getelementptr inbounds i8, i8* %21, i64 %20
store i8* %22, i8** %5
br label %14
23: ; preds = %14
%24 = load i8*, i8** %5
%25 = load i8, i8* %24
%26 = icmp ne i8 %25, 0
br i1 %26, label %27, label %33
27: ; preds = %23
%28 = load i8*, i8** %5
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %5
%30 = load i8, i8* %28
%31 = load i8*, i8** %6
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %6
store i8 %30, i8* %31
br label %33
33: ; preds = %27, %23
br label %9
34: ; preds = %9
%35 = load i8*, i8** %6
store i8 0, i8* %35
ret void
}

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