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

/* Variables and functions */
unsigned char *filebuf(int /*<<< orphan*/ *, int *);
int fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(unsigned char *);
int isprint(unsigned char);
int /*<<< orphan*/ printf(char *, char *);
void strings(FILE *pf) {
  static char printme[1024];
  int sz;
  unsigned char *cdata;
  int nread;
  int printmeindex;
  cdata = filebuf(pf, &sz);
  nread = fread(cdata, 1, sz, pf);
  printmeindex = 0;
  if (nread > 0) {
    int i;
    unsigned char c;
    int isprintable;
    int iseol;
    for (i = 0; i < nread; i++) {
      c = cdata[i];
      isprintable = isprint(c);
      iseol = 0;
      if (c == 0 || c == '\n' || printmeindex >= sizeof(printme) - 1)
        iseol = 1;
      if (iseol || !isprintable) {
        if (printmeindex > 3 && iseol) {
          printme[printmeindex++] = 0;
          printf("%s\n", printme);
          printmeindex = 0;
        }
      } else if (isprintable) {
        printme[printmeindex++] = c;
      }
    }
  }
  if (printmeindex > 3) {
    printme[printmeindex++] = 0;
    printf("%s\n", printme);
    printmeindex = 0;
  }
  free(cdata);
}


x86 assembly (clang, -O0):
<strings>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <filebuf@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    129d <strings+0x14d>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1298 <strings+0x148>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x25(%rbp)
movzbl -0x25(%rbp),%edi
call   1070 <isprint@plt>
mov    %eax,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
movzbl -0x25(%rbp),%eax
cmp    $0x0,%eax
je     11f4 <strings+0xa4>
movzbl -0x25(%rbp),%eax
cmp    $0xa,%eax
je     11f4 <strings+0xa4>
movslq -0x20(%rbp),%rax
cmp    $0x3ff,%rax
jb     11fb <strings+0xab>
movl   $0x1,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
jne    120f <strings+0xbf>
cmpl   $0x0,-0x2c(%rbp)
jne    125b <strings+0x10b>
cmpl   $0x3,-0x20(%rbp)
jle    1256 <strings+0x106>
cmpl   $0x0,-0x30(%rbp)
je     1256 <strings+0x106>
mov    -0x20(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x20(%rbp)
movslq %eax,%rcx
lea    0x2e28(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0xdbd(%rip),%rdi
lea    0x2e16(%rip),%rsi
call   1050 <printf@plt>
movl   $0x0,-0x20(%rbp)
jmp    1285 <strings+0x135>
cmpl   $0x0,-0x2c(%rbp)
je     1280 <strings+0x130>
mov    -0x25(%rbp),%dl
mov    -0x20(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x20(%rbp)
movslq %eax,%rcx
lea    0x2de3(%rip),%rax
mov    %dl,(%rax,%rcx,1)
jmp    1285 <strings+0x135>
jmp    128a <strings+0x13a>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    119d <strings+0x4d>
jmp    129d <strings+0x14d>
cmpl   $0x3,-0x20(%rbp)
jle    12da <strings+0x18a>
mov    -0x20(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x20(%rbp)
movslq %eax,%rcx
lea    0x2da4(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0xd39(%rip),%rdi
lea    0x2d92(%rip),%rsi
call   1050 <printf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strings>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbp
lea    0xc(%rsp),%rsi
call   1060 <filebuf@plt>
mov    0xc(%rsp),%edx
mov    %rax,0x10(%rsp)
mov    %rax,%rdi
mov    $0x1,%esi
mov    %rbp,%rcx
call   1040 <fread@plt>
test   %eax,%eax
jle    1244 <strings+0xf4>
mov    %eax,%r13d
xor    %ebx,%ebx
xor    %r15d,%r15d
jmp    11c6 <strings+0x76>
cs nopw 0x0(%rax,%rax,1)
lea    0x2eb9(%rip),%rsi
movb   $0x0,(%rcx,%rsi,1)
lea    0xe4e(%rip),%rdi
call   1050 <printf@plt>
add    $0x1,%rbx
mov    $0x0,%r15d
cmp    %r13,%rbx
je     1244 <strings+0xf4>
mov    0x10(%rsp),%rax
movzbl (%rax,%rbx,1),%ebp
cmp    $0xa,%ebp
sete   %r14b
test   %ebp,%ebp
sete   %r12b
mov    %ebp,%edi
call   1070 <isprint@plt>
or     %r14b,%r12b
movslq %r15d,%rcx
cmp    $0x3ff,%ecx
setae  %dl
or     %r12b,%dl
cmp    $0x1,%dl
je     1210 <strings+0xc0>
test   %eax,%eax
je     1210 <strings+0xc0>
add    $0x1,%r15d
lea    0x2e57(%rip),%rax
mov    %bpl,(%rcx,%rax,1)
jmp    121b <strings+0xcb>
nop
cmp    $0x4,%r15d
setge  %al
test   %dl,%al
jne    11a0 <strings+0x50>
add    $0x1,%rbx
cmp    %r13,%rbx
jne    11c6 <strings+0x76>
cmp    $0x4,%r15d
jl     1244 <strings+0xf4>
mov    %r15d,%eax
lea    0x2e2c(%rip),%rsi
movb   $0x0,(%rax,%rsi,1)
lea    0xdc1(%rip),%rdi
call   1050 <printf@plt>
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@strings.printme = internal global [1024 x i8] zeroinitializer
@.str = [4 x i8] c"%s\0A\00"
define void @strings(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8
%9 = alloca i32
%10 = alloca i32
store i32* %0, i32** %2
%11 = load i32*, i32** %2
%12 = call i8* @filebuf(i32* %11, i32* %3)
store i8* %12, i8** %4
%13 = load i8*, i8** %4
%14 = load i32, i32* %3
%15 = load i32*, i32** %2
%16 = call i32 @fread(i8* %13, i32 1, i32 %14, i32* %15)
store i32 %16, i32* %5
store i32 0, i32* %6
%17 = load i32, i32* %5
%18 = icmp sgt i32 %17, 0
br i1 %18, label %19, label %78
19: ; preds = %1
store i32 0, i32* %7
br label %20
20: ; preds = %74, %19
%21 = load i32, i32* %7
%22 = load i32, i32* %5
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %77
24: ; preds = %20
%25 = load i8*, i8** %4
%26 = load i32, i32* %7
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = load i8, i8* %28
store i8 %29, i8* %8
%30 = load i8, i8* %8
%31 = call i32 @isprint(i8 zeroext %30)
store i32 %31, i32* %9
store i32 0, i32* %10
%32 = load i8, i8* %8
%33 = zext i8 %32 to i32
%34 = icmp eq i32 %33, 0
br i1 %34, label %43, label %35
35: ; preds = %24
%36 = load i8, i8* %8
%37 = zext i8 %36 to i32
%38 = icmp eq i32 %37, 10
br i1 %38, label %43, label %39
39: ; preds = %35
%40 = load i32, i32* %6
%41 = sext i32 %40 to i64
%42 = icmp uge i64 %41, 1023
br i1 %42, label %43, label %44
43: ; preds = %39, %35, %24
store i32 1, i32* %10
br label %44
44: ; preds = %43, %39
%45 = load i32, i32* %10
%46 = icmp ne i32 %45, 0
br i1 %46, label %50, label %47
47: ; preds = %44
%48 = load i32, i32* %9
%49 = icmp ne i32 %48, 0
br i1 %49, label %63, label %50
50: ; preds = %47, %44
%51 = load i32, i32* %6
%52 = icmp sgt i32 %51, 3
br i1 %52, label %53, label %62
53: ; preds = %50
%54 = load i32, i32* %10
%55 = icmp ne i32 %54, 0
br i1 %55, label %56, label %62
56: ; preds = %53
%57 = load i32, i32* %6
%58 = add nsw i32 %57, 1
store i32 %58, i32* %6
%59 = sext i32 %57 to i64
%60 = getelementptr inbounds [1024 x i8], [1024 x i8]* @strings.printme, i64 0, i64 %59
store i8 0, i8* %60
%61 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @strings.printme, i64 0, i64 0))
store i32 0, i32* %6
br label %62
62: ; preds = %56, %53, %50
br label %73
63: ; preds = %47
%64 = load i32, i32* %9
%65 = icmp ne i32 %64, 0
br i1 %65, label %66, label %72
66: ; preds = %63
%67 = load i8, i8* %8
%68 = load i32, i32* %6
%69 = add nsw i32 %68, 1
store i32 %69, i32* %6
%70 = sext i32 %68 to i64
%71 = getelementptr inbounds [1024 x i8], [1024 x i8]* @strings.printme, i64 0, i64 %70
store i8 %67, i8* %71
br label %72
72: ; preds = %66, %63
br label %73
73: ; preds = %72, %62
br label %74
74: ; preds = %73
%75 = load i32, i32* %7
%76 = add nsw i32 %75, 1
store i32 %76, i32* %7
br label %20
77: ; preds = %20
br label %78
78: ; preds = %77, %1
%79 = load i32, i32* %6
%80 = icmp sgt i32 %79, 3
br i1 %80, label %81, label %87
81: ; preds = %78
%82 = load i32, i32* %6
%83 = add nsw i32 %82, 1
store i32 %83, i32* %6
%84 = sext i32 %82 to i64
%85 = getelementptr inbounds [1024 x i8], [1024 x i8]* @strings.printme, i64 0, i64 %84
store i8 0, i8* %85
%86 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @strings.printme, i64 0, i64 0))
store i32 0, i32* %6
br label %87
87: ; preds = %81, %78
%88 = load i8*, i8** %4
%89 = call i32 @free(i8* %88)
ret void
}

LLVM IR (-O2):
@strings.printme = internal global [1024 x i8] zeroinitializer
@.str = [4 x i8] c"%s\0A\00"
define void @strings(i32* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = call i8* @filebuf(i32* %0, i32* %2)
%5 = load i32, i32* %2
%6 = call i32 @fread(i8* %4, i32 1, i32 %5, i32* %0)
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %49
8: ; preds = %1
%9 = zext i32 %6 to i64
br label %10
10: ; preds = %35, %8
%11 = phi i64 [ 0, %8 ], [ %36, %35 ]
%12 = phi i32 [ 0, %8 ], [ %37, %35 ]
%13 = getelementptr inbounds i8, i8* %4, i64 %11
%14 = load i8, i8* %13
%15 = call i32 @isprint(i8 zeroext %14)
%16 = icmp eq i8 %14, 0
%17 = icmp eq i8 %14, 10
%18 = or i1 %16, %17
%19 = sext i32 %12 to i64
%20 = icmp ugt i32 %12, 1022
%21 = select i1 %18, i1 true, i1 %20
%22 = xor i1 %21, true
%23 = icmp ne i32 %15, 0
%24 = select i1 %22, i1 %23, i1 false
br i1 %24, label %28, label %25
25: ; preds = %10
%26 = icmp sgt i32 %12, 3
%27 = and i1 %26, %21
br i1 %27, label %38, label %31
28: ; preds = %10
%29 = add nsw i32 %12, 1
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* @strings.printme, i64 0, i64 %19
store i8 %14, i8* %30
br label %31
31: ; preds = %25, %28
%32 = phi i32 [ %29, %28 ], [ %12, %25 ]
%33 = add nuw nsw i64 %11, 1
%34 = icmp eq i64 %33, %9
br i1 %34, label %43, label %35
35: ; preds = %31, %38
%36 = phi i64 [ %33, %31 ], [ %41, %38 ]
%37 = phi i32 [ %32, %31 ], [ 0, %38 ]
br label %10
38: ; preds = %25
%39 = getelementptr inbounds [1024 x i8], [1024 x i8]* @strings.printme, i64 0, i64 %19
store i8 0, i8* %39
%40 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @strings.printme, i64 0, i64 0))
%41 = add nuw nsw i64 %11, 1
%42 = icmp eq i64 %41, %9
br i1 %42, label %49, label %35
43: ; preds = %31
%44 = icmp sgt i32 %32, 3
br i1 %44, label %45, label %49
45: ; preds = %43
%46 = zext i32 %32 to i64
%47 = getelementptr inbounds [1024 x i8], [1024 x i8]* @strings.printme, i64 0, i64 %46
store i8 0, i8* %47
%48 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @strings.printme, i64 0, i64 0))
br label %49
49: ; preds = %38, %1, %45, %43
%50 = call i32 @free(i8* %4)
ret void
}