#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 */
typedef int cc_t;

/* Variables and functions */
scalar_t__ _POSIX_VDISABLE;
const char *control(cc_t c) {
  static char buf[5];
  unsigned int uic;
  uic = (unsigned int)c;
  if (uic == 0x7f)
    return ("^?");
  if (c == (cc_t)_POSIX_VDISABLE) {
    return "off";
  }
  if (uic >= 0x80) {
    buf[0] = '\\';
    buf[1] = ((c >> 6) & 07) + '0';
    buf[2] = ((c >> 3) & 07) + '0';
    buf[3] = (c & 07) + '0';
    buf[4] = 0;
  } else if (uic >= 0x20) {
    buf[0] = c;
    buf[1] = 0;
  } else {
    buf[0] = '^';
    buf[1] = '@' + c;
    buf[2] = 0;
  }
  return (buf);
}


x86 assembly (clang, -O0):
<control>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x7f,-0x10(%rbp)
jne    1127 <control+0x27>
lea    0xee2(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11e8 <control+0xe8>
mov    -0xc(%rbp),%eax
mov    0x2eb7(%rip),%rcx
mov    (%rcx),%rcx
cmp    %ecx,%eax
jne    114c <control+0x4c>
lea    0xec0(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11e8 <control+0xe8>
cmpl   $0x80,-0x10(%rbp)
jb     119f <control+0x9f>
movb   $0x5c,0x2ec8(%rip)
mov    -0xc(%rbp),%eax
sar    $0x6,%eax
and    $0x7,%eax
add    $0x30,%eax
mov    %al,0x2eb7(%rip)
mov    -0xc(%rbp),%eax
sar    $0x3,%eax
and    $0x7,%eax
add    $0x30,%eax
mov    %al,0x2ea6(%rip)
mov    -0xc(%rbp),%eax
and    $0x7,%eax
add    $0x30,%eax
mov    %al,0x2e98(%rip)
movb   $0x0,0x2e92(%rip)
jmp    11dd <control+0xdd>
cmpl   $0x20,-0x10(%rbp)
jb     11be <control+0xbe>
mov    -0xc(%rbp),%eax
mov    %al,0x2e76(%rip)
movb   $0x0,0x2e70(%rip)
jmp    11d8 <control+0xd8>
movb   $0x5e,0x2e63(%rip)
mov    -0xc(%rbp),%eax
add    $0x40,%eax
mov    %al,0x2e58(%rip)
movb   $0x0,0x2e52(%rip)
jmp    11dd <control+0xdd>
lea    0x2e44(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<control>:
cmp    $0x7f,%edi
jne    110d <control+0xd>
lea    0xef4(%rip),%rax
ret
mov    0x2ed4(%rip),%rax
cmp    %edi,(%rax)
jne    1120 <control+0x20>
lea    0xee4(%rip),%rax
ret
cmp    $0x80,%edi
jb     1165 <control+0x65>
movb   $0x5c,0x2ef9(%rip)
mov    %edi,%eax
shr    $0x6,%eax
and    $0x7,%al
or     $0x30,%al
mov    %al,0x2eeb(%rip)
mov    %edi,%eax
shr    $0x3,%al
and    $0x7,%al
or     $0x30,%al
mov    %al,0x2edd(%rip)
and    $0x7,%dil
or     $0x30,%dil
mov    %dil,0x2ecf(%rip)
lea    0x2ec9(%rip),%rax
jmp    1193 <control+0x93>
cmp    $0x20,%edi
jb     117a <control+0x7a>
mov    %dil,0x2eb7(%rip)
lea    0x2eb1(%rip),%rax
jmp    1193 <control+0x93>
movb   $0x5e,0x2ea7(%rip)
add    $0x40,%dil
mov    %dil,0x2e9d(%rip)
lea    0x2e97(%rip),%rax
movb   $0x0,(%rax)
lea    0x2e8b(%rip),%rax
ret

LLVM IR (-O0):
@control.buf = internal global [5 x i8] zeroinitializer
@.str = [3 x i8] c"^?\00"
@_POSIX_VDISABLE = global i64 0
@.str.1 = [4 x i8] c"off\00"
define i8* @control(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
%5 = load i32, i32* %3
store i32 %5, i32* %4
%6 = load i32, i32* %4
%7 = icmp eq i32 %6, 127
br i1 %7, label %8, label %9
8: ; preds = %1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %2
br label %45
9: ; preds = %1
%10 = load i32, i32* %3
%11 = load i64, i64* @_POSIX_VDISABLE
%12 = trunc i64 %11 to i32
%13 = icmp eq i32 %10, %12
br i1 %13, label %14, label %15
14: ; preds = %9
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %45
15: ; preds = %9
%16 = load i32, i32* %4
%17 = icmp uge i32 %16, 128
br i1 %17, label %18, label %33
18: ; preds = %15
store i8 92, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @control.buf, i64 0, i64 0)
%19 = load i32, i32* %3
%20 = ashr i32 %19, 6
%21 = and i32 %20, 7
%22 = add nsw i32 %21, 48
%23 = trunc i32 %22 to i8
store i8 %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @control.buf, i64 0, i64 1)
%24 = load i32, i32* %3
%25 = ashr i32 %24, 3
%26 = and i32 %25, 7
%27 = add nsw i32 %26, 48
%28 = trunc i32 %27 to i8
store i8 %28, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @control.buf, i64 0, i64 2)
%29 = load i32, i32* %3
%30 = and i32 %29, 7
%31 = add nsw i32 %30, 48
%32 = trunc i32 %31 to i8
store i8 %32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @control.buf, i64 0, i64 3)
store i8 0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @control.buf, i64 0, i64 4)
br label %44
33: ; preds = %15
%34 = load i32, i32* %4
%35 = icmp uge i32 %34, 32
br i1 %35, label %36, label %39
36: ; preds = %33
%37 = load i32, i32* %3
%38 = trunc i32 %37 to i8
store i8 %38, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @control.buf, i64 0, i64 0)
store i8 0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @control.buf, i64 0, i64 1)
br label %43
39: ; preds = %33
store i8 94, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @control.buf, i64 0, i64 0)
%40 = load i32, i32* %3
%41 = add nsw i32 64, %40
%42 = trunc i32 %41 to i8
store i8 %42, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @control.buf, i64 0, i64 1)
store i8 0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @control.buf, i64 0, i64 2)
br label %43
43: ; preds = %39, %36
br label %44
44: ; preds = %43, %18
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @control.buf, i64 0, i64 0), i8** %2
br label %45
45: ; preds = %44, %14, %8
%46 = load i8*, i8** %2
ret i8* %46
}

LLVM IR (-O2):
@control.buf = internal global [5 x i8] zeroinitializer
@.str = [3 x i8] c"^?\00"
@_POSIX_VDISABLE = global i64 0
@.str.1 = [4 x i8] c"off\00"
define i8* @control(i32 %0) {
%2 = icmp eq i32 %0, 127
br i1 %2, label %29, label %3
3: ; preds = %1
%4 = load i64, i64* @_POSIX_VDISABLE
%5 = trunc i64 %4 to i32
%6 = icmp eq i32 %5, %0
br i1 %6, label %29, label %7
7: ; preds = %3
%8 = icmp ugt i32 %0, 127
br i1 %8, label %9, label %20
9: ; preds = %7
store i8 92, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @control.buf, i64 0, i64 0)
%10 = lshr i32 %0, 6
%11 = trunc i32 %10 to i8
%12 = and i8 %11, 7
%13 = or i8 %12, 48
store i8 %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @control.buf, i64 0, i64 1)
%14 = trunc i32 %0 to i8
%15 = lshr i8 %14, 3
%16 = and i8 %15, 7
%17 = or i8 %16, 48
store i8 %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @control.buf, i64 0, i64 2)
%18 = and i8 %14, 7
%19 = or i8 %18, 48
store i8 %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @control.buf, i64 0, i64 3)
br label %27
20: ; preds = %7
%21 = icmp ugt i32 %0, 31
br i1 %21, label %22, label %24
22: ; preds = %20
%23 = trunc i32 %0 to i8
store i8 %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @control.buf, i64 0, i64 0)
br label %27
24: ; preds = %20
store i8 94, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @control.buf, i64 0, i64 0)
%25 = trunc i32 %0 to i8
%26 = add nuw nsw i8 %25, 64
store i8 %26, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @control.buf, i64 0, i64 1)
br label %27
27: ; preds = %22, %24, %9
%28 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @control.buf, i64 0, i64 4), %9 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @control.buf, i64 0, i64 2), %24 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @control.buf, i64 0, i64 1), %22 ]
store i8 0, i8* %28
br label %29
29: ; preds = %27, %3, %1
%30 = phi i8* [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), %3 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @control.buf, i64 0, i64 0), %27 ]
ret i8* %30
}