void strprint(str) char *str;
{
  register unsigned char *s;
  for (s = (unsigned char *)str; s && *s; s++) {
    if (*s < ' ') {
      putchar('^');
      putchar(*s + 64);
    } else if (*s == 127) {
      putchar('^');
      putchar('?');
    } else
      putchar(*s);
  }
}


x86 assembly (clang, -O0):
<strprint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x10(%rbp)
mov    %al,-0x11(%rbp)
je     1144 <strprint+0x34>
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1154 <strprint+0x44>
jmp    11dc <strprint+0xcc>
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x20,%eax
jge    1186 <strprint+0x76>
mov    $0x5e,%edi
mov    $0x0,%al
call   1030 <putchar@plt>
mov    -0x10(%rbp),%rax
movzbl (%rax),%edi
add    $0x40,%edi
mov    $0x0,%al
call   1030 <putchar@plt>
jmp    11c6 <strprint+0xb6>
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x7f,%eax
jne    11b3 <strprint+0xa3>
mov    $0x5e,%edi
mov    $0x0,%al
call   1030 <putchar@plt>
mov    $0x3f,%edi
mov    $0x0,%al
call   1030 <putchar@plt>
jmp    11c1 <strprint+0xb1>
mov    -0x10(%rbp),%rax
movzbl (%rax),%edi
mov    $0x0,%al
call   1030 <putchar@plt>
jmp    11c6 <strprint+0xb6>
jmp    11cb <strprint+0xbb>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1124 <strprint+0x14>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strprint>:
push   %rbx
test   %rdi,%rdi
je     1175 <strprint+0x65>
mov    %rdi,%rbx
mov    (%rdi),%al
test   %al,%al
je     1175 <strprint+0x65>
add    $0x1,%rbx
jmp    1155 <strprint+0x45>
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x5e,%edi
xor    %eax,%eax
call   1030 <putchar@plt>
movzbl -0x1(%rbx),%edi
add    $0x40,%edi
xor    %eax,%eax
call   1030 <putchar@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1175 <strprint+0x65>
cmp    $0x1f,%al
jbe    1130 <strprint+0x20>
cmp    $0x7f,%al
jne    1170 <strprint+0x60>
mov    $0x5e,%edi
xor    %eax,%eax
call   1030 <putchar@plt>
mov    $0x3f,%edi
jmp    1143 <strprint+0x33>
movzbl %al,%edi
jmp    1143 <strprint+0x33>
pop    %rbx
ret

LLVM IR (-O0):
define void @strprint(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
store i8* %4, i8** %3
br label %5
5: ; preds = %42, %1
%6 = load i8*, i8** %3
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %13
8: ; preds = %5
%9 = load i8*, i8** %3
%10 = load i8, i8* %9
%11 = zext i8 %10 to i32
%12 = icmp ne i32 %11, 0
br label %13
13: ; preds = %8, %5
%14 = phi i1 [ false, %5 ], [ %12, %8 ]
br i1 %14, label %15, label %45
15: ; preds = %13
%16 = load i8*, i8** %3
%17 = load i8, i8* %16
%18 = zext i8 %17 to i32
%19 = icmp slt i32 %18, 32
br i1 %19, label %20, label %27
20: ; preds = %15
%21 = call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 94)
%22 = load i8*, i8** %3
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
%25 = add nsw i32 %24, 64
%26 = call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 %25)
br label %41
27: ; preds = %15
%28 = load i8*, i8** %3
%29 = load i8, i8* %28
%30 = zext i8 %29 to i32
%31 = icmp eq i32 %30, 127
br i1 %31, label %32, label %35
32: ; preds = %27
%33 = call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 94)
%34 = call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 63)
br label %40
35: ; preds = %27
%36 = load i8*, i8** %3
%37 = load i8, i8* %36
%38 = zext i8 %37 to i32
%39 = call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 %38)
br label %40
40: ; preds = %35, %32
br label %41
41: ; preds = %40, %20
br label %42
42: ; preds = %41
%43 = load i8*, i8** %3
%44 = getelementptr inbounds i8, i8* %43, i32 1
store i8* %44, i8** %3
br label %5
45: ; preds = %13
ret void
}

LLVM IR (-O2):
define void @strprint(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %26, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %26, label %6
6: ; preds = %3, %20
%7 = phi i8 [ %24, %20 ], [ %4, %3 ]
%8 = phi i8* [ %23, %20 ], [ %0, %3 ]
%9 = icmp ult i8 %7, 32
br i1 %9, label %10, label %15
10: ; preds = %6
%11 = tail call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 94)
%12 = load i8, i8* %8
%13 = zext i8 %12 to i32
%14 = add nuw nsw i32 %13, 64
br label %20
15: ; preds = %6
%16 = zext i8 %7 to i32
%17 = icmp eq i8 %7, 127
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = tail call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 94)
br label %20
20: ; preds = %15, %10, %18
%21 = phi i32 [ %14, %10 ], [ 63, %18 ], [ %16, %15 ]
%22 = tail call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 %21)
%23 = getelementptr inbounds i8, i8* %8, i64 1
%24 = load i8, i8* %23
%25 = icmp eq i8 %24, 0
br i1 %25, label %26, label %6
26: ; preds = %20, %3, %1
ret void
}