#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 /*<<< orphan*/ STDIN_FILENO;
int /*<<< orphan*/ STDOUT_FILENO;
int read(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ sprintf(char *, char *, int);
int strlen(char *);
int /*<<< orphan*/ write(int /*<<< orphan*/, char *, int);
int get_input_line(char *buf, int maxsize) {
  int cnt = 0, running = 1, i;
  char sbuf[10];
  char c, b;
  buf[cnt] = 0;
  while (running) {
    if (read(STDIN_FILENO, &c, 1) == 1) {
      i = c;
      if ((i >= ' ') && (i < 0x7f)) {
        buf[cnt] = c;
        cnt++;
        buf[cnt] = 0;
        write(STDOUT_FILENO, &c, 1);
      } else {
        if (i == 0x7f) {
          if (cnt > 0) {
            cnt--;
            buf[cnt] = 0;
            b = 8;
            write(STDOUT_FILENO, &b, 1);
            b = ' ';
            write(STDOUT_FILENO, &b, 1);
            b = 8;
            write(STDOUT_FILENO, &b, 1);
          }
        } else if (c == 0x0a) {
          return (0);
        } else {
          if (c == 0x1b) {
            if (read(STDIN_FILENO, &c, 1) != 1) {
              running = 0;
            } else {
              while (read(STDIN_FILENO, &c, 1) == 1)
                ;
              running = 0;
            }
          } else {
            i = c;
            i &= 0xff;
            sprintf(sbuf, "<%d>", i);
            write(STDOUT_FILENO, sbuf, strlen(sbuf));
          }
        }
      }
    }
  }
  return (-1);
}


x86 assembly (clang, -O0):
<get_input_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
cmpl   $0x0,-0x1c(%rbp)
je     135d <get_input_line+0x21d>
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
lea    -0x2b(%rbp),%rsi
mov    $0x1,%edx
call   1050 <read@plt>
cmp    $0x1,%eax
jne    1358 <get_input_line+0x218>
movsbl -0x2b(%rbp),%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x20,-0x20(%rbp)
jl     11ed <get_input_line+0xad>
cmpl   $0x7f,-0x20(%rbp)
jge    11ed <get_input_line+0xad>
mov    -0x2b(%rbp),%dl
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    0x2e18(%rip),%rax
mov    (%rax),%edi
lea    -0x2b(%rbp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
jmp    1353 <get_input_line+0x213>
cmpl   $0x7f,-0x20(%rbp)
jne    126c <get_input_line+0x12c>
cmpl   $0x0,-0x18(%rbp)
jle    1267 <get_input_line+0x127>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
movb   $0x8,-0x2c(%rbp)
mov    0x2dcf(%rip),%rax
mov    (%rax),%edi
lea    -0x2c(%rbp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
movb   $0x20,-0x2c(%rbp)
mov    0x2db4(%rip),%rax
mov    (%rax),%edi
lea    -0x2c(%rbp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
movb   $0x8,-0x2c(%rbp)
mov    0x2d99(%rip),%rax
mov    (%rax),%edi
lea    -0x2c(%rbp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
jmp    134e <get_input_line+0x20e>
movsbl -0x2b(%rbp),%eax
cmp    $0xa,%eax
jne    1285 <get_input_line+0x145>
movl   $0x0,-0x4(%rbp)
jmp    1364 <get_input_line+0x224>
movsbl -0x2b(%rbp),%eax
cmp    $0x1b,%eax
jne    12f4 <get_input_line+0x1b4>
mov    0x2d3f(%rip),%rax
mov    (%rax),%edi
lea    -0x2b(%rbp),%rsi
mov    $0x1,%edx
call   1050 <read@plt>
cmp    $0x1,%eax
je     12be <get_input_line+0x17e>
movl   $0x0,-0x1c(%rbp)
jmp    12ef <get_input_line+0x1af>
jmp    12c3 <get_input_line+0x183>
mov    0x2d0e(%rip),%rax
mov    (%rax),%edi
lea    -0x2b(%rbp),%rsi
mov    $0x1,%edx
call   1050 <read@plt>
cmp    $0x1,%eax
jne    12e8 <get_input_line+0x1a8>
jmp    12c3 <get_input_line+0x183>
movl   $0x0,-0x1c(%rbp)
jmp    1344 <get_input_line+0x204>
movsbl -0x2b(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x20(%rbp)
lea    -0x2a(%rbp),%rdi
mov    -0x20(%rbp),%edx
lea    0xcec(%rip),%rsi
call   1060 <sprintf@plt>
mov    0x2cd0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
lea    -0x2a(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    -0x2a(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x3c(%rbp),%edi
mov    -0x38(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
jmp    1349 <get_input_line+0x209>
jmp    134e <get_input_line+0x20e>
jmp    1353 <get_input_line+0x213>
jmp    1358 <get_input_line+0x218>
jmp    1169 <get_input_line+0x29>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_input_line>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdi,0x10(%rsp)
movb   $0x0,(%rdi)
xor    %r14d,%r14d
mov    0x2e78(%rip),%r15
lea    0xf(%rsp),%rbx
mov    0x2e84(%rip),%r12
lea    0x1e(%rsp),%r13
jmp    1189 <get_input_line+0x49>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
test   %r14d,%r14d
jg     120a <get_input_line+0xca>
mov    (%r15),%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1050 <read@plt>
cmp    $0x1,%eax
jne    1189 <get_input_line+0x49>
movzbl 0xf(%rsp),%eax
lea    -0x20(%rax),%ecx
cmp    $0x5e,%cl
jbe    11eb <get_input_line+0xab>
cmp    $0x7f,%al
je     1180 <get_input_line+0x40>
cmp    $0xa,%al
je     12a7 <get_input_line+0x167>
cmp    $0x1b,%al
je     1264 <get_input_line+0x124>
movzbl %al,%edx
mov    %r13,%rdi
lea    0xe34(%rip),%rsi
call   1060 <sprintf@plt>
mov    (%r12),%ebp
mov    %r13,%rdi
call   1040 <strlen@plt>
mov    %ebp,%edi
mov    %r13,%rsi
mov    %eax,%edx
call   1030 <write@plt>
jmp    1189 <get_input_line+0x49>
movslq %r14d,%r14
mov    0x10(%rsp),%rcx
mov    %al,(%rcx,%r14,1)
movb   $0x0,0x1(%rcx,%r14,1)
add    $0x1,%r14
mov    (%r12),%edi
mov    %rbx,%rsi
jmp    1255 <get_input_line+0x115>
add    $0xffffffff,%r14d
mov    0x10(%rsp),%rax
movb   $0x0,(%rax,%r14,1)
movb   $0x8,0xe(%rsp)
mov    (%r12),%edi
lea    0xe(%rsp),%rbp
mov    %rbp,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
movb   $0x20,0xe(%rsp)
mov    (%r12),%edi
mov    %rbp,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
movb   $0x8,0xe(%rsp)
mov    (%r12),%edi
mov    %rbp,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
jmp    1189 <get_input_line+0x49>
mov    (%r15),%edi
lea    0xf(%rsp),%rsi
mov    $0x1,%edx
call   1050 <read@plt>
mov    $0xffffffff,%ebp
cmp    $0x1,%eax
jne    12a9 <get_input_line+0x169>
lea    0xf(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r15),%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1050 <read@plt>
cmp    $0x1,%eax
je     1290 <get_input_line+0x150>
jmp    12a9 <get_input_line+0x169>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@STDIN_FILENO = global i32 0
@STDOUT_FILENO = global i32 0
@.str = [5 x i8] c"<%d>\00"
define i32 @get_input_line(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [10 x i8]
%10 = alloca i8
%11 = alloca i8
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 0, i32* %6
store i32 1, i32* %7
%12 = load i8*, i8** %4
%13 = load i32, i32* %6
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
store i8 0, i8* %15
br label %16
16: ; preds = %104, %2
%17 = load i32, i32* %7
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %105
19: ; preds = %16
%20 = load i32, i32* @STDIN_FILENO
%21 = call i32 @read(i32 %20, i8* %10, i32 1)
%22 = icmp eq i32 %21, 1
br i1 %22, label %23, label %104
23: ; preds = %19
%24 = load i8, i8* %10
%25 = sext i8 %24 to i32
store i32 %25, i32* %8
%26 = load i32, i32* %8
%27 = icmp sge i32 %26, 32
br i1 %27, label %28, label %45
28: ; preds = %23
%29 = load i32, i32* %8
%30 = icmp slt i32 %29, 127
br i1 %30, label %31, label %45
31: ; preds = %28
%32 = load i8, i8* %10
%33 = load i8*, i8** %4
%34 = load i32, i32* %6
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
store i8 %32, i8* %36
%37 = load i32, i32* %6
%38 = add nsw i32 %37, 1
store i32 %38, i32* %6
%39 = load i8*, i8** %4
%40 = load i32, i32* %6
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %39, i64 %41
store i8 0, i8* %42
%43 = load i32, i32* @STDOUT_FILENO
%44 = call i32 @write(i32 %43, i8* %10, i32 1)
br label %103
45: ; preds = %28, %23
%46 = load i32, i32* %8
%47 = icmp eq i32 %46, 127
br i1 %47, label %48, label %65
48: ; preds = %45
%49 = load i32, i32* %6
%50 = icmp sgt i32 %49, 0
br i1 %50, label %51, label %64
51: ; preds = %48
%52 = load i32, i32* %6
%53 = add nsw i32 %52, -1
store i32 %53, i32* %6
%54 = load i8*, i8** %4
%55 = load i32, i32* %6
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8, i8* %54, i64 %56
store i8 0, i8* %57
store i8 8, i8* %11
%58 = load i32, i32* @STDOUT_FILENO
%59 = call i32 @write(i32 %58, i8* %11, i32 1)
store i8 32, i8* %11
%60 = load i32, i32* @STDOUT_FILENO
%61 = call i32 @write(i32 %60, i8* %11, i32 1)
store i8 8, i8* %11
%62 = load i32, i32* @STDOUT_FILENO
%63 = call i32 @write(i32 %62, i8* %11, i32 1)
br label %64
64: ; preds = %51, %48
br label %102
65: ; preds = %45
%66 = load i8, i8* %10
%67 = sext i8 %66 to i32
%68 = icmp eq i32 %67, 10
br i1 %68, label %69, label %70
69: ; preds = %65
store i32 0, i32* %3
br label %106
70: ; preds = %65
%71 = load i8, i8* %10
%72 = sext i8 %71 to i32
%73 = icmp eq i32 %72, 27
br i1 %73, label %74, label %87
74: ; preds = %70
%75 = load i32, i32* @STDIN_FILENO
%76 = call i32 @read(i32 %75, i8* %10, i32 1)
%77 = icmp ne i32 %76, 1
br i1 %77, label %78, label %79
78: ; preds = %74
store i32 0, i32* %7
br label %86
79: ; preds = %74
br label %80
80: ; preds = %84, %79
%81 = load i32, i32* @STDIN_FILENO
%82 = call i32 @read(i32 %81, i8* %10, i32 1)
%83 = icmp eq i32 %82, 1
br i1 %83, label %84, label %85
84: ; preds = %80
br label %80
85: ; preds = %80
store i32 0, i32* %7
br label %86
86: ; preds = %85, %78
br label %100
87: ; preds = %70
%88 = load i8, i8* %10
%89 = sext i8 %88 to i32
store i32 %89, i32* %8
%90 = load i32, i32* %8
%91 = and i32 %90, 255
store i32 %91, i32* %8
%92 = getelementptr inbounds [10 x i8], [10 x i8]* %9, i64 0, i64 0
%93 = load i32, i32* %8
%94 = call i32 @sprintf(i8* %92, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %93)
%95 = load i32, i32* @STDOUT_FILENO
%96 = getelementptr inbounds [10 x i8], [10 x i8]* %9, i64 0, i64 0
%97 = getelementptr inbounds [10 x i8], [10 x i8]* %9, i64 0, i64 0
%98 = call i32 @strlen(i8* %97)
%99 = call i32 @write(i32 %95, i8* %96, i32 %98)
br label %100
100: ; preds = %87, %86
br label %101
101: ; preds = %100
br label %102
102: ; preds = %101, %64
br label %103
103: ; preds = %102, %31
br label %104
104: ; preds = %103, %19
br label %16
105: ; preds = %16
store i32 -1, i32* %3
br label %106
106: ; preds = %105, %69
%107 = load i32, i32* %3
ret i32 %107
}

LLVM IR (-O2):
@STDIN_FILENO = global i32 0
@STDOUT_FILENO = global i32 0
@.str = [5 x i8] c"<%d>\00"
define i32 @get_input_line(i8* nocapture writeonly %0, i32 %1) {
%3 = alloca [10 x i8]
%4 = alloca i8
%5 = alloca i8
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
store i8 0, i8* %0
br label %7
7: ; preds = %27, %2
%8 = phi i32 [ 0, %2 ], [ %28, %27 ]
%9 = icmp sgt i32 %8, 0
br label %10
10: ; preds = %54, %7
%11 = load i32, i32* @STDIN_FILENO
%12 = call i32 @read(i32 %11, i8* %4, i32 1)
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %54
14: ; preds = %10
%15 = load i8, i8* %4
%16 = zext i8 %15 to i32
%17 = add i8 %15, -32
%18 = icmp ult i8 %17, 95
br i1 %18, label %19, label %29
19: ; preds = %14
%20 = sext i32 %8 to i64
%21 = getelementptr inbounds i8, i8* %0, i64 %20
store i8 %15, i8* %21
%22 = add nsw i32 %8, 1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %0, i64 %23
store i8 0, i8* %24
%25 = load i32, i32* @STDOUT_FILENO
%26 = call i32 @write(i32 %25, i8* %4, i32 1)
br label %27
27: ; preds = %19, %31
%28 = phi i32 [ %32, %31 ], [ %22, %19 ]
br label %7
29: ; preds = %14
switch i8 %15, label %49 [
i8 127, label %30
i8 10, label %55
i8 27, label %41
]
30: ; preds = %29
br i1 %9, label %31, label %54
31: ; preds = %30
%32 = add nsw i32 %8, -1
%33 = zext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %0, i64 %33
store i8 0, i8* %34
store i8 8, i8* %5
%35 = load i32, i32* @STDOUT_FILENO
%36 = call i32 @write(i32 %35, i8* %5, i32 1)
store i8 32, i8* %5
%37 = load i32, i32* @STDOUT_FILENO
%38 = call i32 @write(i32 %37, i8* %5, i32 1)
store i8 8, i8* %5
%39 = load i32, i32* @STDOUT_FILENO
%40 = call i32 @write(i32 %39, i8* %5, i32 1)
br label %27
41: ; preds = %29
%42 = load i32, i32* @STDIN_FILENO
%43 = call i32 @read(i32 %42, i8* %4, i32 1)
%44 = icmp eq i32 %43, 1
br i1 %44, label %45, label %55
45: ; preds = %41, %45
%46 = load i32, i32* @STDIN_FILENO
%47 = call i32 @read(i32 %46, i8* %4, i32 1)
%48 = icmp eq i32 %47, 1
br i1 %48, label %45, label %55
49: ; preds = %29
%50 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %16)
%51 = load i32, i32* @STDOUT_FILENO
%52 = call i32 @strlen(i8* %6)
%53 = call i32 @write(i32 %51, i8* %6, i32 %52)
br label %54
54: ; preds = %49, %30, %10
br label %10
55: ; preds = %29, %45, %41
%56 = phi i32 [ -1, %41 ], [ -1, %45 ], [ 0, %29 ]
ret i32 %56
}