#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*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, unsigned char);
int /*<<< orphan*/ fputc(unsigned char, int /*<<< orphan*/ *);
scalar_t__ strchr(char *, unsigned char);
void feputs(char *line, FILE *fp) {
  unsigned char *p;
  for (p = (unsigned char *)line; *p; p++) {
    if (strchr("\t\r\n", *p) || (*p >= 32 && *p <= 127) || (*p >= 160)) {
      fputc(*p, fp);
    } else {
      fprintf(fp, "^%c", (*p & 0x1f) + 'A' - 1);
    }
  }
  fflush(fp);
}


x86 assembly (clang, -O0):
<feputs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     1204 <feputs+0xc4>
mov    -0x18(%rbp),%rax
lea    0xe90(%rip),%rdi
movzbl (%rax),%esi
call   1030 <strchr@plt>
cmp    $0x0,%rax
jne    11b4 <feputs+0x74>
mov    -0x18(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x20,%eax
jl     11a2 <feputs+0x62>
mov    -0x18(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x7f,%eax
jle    11b4 <feputs+0x74>
mov    -0x18(%rbp),%rax
movzbl (%rax),%eax
cmp    $0xa0,%eax
jl     11cb <feputs+0x8b>
mov    -0x18(%rbp),%rax
mov    (%rax),%al
mov    -0x10(%rbp),%rsi
movzbl %al,%edi
call   1040 <fputc@plt>
jmp    11ee <feputs+0xae>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
movzbl (%rax),%eax
and    $0x1f,%eax
add    $0x41,%eax
sub    $0x1,%eax
lea    0xe1e(%rip),%rsi
movzbl %al,%edx
call   1050 <fprintf@plt>
jmp    11f3 <feputs+0xb3>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1158 <feputs+0x18>
mov    -0x10(%rbp),%rdi
call   1060 <fflush@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<feputs>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    (%rdi),%al
test   %al,%al
je     11ba <feputs+0x7a>
mov    %rdi,%rbx
add    $0x1,%rbx
lea    0xea1(%rip),%r15
lea    0xe9e(%rip),%r12
jmp    1186 <feputs+0x46>
nopl   0x0(%rax,%rax,1)
movzbl %cl,%edi
mov    %r14,%rsi
call   1040 <fputc@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     11ba <feputs+0x7a>
movzbl %al,%esi
mov    %r15,%rdi
call   1030 <strchr@plt>
movzbl -0x1(%rbx),%ecx
test   %rax,%rax
jne    1170 <feputs+0x30>
cmp    $0x1f,%cl
jg     1170 <feputs+0x30>
cmp    $0xa0,%cl
jae    1170 <feputs+0x30>
and    $0x1f,%cl
or     $0x40,%cl
movzbl %cl,%edx
mov    %r14,%rdi
mov    %r12,%rsi
call   1050 <fprintf@plt>
jmp    117b <feputs+0x3b>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1060 <fflush@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"\09\0D\0A\00"
@.str.1 = [4 x i8] c"^%c\00"
define void @feputs(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i8*
store i8* %0, i8** %3
store i32* %1, i32** %4
%6 = load i8*, i8** %3
store i8* %6, i8** %5
br label %7
7: ; preds = %47, %2
%8 = load i8*, i8** %5
%9 = load i8, i8* %8
%10 = icmp ne i8 %9, 0
br i1 %10, label %11, label %50
11: ; preds = %7
%12 = load i8*, i8** %5
%13 = load i8, i8* %12
%14 = call i64 @strchr(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 zeroext %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %31, label %16
16: ; preds = %11
%17 = load i8*, i8** %5
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = icmp sge i32 %19, 32
br i1 %20, label %21, label %26
21: ; preds = %16
%22 = load i8*, i8** %5
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
%25 = icmp sle i32 %24, 127
br i1 %25, label %31, label %26
26: ; preds = %21, %16
%27 = load i8*, i8** %5
%28 = load i8, i8* %27
%29 = zext i8 %28 to i32
%30 = icmp sge i32 %29, 160
br i1 %30, label %31, label %36
31: ; preds = %26, %21, %11
%32 = load i8*, i8** %5
%33 = load i8, i8* %32
%34 = load i32*, i32** %4
%35 = call i32 @fputc(i8 zeroext %33, i32* %34)
br label %46
36: ; preds = %26
%37 = load i32*, i32** %4
%38 = load i8*, i8** %5
%39 = load i8, i8* %38
%40 = zext i8 %39 to i32
%41 = and i32 %40, 31
%42 = add nsw i32 %41, 65
%43 = sub nsw i32 %42, 1
%44 = trunc i32 %43 to i8
%45 = call i32 @fprintf(i32* %37, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %44)
br label %46
46: ; preds = %36, %31
br label %47
47: ; preds = %46
%48 = load i8*, i8** %5
%49 = getelementptr inbounds i8, i8* %48, i32 1
store i8* %49, i8** %5
br label %7
50: ; preds = %7
%51 = load i32*, i32** %4
%52 = call i32 @fflush(i32* %51)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"\09\0D\0A\00"
@.str.1 = [4 x i8] c"^%c\00"
define void @feputs(i8* nocapture %0, i32* nocapture %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %25, label %5
5: ; preds = %2, %21
%6 = phi i8 [ %23, %21 ], [ %3, %2 ]
%7 = phi i8* [ %22, %21 ], [ %0, %2 ]
%8 = tail call i64 @strchr(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 zeroext %6)
%9 = icmp eq i64 %8, 0
%10 = load i8, i8* %7
br i1 %9, label %11, label %15
11: ; preds = %5
%12 = icmp sgt i8 %10, 31
%13 = icmp ugt i8 %10, -97
%14 = or i1 %12, %13
br i1 %14, label %15, label %17
15: ; preds = %5, %11
%16 = tail call i32 @fputc(i8 zeroext %10, i32* %1)
br label %21
17: ; preds = %11
%18 = and i8 %10, 31
%19 = or i8 %18, 64
%20 = tail call i32 @fprintf(i32* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %19)
br label %21
21: ; preds = %15, %17
%22 = getelementptr inbounds i8, i8* %7, i64 1
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 0
br i1 %24, label %25, label %5
25: ; preds = %21, %2
%26 = tail call i32 @fflush(i32* %1)
ret void
}