char *rdchar(c)
char c;
{
  static char ret[4];
  register char *p;
  ret[0] = ((c & 0377) > 0177) ? '\'' : ' ';
  c &= 0177;
  ret[1] = isprint(c) ? ' ' : '^';
  ret[2] = isprint(c) ? c : c ^ 0100;
  ret[3] = 0;
  for (p = ret; *p == ' '; p++)
    ;
  return (p);
}


x86 assembly (clang, -O0):
<rdchar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%edx
and    $0xff,%edx
mov    $0x20,%eax
mov    $0x27,%ecx
cmp    $0x7f,%edx
cmovg  %ecx,%eax
mov    %al,0x2eeb(%rip)
movsbl -0x1(%rbp),%eax
and    $0x7f,%eax
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%edi
call   1030 <isprint@plt>
mov    %eax,%edx
mov    $0x5e,%eax
mov    $0x20,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,0x2ec1(%rip)
movsbl -0x1(%rbp),%edi
call   1030 <isprint@plt>
cmp    $0x0,%eax
je     1187 <rdchar+0x77>
movsbl -0x1(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    1191 <rdchar+0x81>
movsbl -0x1(%rbp),%eax
xor    $0x40,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %al,0x2e91(%rip)
movb   $0x0,0x2e8b(%rip)
lea    0x2e81(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    11d2 <rdchar+0xc2>
jmp    11c1 <rdchar+0xb1>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11ac <rdchar+0x9c>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rdchar>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebx
test   $0x80,%bl
mov    $0x20,%r14d
mov    $0x27,%eax
cmove  %r14d,%eax
mov    %al,0x2efb(%rip)
mov    %edi,%ebp
and    $0x7f,%ebp
mov    %ebp,%edi
call   1030 <isprint@plt>
test   %eax,%eax
mov    $0x5e,%eax
cmovne %r14d,%eax
mov    %al,0x2edf(%rip)
mov    %ebp,%edi
call   1030 <isprint@plt>
mov    %ebp,%ecx
xor    $0x40,%cl
test   %eax,%eax
movzbl %cl,%eax
cmovne %ebp,%eax
mov    %al,0x2ec6(%rip)
movb   $0x0,0x2ec0(%rip)
lea    0x2eb6(%rip),%rax
test   $0x80,%bl
jne    118a <rdchar+0x7a>
nopl   0x0(%rax,%rax,1)
cmpb   $0x20,0x1(%rax)
lea    0x1(%rax),%rax
je     1180 <rdchar+0x70>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@rdchar.ret = internal global [4 x i8] zeroinitializer
define i8* @rdchar(i32 %0) {
%2 = alloca i8
%3 = alloca i8*
%4 = trunc i32 %0 to i8
store i8 %4, i8* %2
%5 = load i8, i8* %2
%6 = sext i8 %5 to i32
%7 = and i32 %6, 255
%8 = icmp sgt i32 %7, 127
%9 = zext i1 %8 to i64
%10 = select i1 %8, i32 39, i32 32
%11 = trunc i32 %10 to i8
store i8 %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @rdchar.ret, i64 0, i64 0)
%12 = load i8, i8* %2
%13 = sext i8 %12 to i32
%14 = and i32 %13, 127
%15 = trunc i32 %14 to i8
store i8 %15, i8* %2
%16 = load i8, i8* %2
%17 = sext i8 %16 to i32
%18 = call i32 @isprint(i32 %17)
%19 = icmp ne i32 %18, 0
%20 = zext i1 %19 to i64
%21 = select i1 %19, i32 32, i32 94
%22 = trunc i32 %21 to i8
store i8 %22, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @rdchar.ret, i64 0, i64 1)
%23 = load i8, i8* %2
%24 = sext i8 %23 to i32
%25 = call i32 @isprint(i32 %24)
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %1
%28 = load i8, i8* %2
%29 = sext i8 %28 to i32
br label %34
30: ; preds = %1
%31 = load i8, i8* %2
%32 = sext i8 %31 to i32
%33 = xor i32 %32, 64
br label %34
34: ; preds = %30, %27
%35 = phi i32 [ %29, %27 ], [ %33, %30 ]
%36 = trunc i32 %35 to i8
store i8 %36, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @rdchar.ret, i64 0, i64 2)
store i8 0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @rdchar.ret, i64 0, i64 3)
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @rdchar.ret, i64 0, i64 0), i8** %3
br label %37
37: ; preds = %43, %34
%38 = load i8*, i8** %3
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 32
br i1 %41, label %42, label %46
42: ; preds = %37
br label %43
43: ; preds = %42
%44 = load i8*, i8** %3
%45 = getelementptr inbounds i8, i8* %44, i32 1
store i8* %45, i8** %3
br label %37
46: ; preds = %37
%47 = load i8*, i8** %3
ret i8* %47
}

LLVM IR (-O2):
@rdchar.ret = internal global [4 x i8] zeroinitializer
define i8* @rdchar(i32 %0) {
%2 = and i32 %0, 128
%3 = icmp eq i32 %2, 0
%4 = select i1 %3, i8 32, i8 39
store i8 %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @rdchar.ret, i64 0, i64 0)
%5 = and i32 %0, 127
%6 = tail call i32 @isprint(i32 %5)
%7 = icmp eq i32 %6, 0
%8 = select i1 %7, i8 94, i8 32
store i8 %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @rdchar.ret, i64 0, i64 1)
%9 = tail call i32 @isprint(i32 %5)
%10 = icmp eq i32 %9, 0
%11 = xor i32 %5, 64
%12 = select i1 %10, i32 %11, i32 %5
%13 = trunc i32 %12 to i8
store i8 %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @rdchar.ret, i64 0, i64 2)
store i8 0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @rdchar.ret, i64 0, i64 3)
br i1 %3, label %14, label %19
14: ; preds = %1, %14
%15 = phi i8* [ %18, %14 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @rdchar.ret, i64 0, i64 1), %1 ]
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 32
%18 = getelementptr inbounds i8, i8* %15, i64 1
br i1 %17, label %14, label %19
19: ; preds = %14, %1
%20 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @rdchar.ret, i64 0, i64 0), %1 ], [ %15, %14 ]
ret i8* %20
}