#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 EOF;
int getc(int /*<<< orphan*/ *);
scalar_t__ isprint(int);
scalar_t__ isspace(int);
int /*<<< orphan*/ putchar(char);
scalar_t__ strchr(char *, int);
void dostring(FILE *fp) {
  int c;
  while ((c = getc(fp)) != EOF) {
    if (c == '\0' || strchr("\"\\>", c) || !(isprint(c) || isspace(c)))
      break;
    putchar(c);
  }
  putchar('\n');
}


x86 assembly (clang, -O0):
<dostring>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <getc@plt>
mov    %eax,-0xc(%rbp)
mov    0x2e79(%rip),%rcx
cmp    (%rcx),%eax
je     11d3 <dostring+0x83>
cmpl   $0x0,-0xc(%rbp)
je     11be <dostring+0x6e>
mov    -0xc(%rbp),%esi
lea    0xe75(%rip),%rdi
call   1040 <strchr@plt>
cmp    $0x0,%rax
jne    11be <dostring+0x6e>
mov    -0xc(%rbp),%edi
call   1060 <isprint@plt>
cmp    $0x0,%rax
jne    11c3 <dostring+0x73>
mov    -0xc(%rbp),%edi
call   1050 <isspace@plt>
cmp    $0x0,%rax
jne    11c3 <dostring+0x73>
jmp    11d3 <dostring+0x83>
mov    -0xc(%rbp),%eax
movsbl %al,%edi
call   1030 <putchar@plt>
jmp    115c <dostring+0xc>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dostring>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1070 <getc@plt>
test   %eax,%eax
je     11c3 <dostring+0x73>
mov    %eax,%ebp
mov    0x2e7c(%rip),%r15
cmp    (%r15),%eax
je     11c3 <dostring+0x73>
lea    0xe88(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebp,%esi
call   1040 <strchr@plt>
test   %rax,%rax
jne    11c3 <dostring+0x73>
mov    %ebp,%edi
call   1060 <isprint@plt>
test   %rax,%rax
jne    11a7 <dostring+0x57>
mov    %ebp,%edi
call   1050 <isspace@plt>
test   %rax,%rax
je     11c3 <dostring+0x73>
movsbl %bpl,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
call   1070 <getc@plt>
test   %eax,%eax
je     11c3 <dostring+0x73>
mov    %eax,%ebp
cmp    (%r15),%eax
jne    1180 <dostring+0x30>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@EOF = global i32 0
@.str = [4 x i8] c"\22\\>\00"
define void @dostring(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
store i32* %0, i32** %2
br label %4
4: ; preds = %25, %1
%5 = load i32*, i32** %2
%6 = call i32 @getc(i32* %5)
store i32 %6, i32* %3
%7 = load i32, i32* @EOF
%8 = icmp ne i32 %6, %7
br i1 %8, label %9, label %29
9: ; preds = %4
%10 = load i32, i32* %3
%11 = icmp eq i32 %10, 0
br i1 %11, label %24, label %12
12: ; preds = %9
%13 = load i32, i32* %3
%14 = call i64 @strchr(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %24, label %16
16: ; preds = %12
%17 = load i32, i32* %3
%18 = call i64 @isprint(i32 %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %25, label %20
20: ; preds = %16
%21 = load i32, i32* %3
%22 = call i64 @isspace(i32 %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %25, label %24
24: ; preds = %20, %12, %9
br label %29
25: ; preds = %20, %16
%26 = load i32, i32* %3
%27 = trunc i32 %26 to i8
%28 = call i32 @putchar(i8 signext %27)
br label %4
29: ; preds = %24, %4
%30 = call i32 @putchar(i8 signext 10)
ret void
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [4 x i8] c"\22\\>\00"
define void @dostring(i32* nocapture %0) {
%2 = tail call i32 @getc(i32* %0)
%3 = load i32, i32* @EOF
%4 = icmp eq i32 %2, %3
%5 = icmp eq i32 %2, 0
%6 = or i1 %5, %4
br i1 %6, label %25, label %7
7: ; preds = %1, %17
%8 = phi i32 [ %20, %17 ], [ %2, %1 ]
%9 = tail call i64 @strchr(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %25
11: ; preds = %7
%12 = tail call i64 @isprint(i32 %8)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = tail call i64 @isspace(i32 %8)
%16 = icmp eq i64 %15, 0
br i1 %16, label %25, label %17
17: ; preds = %14, %11
%18 = trunc i32 %8 to i8
%19 = tail call i32 @putchar(i8 signext %18)
%20 = tail call i32 @getc(i32* %0)
%21 = load i32, i32* @EOF
%22 = icmp eq i32 %20, %21
%23 = icmp eq i32 %20, 0
%24 = or i1 %23, %22
br i1 %24, label %25, label %7
25: ; preds = %17, %14, %7, %1
%26 = tail call i32 @putchar(i8 signext 10)
ret void
}