#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*/ printf(char *, ...);
void printx(const char *string) {
  for (const char *c = string; *c != 0; ++c) {
    if (' ' > *c || '~' < *c) {
      printf("\\%02x", *c);
    } else {
      printf("%c", *c);
    }
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<printx>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11a1 <printx+0x91>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x20,%eax
cmp    %ecx,%eax
jg     115c <printx+0x4c>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x7e,%eax
cmp    %ecx,%eax
jge    1176 <printx+0x66>
mov    -0x10(%rbp),%rax
movsbl (%rax),%esi
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    118b <printx+0x7b>
mov    -0x10(%rbp),%rax
movsbl (%rax),%esi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1190 <printx+0x80>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1124 <printx+0x14>
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printx>:
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%al
test   %al,%al
je     1168 <printx+0x48>
mov    %rdi,%rbx
add    $0x1,%rbx
lea    0xec8(%rip),%r14
jmp    1152 <printx+0x32>
nopw   0x0(%rax,%rax,1)
mov    %esi,%edi
call   1030 <putchar@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1168 <printx+0x48>
movsbl %al,%esi
lea    -0x7f(%rsi),%eax
cmp    $0xa0,%al
ja     1140 <printx+0x20>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1147 <printx+0x27>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"\\%02x\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @printx(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 = %31, %1
%6 = load i8*, i8** %3
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %34
10: ; preds = %5
%11 = load i8*, i8** %3
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp sgt i32 32, %13
br i1 %14, label %20, label %15
15: ; preds = %10
%16 = load i8*, i8** %3
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp slt i32 126, %18
br i1 %19, label %20, label %25
20: ; preds = %15, %10
%21 = load i8*, i8** %3
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %23)
br label %30
25: ; preds = %15
%26 = load i8*, i8** %3
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %25, %20
br label %31
31: ; preds = %30
%32 = load i8*, i8** %3
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %3
br label %5
34: ; preds = %5
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"\\%02x\00"
define void @printx(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %16, %1
%5 = tail call i32 @putchar(i32 10)
ret void
6: ; preds = %1, %16
%7 = phi i8 [ %18, %16 ], [ %2, %1 ]
%8 = phi i8* [ %17, %16 ], [ %0, %1 ]
%9 = sext i8 %7 to i32
%10 = add i8 %7, -127
%11 = icmp ult i8 %10, -95
br i1 %11, label %12, label %14
12: ; preds = %6
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %9)
br label %16
14: ; preds = %6
%15 = tail call i32 @putchar(i32 %9)
br label %16
16: ; preds = %12, %14
%17 = getelementptr inbounds i8, i8* %8, i64 1
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 0
br i1 %19, label %4, label %6
}