#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__ countbn(char);
char getchar();
int /*<<< orphan*/ printf(char *, char *, ...);
int readline(char *, int);
int main(int argc, char *argv[]) {
  int len;
  char line[80 + 1];
  char b, c;
  int nr = 80;
  int i;
  while ((len = readline(line, nr)) > 0) {
    if (len == (nr - 1) && line[nr - 2] != '\n') {
      c = getchar();
      if (countbn(c) > 0) {
        printf("%s\n%c", line, c);
        nr = 80 - 1;
      } else {
        b = line[nr - 2];
        if (countbn(b) == 0) {
          line[nr - 2] = '\0';
          printf("%s-\n%c%c", line, b, c);
          nr = 80 - 2;
        } else {
          printf("%s%c", line, c);
          nr = 80 - 1;
        }
      }
    } else {
      printf("%s", line);
      nr = 80;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x50,-0x78(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x78(%rbp),%esi
call   1040 <readline@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jle    1278 <main+0x138>
mov    -0x14(%rbp),%eax
mov    -0x78(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    125a <main+0x11a>
mov    -0x78(%rbp),%eax
sub    $0x2,%eax
cltq
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0xa,%eax
je     125a <main+0x11a>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x72(%rbp)
movsbl -0x72(%rbp),%edi
call   1060 <countbn@plt>
cmp    $0x0,%rax
jle    11de <main+0x9e>
lea    -0x70(%rbp),%rsi
movsbl -0x72(%rbp),%edx
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x4f,-0x78(%rbp)
jmp    1255 <main+0x115>
mov    -0x78(%rbp),%eax
sub    $0x2,%eax
cltq
mov    -0x70(%rbp,%rax,1),%al
mov    %al,-0x71(%rbp)
movsbl -0x71(%rbp),%edi
call   1060 <countbn@plt>
cmp    $0x0,%rax
jne    1233 <main+0xf3>
mov    -0x78(%rbp),%eax
sub    $0x2,%eax
cltq
movb   $0x0,-0x70(%rbp,%rax,1)
lea    -0x70(%rbp),%rsi
movsbl -0x71(%rbp),%edx
movsbl -0x72(%rbp),%ecx
lea    0xde6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x4e,-0x78(%rbp)
jmp    1250 <main+0x110>
lea    -0x70(%rbp),%rsi
movsbl -0x72(%rbp),%edx
lea    0xdcd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x4f,-0x78(%rbp)
jmp    1255 <main+0x115>
jmp    1273 <main+0x133>
lea    -0x70(%rbp),%rsi
lea    0xdaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x50,-0x78(%rbp)
jmp    1160 <main+0x20>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rsp,%rdi
mov    $0x50,%ebp
mov    $0x50,%esi
call   1040 <readline@plt>
test   %eax,%eax
jle    121f <main+0xdf>
lea    0xe91(%rip),%r14
mov    %rsp,%rbx
lea    0xe9b(%rip),%r13
jmp    11a0 <main+0x60>
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x50,%ebp
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <readline@plt>
test   %eax,%eax
jle    121f <main+0xdf>
lea    -0x1(%rbp),%ecx
cmp    %ecx,%eax
jne    1180 <main+0x40>
add    $0xfffffffe,%ebp
cmpb   $0xa,(%rsp,%rbp,1)
je     1180 <main+0x40>
xor    %eax,%eax
call   1050 <getchar@plt>
movsbl %al,%r15d
mov    %r15d,%edi
call   1060 <countbn@plt>
test   %rax,%rax
jle    11cd <main+0x8d>
mov    %r14,%rdi
jmp    11e6 <main+0xa6>
movsbl (%rsp,%rbp,1),%r12d
mov    %r12d,%edi
call   1060 <countbn@plt>
test   %rax,%rax
je     11fa <main+0xba>
lea    0xe29(%rip),%rdi
mov    %rbx,%rsi
mov    %r15d,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x4f,%ebp
jmp    1192 <main+0x52>
movb   $0x0,(%rsp,%rbp,1)
lea    0xe01(%rip),%rdi
mov    %rbx,%rsi
mov    %r12d,%edx
mov    %r15d,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x4e,%ebp
jmp    1192 <main+0x52>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%s\0A%c\00"
@.str.1 = [9 x i8] c"%s-\0A%c%c\00"
@.str.2 = [5 x i8] c"%s%c\00"
@.str.3 = [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 [81 x i8]
%8 = alloca i8
%9 = alloca i8
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 80, i32* %10
br label %12
12: ; preds = %70, %2
%13 = getelementptr inbounds [81 x i8], [81 x i8]* %7, i64 0, i64 0
%14 = load i32, i32* %10
%15 = call i32 @readline(i8* %13, i32 %14)
store i32 %15, i32* %6
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %71
17: ; preds = %12
%18 = load i32, i32* %6
%19 = load i32, i32* %10
%20 = sub nsw i32 %19, 1
%21 = icmp eq i32 %18, %20
br i1 %21, label %22, label %67
22: ; preds = %17
%23 = load i32, i32* %10
%24 = sub nsw i32 %23, 2
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [81 x i8], [81 x i8]* %7, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 10
br i1 %29, label %30, label %67
30: ; preds = %22
%31 = call signext i8 (...) @getchar()
store i8 %31, i8* %9
%32 = load i8, i8* %9
%33 = call i64 @countbn(i8 signext %32)
%34 = icmp sgt i64 %33, 0
br i1 %34, label %35, label %40
35: ; preds = %30
%36 = getelementptr inbounds [81 x i8], [81 x i8]* %7, i64 0, i64 0
%37 = load i8, i8* %9
%38 = sext i8 %37 to i32
%39 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %36, i32 %38)
store i32 79, i32* %10
br label %66
40: ; preds = %30
%41 = load i32, i32* %10
%42 = sub nsw i32 %41, 2
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [81 x i8], [81 x i8]* %7, i64 0, i64 %43
%45 = load i8, i8* %44
store i8 %45, i8* %8
%46 = load i8, i8* %8
%47 = call i64 @countbn(i8 signext %46)
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %60
49: ; preds = %40
%50 = load i32, i32* %10
%51 = sub nsw i32 %50, 2
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [81 x i8], [81 x i8]* %7, i64 0, i64 %52
store i8 0, i8* %53
%54 = getelementptr inbounds [81 x i8], [81 x i8]* %7, i64 0, i64 0
%55 = load i8, i8* %8
%56 = sext i8 %55 to i32
%57 = load i8, i8* %9
%58 = sext i8 %57 to i32
%59 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %54, i32 %56, i32 %58)
store i32 78, i32* %10
br label %65
60: ; preds = %40
%61 = getelementptr inbounds [81 x i8], [81 x i8]* %7, i64 0, i64 0
%62 = load i8, i8* %9
%63 = sext i8 %62 to i32
%64 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %61, i32 %63)
store i32 79, i32* %10
br label %65
65: ; preds = %60, %49
br label %66
66: ; preds = %65, %35
br label %70
67: ; preds = %22, %17
%68 = getelementptr inbounds [81 x i8], [81 x i8]* %7, i64 0, i64 0
%69 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %68)
store i32 80, i32* %10
br label %70
70: ; preds = %67, %66
br label %12
71: ; preds = %12
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"%s\0A%c\00"
@.str.1 = [9 x i8] c"%s-\0A%c%c\00"
@.str.2 = [5 x i8] c"%s%c\00"
@.str.3 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [81 x i8]
%4 = getelementptr inbounds [81 x i8], [81 x i8]* %3, i64 0, i64 0
%5 = call i32 @readline(i8* %4, i32 80)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %42
7: ; preds = %2, %38
%8 = phi i32 [ %40, %38 ], [ %5, %2 ]
%9 = phi i32 [ %39, %38 ], [ 80, %2 ]
%10 = add nsw i32 %9, -1
%11 = icmp eq i32 %8, %10
br i1 %11, label %12, label %36
12: ; preds = %7
%13 = add nsw i32 %9, -2
%14 = zext i32 %13 to i64
%15 = getelementptr inbounds [81 x i8], [81 x i8]* %3, i64 0, i64 %14
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 10
br i1 %17, label %36, label %18
18: ; preds = %12
%19 = call signext i8 (...) @getchar()
%20 = call i64 @countbn(i8 signext %19)
%21 = icmp sgt i64 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = sext i8 %19 to i32
%24 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %4, i32 %23)
br label %38
25: ; preds = %18
%26 = load i8, i8* %15
%27 = call i64 @countbn(i8 signext %26)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %33
29: ; preds = %25
store i8 0, i8* %15
%30 = sext i8 %26 to i32
%31 = sext i8 %19 to i32
%32 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %4, i32 %30, i32 %31)
br label %38
33: ; preds = %25
%34 = sext i8 %19 to i32
%35 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %4, i32 %34)
br label %38
36: ; preds = %12, %7
%37 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %4)
br label %38
38: ; preds = %22, %33, %29, %36
%39 = phi i32 [ 79, %22 ], [ 78, %29 ], [ 79, %33 ], [ 80, %36 ]
%40 = call i32 @readline(i8* %4, i32 %39)
%41 = icmp sgt i32 %40, 0
br i1 %41, label %7, label %42
42: ; preds = %38, %2
ret i32 0
}