#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 */

/* Variables and functions */
int /*<<< orphan*/ putchar(unsigned char);
void strprint(char *str) {
  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    11d5 <strprint+0xc5>
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x20,%eax
jge    1185 <strprint+0x75>
mov    $0x5e,%edi
call   1030 <putchar@plt>
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
add    $0x40,%eax
movzbl %al,%edi
call   1030 <putchar@plt>
jmp    11bf <strprint+0xaf>
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x7f,%eax
jne    11ae <strprint+0x9e>
mov    $0x5e,%edi
call   1030 <putchar@plt>
mov    $0x3f,%edi
call   1030 <putchar@plt>
jmp    11ba <strprint+0xaa>
mov    -0x10(%rbp),%rax
movzbl (%rax),%edi
call   1030 <putchar@plt>
jmp    11bf <strprint+0xaf>
jmp    11c4 <strprint+0xb4>
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     1169 <strprint+0x59>
mov    %rdi,%rbx
mov    (%rdi),%al
test   %al,%al
je     1169 <strprint+0x59>
add    $0x1,%rbx
jmp    1153 <strprint+0x43>
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x5e,%edi
call   1030 <putchar@plt>
movzbl -0x1(%rbx),%eax
add    $0x40,%al
movzbl %al,%edi
call   1030 <putchar@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1169 <strprint+0x59>
cmp    $0x1f,%al
jbe    1130 <strprint+0x20>
cmp    $0x7f,%al
jne    1140 <strprint+0x30>
mov    $0x5e,%edi
call   1030 <putchar@plt>
mov    $0x3f,%al
jmp    1140 <strprint+0x30>
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 %28
20: ; preds = %15
%21 = call i32 @putchar(i8 zeroext 94)
%22 = load i8*, i8** %3
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
%25 = add nsw i32 %24, 64
%26 = trunc i32 %25 to i8
%27 = call i32 @putchar(i8 zeroext %26)
br label %41
28: ; preds = %15
%29 = load i8*, i8** %3
%30 = load i8, i8* %29
%31 = zext i8 %30 to i32
%32 = icmp eq i32 %31, 127
br i1 %32, label %33, label %36
33: ; preds = %28
%34 = call i32 @putchar(i8 zeroext 94)
%35 = call i32 @putchar(i8 zeroext 63)
br label %40
36: ; preds = %28
%37 = load i8*, i8** %3
%38 = load i8, i8* %37
%39 = call i32 @putchar(i8 zeroext %38)
br label %40
40: ; preds = %36, %33
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 %24, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %24, label %6
6: ; preds = %3, %18
%7 = phi i8 [ %22, %18 ], [ %4, %3 ]
%8 = phi i8* [ %21, %18 ], [ %0, %3 ]
%9 = icmp ult i8 %7, 32
br i1 %9, label %10, label %14
10: ; preds = %6
%11 = tail call i32 @putchar(i8 zeroext 94)
%12 = load i8, i8* %8
%13 = add i8 %12, 64
br label %18
14: ; preds = %6
%15 = icmp eq i8 %7, 127
br i1 %15, label %16, label %18
16: ; preds = %14
%17 = tail call i32 @putchar(i8 zeroext 94)
br label %18
18: ; preds = %14, %10, %16
%19 = phi i8 [ %13, %10 ], [ 63, %16 ], [ %7, %14 ]
%20 = tail call i32 @putchar(i8 zeroext %19)
%21 = getelementptr inbounds i8, i8* %8, i64 1
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 0
br i1 %23, label %24, label %6
24: ; preds = %18, %3, %1
ret void
}