#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 /*<<< orphan*/ fputc(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
scalar_t__ isprint(int);
void _q_textout(FILE *fp, void *data, size_t size, size_t max) {
  size_t i;
  for (i = 0; i < size && i < max; i++) {
    int c = ((char *)data)[i];
    if (isprint(c) == 0)
      c = '?';
    fputc(c, fp);
  }
  if (size > max)
    fputs("...", fp);
}


x86 assembly (clang, -O0):
<_q_textout>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rcx
xor    %eax,%eax
cmp    -0x18(%rbp),%rcx
mov    %al,-0x2d(%rbp)
jae    1171 <_q_textout+0x41>
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
setb   %al
mov    %al,-0x2d(%rbp)
mov    -0x2d(%rbp),%al
test   $0x1,%al
jne    1181 <_q_textout+0x51>
jmp    11c6 <_q_textout+0x96>
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%edi
call   1050 <isprint@plt>
cmp    $0x0,%rax
jne    11a9 <_q_textout+0x79>
movl   $0x3f,-0x2c(%rbp)
mov    -0x2c(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1040 <fputc@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1150 <_q_textout+0x20>
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jbe    11e4 <_q_textout+0xb4>
mov    -0x8(%rbp),%rsi
lea    0xe21(%rip),%rdi
call   1030 <fputs@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_q_textout>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,0x8(%rsp)
mov    %rdi,%r12
mov    %rdx,0x10(%rsp)
test   %rdx,%rdx
je     11b7 <_q_textout+0x87>
cmpq   $0x0,0x8(%rsp)
je     11b7 <_q_textout+0x87>
mov    %rsi,%r13
mov    0x8(%rsp),%rax
add    $0xffffffffffffffff,%rax
mov    0x10(%rsp),%rcx
lea    -0x1(%rcx),%rbx
cmp    %rbx,%rax
cmovb  %rax,%rbx
add    $0x1,%rbx
xor    %r14d,%r14d
mov    $0x3f,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl 0x0(%r13,%r14,1),%ebp
mov    %ebp,%edi
call   1040 <isprint@plt>
test   %rax,%rax
cmove  %r15d,%ebp
mov    %ebp,%edi
mov    %r12,%rsi
call   1030 <fputc@plt>
add    $0x1,%r14
cmp    %r14,%rbx
jne    1190 <_q_textout+0x60>
mov    0x10(%rsp),%rax
cmp    0x8(%rsp),%rax
jbe    11ea <_q_textout+0xba>
lea    0xe36(%rip),%rdi
mov    $0x3,%esi
mov    $0x1,%edx
mov    %r12,%rcx
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <fwrite@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"...\00"
define void @_q_textout(i32* %0, i8* %1, i64 %2, i64 %3) {
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i32
store i32* %0, i32** %5
store i8* %1, i8** %6
store i64 %2, i64* %7
store i64 %3, i64* %8
store i64 0, i64* %9
br label %11
11: ; preds = %35, %4
%12 = load i64, i64* %9
%13 = load i64, i64* %7
%14 = icmp ult i64 %12, %13
br i1 %14, label %15, label %19
15: ; preds = %11
%16 = load i64, i64* %9
%17 = load i64, i64* %8
%18 = icmp ult i64 %16, %17
br label %19
19: ; preds = %15, %11
%20 = phi i1 [ false, %11 ], [ %18, %15 ]
br i1 %20, label %21, label %38
21: ; preds = %19
%22 = load i8*, i8** %6
%23 = load i64, i64* %9
%24 = getelementptr inbounds i8, i8* %22, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
store i32 %26, i32* %10
%27 = load i32, i32* %10
%28 = call i64 @isprint(i32 %27)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %21
store i32 63, i32* %10
br label %31
31: ; preds = %30, %21
%32 = load i32, i32* %10
%33 = load i32*, i32** %5
%34 = call i32 @fputc(i32 %32, i32* %33)
br label %35
35: ; preds = %31
%36 = load i64, i64* %9
%37 = add i64 %36, 1
store i64 %37, i64* %9
br label %11
38: ; preds = %19
%39 = load i64, i64* %7
%40 = load i64, i64* %8
%41 = icmp ugt i64 %39, %40
br i1 %41, label %42, label %45
42: ; preds = %38
%43 = load i32*, i32** %5
%44 = call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %43)
br label %45
45: ; preds = %42, %38
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"...\00"
define void @_q_textout(i32* nocapture %0, i8* nocapture %1, i64 %2, i64 %3) {
%5 = icmp ne i64 %2, 0
%6 = icmp ne i64 %3, 0
%7 = and i1 %5, %6
br i1 %7, label %8, label %23
8: ; preds = %4
%9 = add i64 %3, -1
%10 = add i64 %2, -1
%11 = call i64 @llvm.umin.i64(i64 %9, i64 %10)
br label %12
12: ; preds = %8, %12
%13 = phi i64 [ %21, %12 ], [ 0, %8 ]
%14 = getelementptr inbounds i8, i8* %1, i64 %13
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = tail call i64 @isprint(i32 %16)
%18 = icmp eq i64 %17, 0
%19 = select i1 %18, i32 63, i32 %16
%20 = tail call i32 @fputc(i32 %19, i32* %0)
%21 = add nuw i64 %13, 1
%22 = icmp eq i64 %13, %11
br i1 %22, label %23, label %12
23: ; preds = %12, %4
%24 = icmp ugt i64 %2, %3
br i1 %24, label %25, label %27
25: ; preds = %23
%26 = tail call i64 @fwrite(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 3, i64 1, i32* %0)
br label %27
27: ; preds = %25, %23
ret void
}