#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 int /*<<< orphan*/ FILE;

/* Variables and functions */
#define EOF 128
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ putchar(int);
void unbackspace(FILE *fp) {
  int c, last;
  if ((last = getc(fp)) == EOF)
    return;
  for (;;)
    switch (c = getc(fp)) {
    case '\b':
      last = getc(fp);
      continue;
    case EOF:
      return;
    default:
      putchar(last);
      last = c;
    }
}


x86 assembly (clang, -O0):
<unbackspace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <getc@plt>
mov    %eax,-0x10(%rbp)
cmp    $0x80,%eax
jne    1148 <unbackspace+0x28>
jmp    11a8 <unbackspace+0x88>
jmp    114d <unbackspace+0x2d>
mov    -0x8(%rbp),%rdi
call   1040 <getc@plt>
mov    %eax,-0xc(%rbp)
mov    %eax,%ecx
mov    %ecx,-0x14(%rbp)
sub    $0x8,%eax
je     117f <unbackspace+0x5f>
jmp    116c <unbackspace+0x4c>
mov    -0x14(%rbp),%eax
sub    $0x80,%eax
je     1190 <unbackspace+0x70>
jmp    1195 <unbackspace+0x75>
mov    -0x8(%rbp),%rdi
call   1040 <getc@plt>
mov    %eax,-0x10(%rbp)
jmp    114d <unbackspace+0x2d>
jmp    11a8 <unbackspace+0x88>
mov    -0x10(%rbp),%edi
call   1030 <putchar@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    114d <unbackspace+0x2d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unbackspace>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
call   1040 <getc@plt>
cmp    $0x80,%eax
jne    1148 <unbackspace+0x28>
pop    %rbx
pop    %r14
pop    %rbp
ret
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1040 <getc@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1040 <getc@plt>
cmp    $0x8,%eax
je     1140 <unbackspace+0x20>
mov    %eax,%ebp
cmp    $0x80,%eax
je     1133 <unbackspace+0x13>
mov    %ebx,%edi
call   1030 <putchar@plt>
mov    %ebp,%ebx
jmp    114a <unbackspace+0x2a>

LLVM IR (-O0):
define void @unbackspace(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
store i32* %0, i32** %2
%5 = load i32*, i32** %2
%6 = call i32 @getc(i32* %5)
store i32 %6, i32* %4
%7 = icmp eq i32 %6, 128
br i1 %7, label %8, label %9
8: ; preds = %1
br label %22
9: ; preds = %1
br label %10
10: ; preds = %21, %13, %9
%11 = load i32*, i32** %2
%12 = call i32 @getc(i32* %11)
store i32 %12, i32* %3
switch i32 %12, label %17 [
i32 8, label %13
i32 128, label %16
]
13: ; preds = %10
%14 = load i32*, i32** %2
%15 = call i32 @getc(i32* %14)
store i32 %15, i32* %4
br label %10
16: ; preds = %10
br label %22
17: ; preds = %10
%18 = load i32, i32* %4
%19 = call i32 @putchar(i32 %18)
%20 = load i32, i32* %3
store i32 %20, i32* %4
br label %21
21: ; preds = %17
br label %10
22: ; preds = %16, %8
ret void
}

LLVM IR (-O2):
define void @unbackspace(i32* nocapture %0) {
%2 = tail call i32 @getc(i32* %0)
%3 = icmp eq i32 %2, 128
br i1 %3, label %13, label %4
4: ; preds = %1, %9
%5 = phi i32 [ %10, %9 ], [ %2, %1 ]
%6 = tail call i32 @getc(i32* %0)
switch i32 %6, label %11 [
i32 8, label %7
i32 128, label %13
]
7: ; preds = %4
%8 = tail call i32 @getc(i32* %0)
br label %9
9: ; preds = %7, %11
%10 = phi i32 [ %6, %11 ], [ %8, %7 ]
br label %4
11: ; preds = %4
%12 = tail call i32 @putchar(i32 %5)
br label %9
13: ; preds = %4, %1
ret void
}