#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 get_line(char *, int);
int /*<<< orphan*/ printf(char *, char *);
int remove_ch(char *, int);
int main(int argc, char *argv[]) {
  int len;
  char line[1000];
  while ((len = get_line(line, 1000)) > 0) {
    len = remove_ch(line, len);
    if (len > 0)
      printf("%s", line);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x400(%rbp),%rdi
mov    $0x3e8,%esi
call   1030 <get_line@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jle    119a <main+0x6a>
lea    -0x400(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <remove_ch@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    1195 <main+0x65>
lea    -0x400(%rbp),%rsi
lea    0xe70(%rip),%rdi
call   1040 <printf@plt>
jmp    1149 <main+0x19>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x3e8,%rsp
mov    %rsp,%rdi
mov    $0x3e8,%esi
call   1030 <get_line@plt>
test   %eax,%eax
jle    118c <main+0x5c>
mov    %rsp,%rbx
lea    0xeab(%rip),%r14
jmp    1171 <main+0x41>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x3e8,%esi
call   1030 <get_line@plt>
test   %eax,%eax
jle    118c <main+0x5c>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <remove_ch@plt>
test   %eax,%eax
jle    1160 <main+0x30>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
jmp    1160 <main+0x30>
xor    %eax,%eax
add    $0x3e8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [1000 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %8
8: ; preds = %21, %2
%9 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%10 = call i32 @get_line(i8* %9, i32 1000)
store i32 %10, i32* %6
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %22
12: ; preds = %8
%13 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%14 = load i32, i32* %6
%15 = call i32 @remove_ch(i8* %13, i32 %14)
store i32 %15, i32* %6
%16 = load i32, i32* %6
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %12
%19 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%20 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %19)
br label %21
21: ; preds = %18, %12
br label %8
22: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1000 x i8]
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%5 = call i32 @get_line(i8* %4, i32 1000)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %16
7: ; preds = %2, %13
%8 = phi i32 [ %14, %13 ], [ %5, %2 ]
%9 = call i32 @remove_ch(i8* %4, i32 %8)
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %4)
br label %13
13: ; preds = %11, %7
%14 = call i32 @get_line(i8* %4, i32 1000)
%15 = icmp sgt i32 %14, 0
br i1 %15, label %7, label %16
16: ; preds = %13, %2
ret i32 0
}