#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 */
int getc(int /*<<< orphan*/ *);
scalar_t__ isprint(int);
int /*<<< orphan*/ printf(char *, ...);
int read_text(FILE *fp, int clen) {
  int ch, avail;
  printf("    \"");
  avail = 60;
  while (clen) {
    clen--;
    if ((ch = getc(fp)) < 0)
      return 0;
    if (!ch)
      break;
    if (avail) {
      if (isprint(ch))
        printf("%c", ch);
      else
        printf("?");
      if (!--avail)
        printf(" ... ");
    }
  }
  if ((clen && avail >= clen) || (!clen && avail >= 10))
    printf("\" = ");
  else
    printf("\" = \n        ");
  if (!clen) {
    printf("(no value)");
  } else {
    printf("\"");
    avail = 60;
    while (clen--) {
      if ((ch = getc(fp)) < 0)
        return 0;
      if (ch == '\n')
        printf("\n        ");
      else if (isprint(ch))
        printf("%c", ch);
      else
        printf("?");
      if (!--avail) {
        avail = 60;
        if (ch != '\n')
          printf("\n        ");
      }
    }
    printf("\"\n");
  }
  return 1;
}


x86 assembly (clang, -O0):
<read_text>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x3c,-0x1c(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1201 <read_text+0xd1>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <getc@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    1188 <read_text+0x58>
movl   $0x0,-0x4(%rbp)
jmp    135b <read_text+0x22b>
cmpl   $0x0,-0x18(%rbp)
jne    1197 <read_text+0x67>
jmp    1201 <read_text+0xd1>
cmpl   $0x0,-0x1c(%rbp)
je     11fc <read_text+0xcc>
mov    -0x18(%rbp),%edi
call   1040 <isprint@plt>
cmp    $0x0,%rax
je     11c9 <read_text+0x99>
mov    -0x18(%rbp),%esi
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d7 <read_text+0xa7>
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jne    11f7 <read_text+0xc7>
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11fc <read_text+0xcc>
jmp    1154 <read_text+0x24>
cmpl   $0x0,-0x14(%rbp)
je     1217 <read_text+0xe7>
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    122b <read_text+0xfb>
cmpl   $0x0,-0x14(%rbp)
jne    123e <read_text+0x10e>
cmpl   $0xa,-0x1c(%rbp)
jl     123e <read_text+0x10e>
lea    0xddf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    124c <read_text+0x11c>
lea    0xdd1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x14(%rbp)
jne    1269 <read_text+0x139>
lea    0xdc7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1354 <read_text+0x224>
lea    0xd94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x3c,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x14(%rbp)
cmp    $0x0,%eax
je     1346 <read_text+0x216>
mov    -0x10(%rbp),%rdi
call   1050 <getc@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    12b3 <read_text+0x183>
movl   $0x0,-0x4(%rbp)
jmp    135b <read_text+0x22b>
cmpl   $0xa,-0x18(%rbp)
jne    12d0 <read_text+0x1a0>
lea    0xd56(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    130b <read_text+0x1db>
mov    -0x18(%rbp),%edi
call   1040 <isprint@plt>
cmp    $0x0,%rax
je     12f8 <read_text+0x1c8>
mov    -0x18(%rbp),%esi
lea    0xd1a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1306 <read_text+0x1d6>
lea    0xd0a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    130b <read_text+0x1db>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jne    1341 <read_text+0x211>
movl   $0x3c,-0x1c(%rbp)
cmpl   $0xa,-0x18(%rbp)
je     133c <read_text+0x20c>
lea    0xce5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1341 <read_text+0x211>
jmp    127e <read_text+0x14e>
lea    0xce2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_text>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%r12
lea    0xe99(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
test   %ebp,%ebp
je     11da <read_text+0x8a>
mov    $0x1,%ebx
sub    %ebp,%ebx
mov    $0x3c,%r15d
mov    $0x3f,%r13d
lea    0xe7a(%rip),%r14
jmp    119b <read_text+0x4b>
xchg   %ax,%ax
xor    %r15d,%r15d
add    $0x1,%ebx
cmp    $0x1,%ebx
je     11f8 <read_text+0xa8>
mov    %r12,%rdi
call   1070 <getc@plt>
test   %eax,%eax
js     11e3 <read_text+0x93>
je     11e8 <read_text+0x98>
test   %r15d,%r15d
je     1190 <read_text+0x40>
mov    %eax,%ebp
mov    %eax,%edi
call   1060 <isprint@plt>
test   %rax,%rax
cmove  %r13d,%ebp
mov    %ebp,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%r15d
jne    1193 <read_text+0x43>
xor    %r15d,%r15d
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1193 <read_text+0x43>
lea    0xe2b(%rip),%rdi
jmp    120e <read_text+0xbe>
xor    %r15d,%r15d
jmp    1229 <read_text+0xd9>
mov    %ebx,%ebp
neg    %ebp
jae    123b <read_text+0xeb>
cmp    %ebp,%r15d
jl     123b <read_text+0xeb>
mov    %ebp,%r13d
jmp    1248 <read_text+0xf8>
cmp    $0xa,%r15d
lea    0xe09(%rip),%rax
lea    0xe07(%rip),%rdi
cmovge %rax,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe03(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
test   %ebx,%ebx
jne    1277 <read_text+0x127>
xor    %r13d,%r13d
cmp    $0x9,%r15d
jle    1277 <read_text+0x127>
lea    0xdbd(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
test   %ebx,%ebx
je     1215 <read_text+0xc5>
mov    $0x22,%edi
call   1030 <putchar@plt>
test   %r13d,%r13d
jne    1296 <read_text+0x146>
lea    0xd94(%rip),%rdi
call   1040 <puts@plt>
jmp    1223 <read_text+0xd3>
lea    0xd93(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
test   %ebx,%ebx
je     1215 <read_text+0xc5>
mov    $0x22,%edi
call   1030 <putchar@plt>
mov    %ebp,%r13d
lea    0xd78(%rip),%r14
xor    %r15d,%r15d
mov    $0x3c,%ebx
jmp    12ca <read_text+0x17a>
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0xffffffff,%ebx
mov    $0x3c,%eax
cmove  %eax,%ebx
test   %r13d,%r13d
je     1269 <read_text+0x119>
mov    %r12,%rdi
call   1070 <getc@plt>
test   %eax,%eax
js     1229 <read_text+0xd9>
mov    %eax,%ebp
add    $0xffffffff,%r13d
cmp    $0xa,%eax
je     12b0 <read_text+0x160>
mov    %ebp,%edi
call   1060 <isprint@plt>
test   %rax,%rax
mov    $0x3f,%eax
cmove  %eax,%ebp
mov    %ebp,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    12c5 <read_text+0x175>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x3c,%ebx
jmp    12c5 <read_text+0x175>

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

LLVM IR (-O2):
@.str = [6 x i8] c" \22\00"
@.str.3 = [6 x i8] c" ... \00"
@.str.4 = [5 x i8] c"\22 = \00"
@.str.5 = [14 x i8] c"\22 = \0A \00"
@.str.6 = [11 x i8] c"(no value)\00"
@.str.8 = [10 x i8] c"\0A \00"
@str = [2 x i8] c"\22\00"
define i32 @read_text(i32* nocapture %0, i32 %1) {
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32 %1, 0
br i1 %4, label %44, label %5
5: ; preds = %2, %24
%6 = phi i32 [ %25, %24 ], [ 60, %2 ]
%7 = phi i32 [ %8, %24 ], [ %1, %2 ]
%8 = add nsw i32 %7, -1
%9 = tail call i32 @getc(i32* %0)
%10 = icmp slt i32 %9, 0
br i1 %10, label %81, label %11
11: ; preds = %5
%12 = icmp eq i32 %9, 0
br i1 %12, label %27, label %13
13: ; preds = %11
%14 = icmp eq i32 %6, 0
br i1 %14, label %24, label %15
15: ; preds = %13
%16 = tail call i64 @isprint(i32 %9)
%17 = icmp eq i64 %16, 0
%18 = select i1 %17, i32 63, i32 %9
%19 = tail call i32 @putchar(i32 %18)
%20 = add nsw i32 %6, -1
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %15
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %24
24: ; preds = %15, %22, %13
%25 = phi i32 [ %20, %15 ], [ 0, %22 ], [ 0, %13 ]
%26 = icmp eq i32 %8, 0
br i1 %26, label %34, label %5
27: ; preds = %11
%28 = icmp eq i32 %8, 0
%29 = icmp slt i32 %6, %8
%30 = select i1 %28, i1 true, i1 %29
br i1 %30, label %31, label %41
31: ; preds = %27
%32 = icmp sgt i32 %6, 9
%33 = select i1 %28, i1 %32, i1 false
br i1 %33, label %41, label %37
34: ; preds = %24
%35 = icmp sgt i32 %25, 9
%36 = select i1 %35, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0)
br label %44
37: ; preds = %31
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
br i1 %28, label %47, label %39
39: ; preds = %37
%40 = tail call i32 @putchar(i32 34)
br label %52
41: ; preds = %31, %27
%42 = phi i32 [ %8, %27 ], [ 0, %31 ]
%43 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br i1 %28, label %47, label %49
44: ; preds = %34, %2
%45 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), %2 ], [ %36, %34 ]
%46 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %45)
br label %47
47: ; preds = %44, %37, %41
%48 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
br label %81
49: ; preds = %41
%50 = tail call i32 @putchar(i32 34)
%51 = icmp eq i32 %42, 0
br i1 %51, label %79, label %52
52: ; preds = %39, %49
%53 = phi i32 [ %42, %49 ], [ %8, %39 ]
br label %54
54: ; preds = %52, %76
%55 = phi i32 [ %57, %76 ], [ %53, %52 ]
%56 = phi i32 [ %77, %76 ], [ 60, %52 ]
%57 = add nsw i32 %55, -1
%58 = tail call i32 @getc(i32* %0)
%59 = icmp slt i32 %58, 0
br i1 %59, label %81, label %60
60: ; preds = %54
%61 = icmp eq i32 %58, 10
br i1 %61, label %69, label %62
62: ; preds = %60
%63 = tail call i64 @isprint(i32 %58)
%64 = icmp eq i64 %63, 0
%65 = select i1 %64, i32 63, i32 %58
%66 = tail call i32 @putchar(i32 %65)
%67 = add nsw i32 %56, -1
%68 = icmp eq i32 %67, 0
br i1 %68, label %74, label %76
69: ; preds = %60
%70 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0))
%71 = add nsw i32 %56, -1
%72 = icmp eq i32 %71, 0
%73 = select i1 %72, i32 60, i32 %71
br label %76
74: ; preds = %62
%75 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0))
br label %76
76: ; preds = %69, %62, %74
%77 = phi i32 [ %67, %62 ], [ 60, %74 ], [ %73, %69 ]
%78 = icmp eq i32 %57, 0
br i1 %78, label %79, label %54
79: ; preds = %76, %49
%80 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
br label %81
81: ; preds = %5, %54, %47, %79
%82 = phi i32 [ 1, %79 ], [ 1, %47 ], [ 0, %54 ], [ 0, %5 ]
ret i32 %82
}