#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 printf(char *, ...);
int printEscapedRangeChar(char c) {
  int chars = 0;
  switch (c) {
  case '[':
    chars += printf("\\[");
    break;
  case ']':
    chars += printf("\\]");
    break;
  case '\\':
    chars += printf("\\\\");
    break;
  default:
    chars += printf("%c", c);
    break;
  }
  return chars;
}


x86 assembly (clang, -O0):
<printEscapedRangeChar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movl   $0x0,-0x8(%rbp)
movsbl -0x1(%rbp),%eax
mov    %eax,-0xc(%rbp)
sub    $0x5b,%eax
je     115c <printEscapedRangeChar+0x4c>
jmp    113a <printEscapedRangeChar+0x2a>
mov    -0xc(%rbp),%eax
sub    $0x5c,%eax
je     118e <printEscapedRangeChar+0x7e>
jmp    114b <printEscapedRangeChar+0x3b>
mov    -0xc(%rbp),%eax
sub    $0x5d,%eax
je     1175 <printEscapedRangeChar+0x65>
jmp    11a7 <printEscapedRangeChar+0x97>
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    11bf <printEscapedRangeChar+0xaf>
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    11bf <printEscapedRangeChar+0xaf>
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    11bf <printEscapedRangeChar+0xaf>
movsbl -0x1(%rbp),%esi
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printEscapedRangeChar>:
cmp    $0x5d,%edi
je     112f <printEscapedRangeChar+0x1f>
mov    %edi,%esi
cmp    $0x5c,%edi
je     113d <printEscapedRangeChar+0x2d>
cmp    $0x5b,%esi
jne    114b <printEscapedRangeChar+0x3b>
lea    0xed8(%rip),%rdi
xor    %eax,%eax
jmp    1030 <printf@plt>
lea    0xecd(%rip),%rdi
xor    %eax,%eax
jmp    1030 <printf@plt>
lea    0xec2(%rip),%rdi
xor    %eax,%eax
jmp    1030 <printf@plt>
lea    0xeb7(%rip),%rdi
xor    %eax,%eax
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"\\[\00"
@.str.1 = [3 x i8] c"\\]\00"
@.str.2 = [3 x i8] c"\\\\\00"
@.str.3 = [3 x i8] c"%c\00"
define i32 @printEscapedRangeChar(i8 signext %0) {
%2 = alloca i8
%3 = alloca i32
store i8 %0, i8* %2
store i32 0, i32* %3
%4 = load i8, i8* %2
%5 = sext i8 %4 to i32
switch i32 %5, label %18 [
i32 91, label %6
i32 93, label %10
i32 92, label %14
]
6: ; preds = %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* %3
%9 = add nsw i32 %8, %7
store i32 %9, i32* %3
br label %24
10: ; preds = %1
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%12 = load i32, i32* %3
%13 = add nsw i32 %12, %11
store i32 %13, i32* %3
br label %24
14: ; preds = %1
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%16 = load i32, i32* %3
%17 = add nsw i32 %16, %15
store i32 %17, i32* %3
br label %24
18: ; preds = %1
%19 = load i8, i8* %2
%20 = sext i8 %19 to i32
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %20)
%22 = load i32, i32* %3
%23 = add nsw i32 %22, %21
store i32 %23, i32* %3
br label %24
24: ; preds = %18, %14, %10, %6
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
@.str = [3 x i8] c"\\[\00"
@.str.1 = [3 x i8] c"\\]\00"
@.str.2 = [3 x i8] c"\\\\\00"
@.str.3 = [3 x i8] c"%c\00"
define i32 @printEscapedRangeChar(i8 signext %0) {
%2 = sext i8 %0 to i32
switch i32 %2, label %9 [
i32 91, label %3
i32 93, label %5
i32 92, label %7
]
3: ; preds = %1
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %11
5: ; preds = %1
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %11
7: ; preds = %1
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %11
9: ; preds = %1
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %2)
br label %11
11: ; preds = %9, %7, %5, %3
%12 = phi i32 [ %10, %9 ], [ %8, %7 ], [ %6, %5 ], [ %4, %3 ]
ret i32 %12
}