#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 xfunc_in();
int /*<<< orphan*/ xputc(char);
int get_line(char *buff, int len) {
  int c, i;
  i = 0;
  for (;;) {
    c = xfunc_in();
    if (!c)
      return 0;
    if (c == '\r')
      break;
    if (c == '\b' && i) {
      i--;
      if (1)
        xputc(c);
      xputc(' ');
      xputc(c);
      continue;
    }
    if (c >= ' ' && i < len - 1) {
      buff[i++] = c;
      if (1)
        xputc(c);
    }
  }
  buff[i] = 0;
  if (1)
    xputc('\n');
  return 1;
}


x86 assembly (clang, -O0):
<get_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    $0x0,%al
call   1030 <xfunc_in@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    1156 <get_line+0x36>
movl   $0x0,-0x4(%rbp)
jmp    1209 <get_line+0xe9>
cmpl   $0xd,-0x18(%rbp)
jne    1165 <get_line+0x45>
jmp    11ec <get_line+0xcc>
cmpl   $0x8,-0x18(%rbp)
jne    11a7 <get_line+0x87>
cmpl   $0x0,-0x1c(%rbp)
je     11a7 <get_line+0x87>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
movsbl %al,%edi
call   1040 <xputc@plt>
mov    $0x20,%edi
call   1040 <xputc@plt>
mov    -0x18(%rbp),%eax
movsbl %al,%edi
call   1040 <xputc@plt>
jmp    1136 <get_line+0x16>
cmpl   $0x20,-0x18(%rbp)
jl     11e7 <get_line+0xc7>
mov    -0x1c(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11e7 <get_line+0xc7>
mov    -0x18(%rbp),%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x1c(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
movsbl %al,%edi
call   1040 <xputc@plt>
jmp    1136 <get_line+0x16>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    $0xa,%edi
call   1040 <xputc@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_line>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %rdi,%r14
add    $0xffffffff,%ebp
xor    %ebx,%ebx
xchg   %ax,%ax
xor    %eax,%eax
call   1030 <xfunc_in@plt>
test   %eax,%eax
je     1198 <get_line+0x78>
cmp    $0xd,%eax
je     1181 <get_line+0x61>
cmp    $0x8,%eax
jne    1149 <get_line+0x29>
test   %ebx,%ebx
jne    115e <get_line+0x3e>
cmp    $0x20,%eax
jl     1130 <get_line+0x10>
cmp    %ebp,%ebx
jge    1130 <get_line+0x10>
movslq %ebx,%rcx
add    $0x1,%ebx
mov    %al,(%r14,%rcx,1)
jmp    1177 <get_line+0x57>
add    $0xffffffff,%ebx
mov    $0x8,%edi
call   1040 <xputc@plt>
mov    $0x20,%edi
call   1040 <xputc@plt>
mov    $0x8,%al
movsbl %al,%edi
call   1040 <xputc@plt>
jmp    1130 <get_line+0x10>
movslq %ebx,%rax
movb   $0x0,(%r14,%rax,1)
mov    $0xa,%edi
call   1040 <xputc@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @get_line(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 0, i32* %7
br label %8
8: ; preds = %52, %23, %2
%9 = call i32 (...) @xfunc_in()
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = icmp ne i32 %10, 0
br i1 %11, label %13, label %12
12: ; preds = %8
store i32 0, i32* %3
br label %59
13: ; preds = %8
%14 = load i32, i32* %6
%15 = icmp eq i32 %14, 13
br i1 %15, label %16, label %17
16: ; preds = %13
br label %53
17: ; preds = %13
%18 = load i32, i32* %6
%19 = icmp eq i32 %18, 8
br i1 %19, label %20, label %33
20: ; preds = %17
%21 = load i32, i32* %7
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %33
23: ; preds = %20
%24 = load i32, i32* %7
%25 = add nsw i32 %24, -1
store i32 %25, i32* %7
%26 = load i32, i32* %6
%27 = trunc i32 %26 to i8
%28 = call i32 @xputc(i8 signext %27)
%29 = call i32 @xputc(i8 signext 32)
%30 = load i32, i32* %6
%31 = trunc i32 %30 to i8
%32 = call i32 @xputc(i8 signext %31)
br label %8
33: ; preds = %20, %17
%34 = load i32, i32* %6
%35 = icmp sge i32 %34, 32
br i1 %35, label %36, label %52
36: ; preds = %33
%37 = load i32, i32* %7
%38 = load i32, i32* %5
%39 = sub nsw i32 %38, 1
%40 = icmp slt i32 %37, %39
br i1 %40, label %41, label %52
41: ; preds = %36
%42 = load i32, i32* %6
%43 = trunc i32 %42 to i8
%44 = load i8*, i8** %4
%45 = load i32, i32* %7
%46 = add nsw i32 %45, 1
store i32 %46, i32* %7
%47 = sext i32 %45 to i64
%48 = getelementptr inbounds i8, i8* %44, i64 %47
store i8 %43, i8* %48
%49 = load i32, i32* %6
%50 = trunc i32 %49 to i8
%51 = call i32 @xputc(i8 signext %50)
br label %52
52: ; preds = %41, %36, %33
br label %8
53: ; preds = %16
%54 = load i8*, i8** %4
%55 = load i32, i32* %7
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8, i8* %54, i64 %56
store i8 0, i8* %57
%58 = call i32 @xputc(i8 signext 10)
store i32 1, i32* %3
br label %59
59: ; preds = %53, %12
%60 = load i32, i32* %3
ret i32 %60
}

LLVM IR (-O2):
define i32 @get_line(i8* nocapture writeonly %0, i32 %1) {
%3 = add nsw i32 %1, -1
br label %4
4: ; preds = %17, %2
%5 = phi i32 [ %19, %17 ], [ 0, %2 ]
%6 = icmp ne i32 %5, 0
%7 = icmp slt i32 %5, %3
br label %8
8: ; preds = %4, %21
%9 = tail call i32 (...) @xfunc_in()
switch i32 %9, label %10 [
i32 0, label %33
i32 13, label %29
]
10: ; preds = %8
%11 = icmp eq i32 %9, 8
%12 = select i1 %11, i1 %6, i1 false
br i1 %12, label %13, label %21
13: ; preds = %10
%14 = add nsw i32 %5, -1
%15 = tail call i32 @xputc(i8 signext 8)
%16 = tail call i32 @xputc(i8 signext 32)
br label %17
17: ; preds = %13, %24
%18 = phi i8 [ %25, %24 ], [ 8, %13 ]
%19 = phi i32 [ %26, %24 ], [ %14, %13 ]
%20 = tail call i32 @xputc(i8 signext %18)
br label %4
21: ; preds = %10
%22 = icmp sgt i32 %9, 31
%23 = select i1 %22, i1 %7, i1 false
br i1 %23, label %24, label %8
24: ; preds = %21
%25 = trunc i32 %9 to i8
%26 = add nsw i32 %5, 1
%27 = sext i32 %5 to i64
%28 = getelementptr inbounds i8, i8* %0, i64 %27
store i8 %25, i8* %28
br label %17
29: ; preds = %8
%30 = sext i32 %5 to i64
%31 = getelementptr inbounds i8, i8* %0, i64 %30
store i8 0, i8* %31
%32 = tail call i32 @xputc(i8 signext 10)
br label %33
33: ; preds = %8, %29
%34 = phi i32 [ 1, %29 ], [ %9, %8 ]
ret i32 %34
}