#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 zasprintf(char **, char *, ...);
int make_char_printable(char **buf, size_t c) {
  if (c == '\0')
    return zasprintf(buf, "^@");
  else if (c <= '\32')
    return zasprintf(buf, "^%c", 'A' + c - 1);
  else
    return zasprintf(buf, "\\%o", c & 0xff);
}


x86 assembly (clang, -O0):
<make_char_printable>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1145 <make_char_printable+0x35>
mov    -0x10(%rbp),%rdi
lea    0xeca(%rip),%rsi
mov    $0x0,%al
call   1030 <zasprintf@plt>
mov    %eax,-0x4(%rbp)
jmp    1196 <make_char_printable+0x86>
cmpq   $0x1a,-0x18(%rbp)
ja     1176 <make_char_printable+0x66>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
add    $0x41,%rdx
sub    $0x1,%rdx
lea    0xe9c(%rip),%rsi
mov    $0x0,%al
call   1030 <zasprintf@plt>
mov    %eax,-0x4(%rbp)
jmp    1196 <make_char_printable+0x86>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
and    $0xff,%rdx
lea    0xe7b(%rip),%rsi
mov    $0x0,%al
call   1030 <zasprintf@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_char_printable>:
test   %rsi,%rsi
je     1130 <make_char_printable+0x20>
mov    %rsi,%rdx
cmp    $0x1a,%rsi
ja     113e <make_char_printable+0x2e>
add    $0x40,%rdx
lea    0xeda(%rip),%rsi
xor    %eax,%eax
jmp    1030 <zasprintf@plt>
lea    0xec9(%rip),%rsi
xor    %eax,%eax
jmp    1030 <zasprintf@plt>
movzbl %dl,%edx
lea    0xebf(%rip),%rsi
xor    %eax,%eax
jmp    1030 <zasprintf@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"^@\00"
@.str.1 = [4 x i8] c"^%c\00"
@.str.2 = [4 x i8] c"\\%o\00"
define i32 @make_char_printable(i8** %0, i64 %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i64
store i8** %0, i8*** %4
store i64 %1, i64* %5
%6 = load i64, i64* %5
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load i8**, i8*** %4
%10 = call i32 (i8**, i8*, ...) @zasprintf(i8** %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 %10, i32* %3
br label %25
11: ; preds = %2
%12 = load i64, i64* %5
%13 = icmp ule i64 %12, 26
br i1 %13, label %14, label %20
14: ; preds = %11
%15 = load i8**, i8*** %4
%16 = load i64, i64* %5
%17 = add i64 65, %16
%18 = sub i64 %17, 1
%19 = call i32 (i8**, i8*, ...) @zasprintf(i8** %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 %18)
store i32 %19, i32* %3
br label %25
20: ; preds = %11
%21 = load i8**, i8*** %4
%22 = load i64, i64* %5
%23 = and i64 %22, 255
%24 = call i32 (i8**, i8*, ...) @zasprintf(i8** %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64 %23)
store i32 %24, i32* %3
br label %25
25: ; preds = %20, %14, %8
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
@.str = [3 x i8] c"^@\00"
@.str.1 = [4 x i8] c"^%c\00"
@.str.2 = [4 x i8] c"\\%o\00"
define i32 @make_char_printable(i8** %0, i64 %1) {
%3 = icmp eq i64 %1, 0
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 (i8**, i8*, ...) @zasprintf(i8** %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %14
6: ; preds = %2
%7 = icmp ult i64 %1, 27
br i1 %7, label %8, label %11
8: ; preds = %6
%9 = add nuw nsw i64 %1, 64
%10 = tail call i32 (i8**, i8*, ...) @zasprintf(i8** %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 %9)
br label %14
11: ; preds = %6
%12 = and i64 %1, 255
%13 = tail call i32 (i8**, i8*, ...) @zasprintf(i8** %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64 %12)
br label %14
14: ; preds = %11, %8, %4
%15 = phi i32 [ %5, %4 ], [ %10, %8 ], [ %13, %11 ]
ret i32 %15
}