#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 putcp(int c, int *sp) {
  switch (c) {
  case '=':
  case '0':
  case '1':
  case '2':
  case '3':
  case '4':
  case '5':
  case '6':
  case '7':
  case '8':
  case '9':
    goto x2;
  case '\\':
  case '"':
  case '-':
  case '+':
    printf("\\%c", c);
    *sp = 0;
    break;
  default:
    if (c >= 256) {
      if (!*sp)
        printf(" ");
      printf("0x%04X ", c);
      *sp = 1;
      break;
    } else if (c <= 0x20 || c >= 0x7F) {
    x2:
      if (!*sp)
        printf(" ");
      printf("0x%02X ", c);
      *sp = 1;
      break;
    } else {
      printf("%c", c);
      *sp = 0;
      break;
    }
  }
}


x86 assembly (clang, -O0):
<putcp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
sub    $0x22,%eax
je     1190 <putcp+0x80>
jmp    1133 <putcp+0x23>
mov    -0x14(%rbp),%eax
sub    $0x2b,%eax
je     1190 <putcp+0x80>
jmp    1144 <putcp+0x34>
mov    -0x14(%rbp),%eax
sub    $0x2d,%eax
je     1190 <putcp+0x80>
jmp    1155 <putcp+0x45>
mov    -0x14(%rbp),%eax
add    $0xffffffd0,%eax
sub    $0xa,%eax
jb     118b <putcp+0x7b>
jmp    1169 <putcp+0x59>
mov    -0x14(%rbp),%eax
sub    $0x3d,%eax
je     118b <putcp+0x7b>
jmp    117a <putcp+0x6a>
mov    -0x14(%rbp),%eax
sub    $0x5c,%eax
je     1190 <putcp+0x80>
jmp    11b0 <putcp+0xa0>
jmp    1211 <putcp+0x101>
mov    -0x4(%rbp),%esi
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
jmp    1267 <putcp+0x157>
cmpl   $0x100,-0x4(%rbp)
jl     11f8 <putcp+0xe8>
mov    -0x10(%rbp),%rax
cmpl   $0x0,(%rax)
jne    11d8 <putcp+0xc8>
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%esi
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
jmp    1267 <putcp+0x157>
cmpl   $0x20,-0x4(%rbp)
jle    120c <putcp+0xfc>
cmpl   $0x7f,-0x4(%rbp)
jl     124c <putcp+0x13c>
jmp    1211 <putcp+0x101>
mov    -0x10(%rbp),%rax
cmpl   $0x0,(%rax)
jne    122c <putcp+0x11c>
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%esi
lea    0xdd6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
jmp    1267 <putcp+0x157>
mov    -0x4(%rbp),%esi
lea    0xdab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<putcp>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebx
lea    -0x22(%rbx),%eax
cmp    $0x3a,%eax
ja     118d <putcp+0x6d>
mov    $0x8ffc000,%ecx
bt     %rax,%rcx
jae    1163 <putcp+0x43>
cmpl   $0x0,(%r14)
jne    114c <putcp+0x2c>
mov    $0x20,%edi
call   1030 <putchar@plt>
lea    0xeb9(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%ebp
jmp    1185 <putcp+0x65>
movabs $0x400000000000a01,%rcx
bt     %rax,%rcx
jae    118d <putcp+0x6d>
lea    0xe86(%rip),%rdi
xor    %ebp,%ebp
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,(%r14)
pop    %rbx
pop    %r14
pop    %rbp
ret
cmp    $0x100,%ebx
jl     11ae <putcp+0x8e>
cmpl   $0x0,(%r14)
jne    11a5 <putcp+0x85>
mov    $0x20,%edi
call   1030 <putchar@plt>
lea    0xe58(%rip),%rdi
jmp    1153 <putcp+0x33>
lea    -0x7f(%rbx),%eax
cmp    $0xffffffa1,%eax
jbe    113c <putcp+0x1c>
mov    %ebx,%edi
call   1030 <putchar@plt>
xor    %ebp,%ebp
jmp    1185 <putcp+0x65>

LLVM IR (-O0):
@.str = [4 x i8] c"\\%c\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [8 x i8] c"0x%04X \00"
@.str.3 = [8 x i8] c"0x%02X \00"
@.str.4 = [3 x i8] c"%c\00"
define void @putcp(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
store i32 %0, i32* %3
store i32* %1, i32** %4
%5 = load i32, i32* %3
switch i32 %5, label %11 [
i32 61, label %6
i32 48, label %6
i32 49, label %6
i32 50, label %6
i32 51, label %6
i32 52, label %6
i32 53, label %6
i32 54, label %6
i32 55, label %6
i32 56, label %6
i32 57, label %6
i32 92, label %7
i32 34, label %7
i32 45, label %7
i32 43, label %7
]
6: ; preds = %2, %2, %2, %2, %2, %2, %2, %2, %2, %2, %2
br label %31
7: ; preds = %2, %2, %2, %2
%8 = load i32, i32* %3
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = load i32*, i32** %4
store i32 0, i32* %10
br label %45
11: ; preds = %2
%12 = load i32, i32* %3
%13 = icmp sge i32 %12, 256
br i1 %13, label %14, label %24
14: ; preds = %11
%15 = load i32*, i32** %4
%16 = load i32, i32* %15
%17 = icmp ne i32 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %14
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %20
20: ; preds = %18, %14
%21 = load i32, i32* %3
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%23 = load i32*, i32** %4
store i32 1, i32* %23
br label %45
24: ; preds = %11
%25 = load i32, i32* %3
%26 = icmp sle i32 %25, 32
br i1 %26, label %30, label %27
27: ; preds = %24
%28 = load i32, i32* %3
%29 = icmp sge i32 %28, 127
br i1 %29, label %30, label %41
30: ; preds = %27, %24
br label %31
31: ; preds = %30, %6
%32 = load i32*, i32** %4
%33 = load i32, i32* %32
%34 = icmp ne i32 %33, 0
br i1 %34, label %37, label %35
35: ; preds = %31
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %37
37: ; preds = %35, %31
%38 = load i32, i32* %3
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %38)
%40 = load i32*, i32** %4
store i32 1, i32* %40
br label %45
41: ; preds = %27
%42 = load i32, i32* %3
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %42)
%44 = load i32*, i32** %4
store i32 0, i32* %44
br label %45
45: ; preds = %41, %37, %20, %7
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"\\%c\00"
@.str.2 = [8 x i8] c"0x%04X \00"
@.str.3 = [8 x i8] c"0x%02X \00"
define void @putcp(i32 %0, i32* nocapture %1) {
switch i32 %0, label %5 [
i32 61, label %17
i32 48, label %17
i32 49, label %17
i32 50, label %17
i32 51, label %17
i32 52, label %17
i32 53, label %17
i32 54, label %17
i32 55, label %17
i32 56, label %17
i32 57, label %17
i32 92, label %3
i32 34, label %3
i32 45, label %3
i32 43, label %3
]
3: ; preds = %2, %2, %2, %2
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %26
5: ; preds = %2
%6 = icmp sgt i32 %0, 255
br i1 %6, label %7, label %14
7: ; preds = %5
%8 = load i32, i32* %1
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = tail call i32 @putchar(i32 32)
br label %12
12: ; preds = %10, %7
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %0)
br label %26
14: ; preds = %5
%15 = add i32 %0, -127
%16 = icmp ult i32 %15, -94
br i1 %16, label %17, label %24
17: ; preds = %14, %2, %2, %2, %2, %2, %2, %2, %2, %2, %2, %2
%18 = load i32, i32* %1
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = tail call i32 @putchar(i32 32)
br label %22
22: ; preds = %20, %17
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %0)
br label %26
24: ; preds = %14
%25 = tail call i32 @putchar(i32 %0)
br label %26
26: ; preds = %24, %22, %12, %3
%27 = phi i32 [ 0, %24 ], [ 1, %22 ], [ 1, %12 ], [ 0, %3 ]
store i32 %27, i32* %1
ret void
}