#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 */
scalar_t__ isprint(char);
char *unctrl(char c) {
  static char buf[3];
  if (isprint(c)) {
    buf[0] = c;
    buf[1] = '\0';
  } else if (c == 0177) {
    buf[0] = '^';
    buf[1] = '?';
  } else {
    buf[0] = '^';
    buf[1] = c + 'A' - 1;
  }
  return buf;
}


x86 assembly (clang, -O0):
<unctrl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%edi
call   1030 <isprint@plt>
cmp    $0x0,%rax
je     1146 <unctrl+0x36>
mov    -0x1(%rbp),%al
mov    %al,0x2eef(%rip)
movb   $0x0,0x2ee9(%rip)
jmp    1182 <unctrl+0x72>
movsbl -0x1(%rbp),%eax
cmp    $0x7f,%eax
jne    1166 <unctrl+0x56>
movb   $0x5e,0x2ecf(%rip)
movb   $0x3f,0x2ec9(%rip)
jmp    117d <unctrl+0x6d>
movb   $0x5e,0x2ebc(%rip)
movsbl -0x1(%rbp),%eax
add    $0x41,%eax
sub    $0x1,%eax
mov    %al,0x2ead(%rip)
jmp    1182 <unctrl+0x72>
lea    0x2ea0(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unctrl>:
push   %rbx
mov    %edi,%ebx
call   1030 <isprint@plt>
test   %rax,%rax
je     1127 <unctrl+0x17>
mov    %bl,0x2f06(%rip)
xor    %eax,%eax
jmp    113f <unctrl+0x2f>
lea    0x40(%rbx),%eax
cmp    $0x7f,%bl
movb   $0x5e,0x2ef5(%rip)
movzbl %al,%ecx
mov    $0x3f,%eax
cmovne %ecx,%eax
mov    %al,0x2ee5(%rip)
lea    0x2edd(%rip),%rax
pop    %rbx
ret

LLVM IR (-O0):
@unctrl.buf = internal global [3 x i8] zeroinitializer
define i8* @unctrl(i8 signext %0) {
%2 = alloca i8
store i8 %0, i8* %2
%3 = load i8, i8* %2
%4 = call i64 @isprint(i8 signext %3)
%5 = icmp ne i64 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = load i8, i8* %2
store i8 %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @unctrl.buf, i64 0, i64 0)
store i8 0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @unctrl.buf, i64 0, i64 1)
br label %20
8: ; preds = %1
%9 = load i8, i8* %2
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 127
br i1 %11, label %12, label %13
12: ; preds = %8
store i8 94, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @unctrl.buf, i64 0, i64 0)
store i8 63, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @unctrl.buf, i64 0, i64 1)
br label %19
13: ; preds = %8
store i8 94, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @unctrl.buf, i64 0, i64 0)
%14 = load i8, i8* %2
%15 = sext i8 %14 to i32
%16 = add nsw i32 %15, 65
%17 = sub nsw i32 %16, 1
%18 = trunc i32 %17 to i8
store i8 %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @unctrl.buf, i64 0, i64 1)
br label %19
19: ; preds = %13, %12
br label %20
20: ; preds = %19, %6
ret i8* getelementptr inbounds ([3 x i8], [3 x i8]* @unctrl.buf, i64 0, i64 0)
}

LLVM IR (-O2):
@unctrl.buf = internal global [3 x i8] zeroinitializer
define i8* @unctrl(i8 signext %0) {
%2 = tail call i64 @isprint(i8 signext %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %5, label %4
4: ; preds = %1
store i8 %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @unctrl.buf, i64 0, i64 0)
br label %9
5: ; preds = %1
%6 = icmp eq i8 %0, 127
store i8 94, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @unctrl.buf, i64 0, i64 0)
%7 = add i8 %0, 64
%8 = select i1 %6, i8 63, i8 %7
br label %9
9: ; preds = %5, %4
%10 = phi i8 [ 0, %4 ], [ %8, %5 ]
store i8 %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @unctrl.buf, i64 0, i64 1)
ret i8* getelementptr inbounds ([3 x i8], [3 x i8]* @unctrl.buf, i64 0, i64 0)
}