#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 */
struct buffer {
  int dummy;
};
typedef int ssize_t;

/* Variables and functions */
int buffer_append(struct buffer *, char const);
int decode_unicode(struct buffer *, char const *, char const *);
ssize_t decode_escape(struct buffer *output, const char *input,
                      const char *end) {
  if (input >= end)
    return 1;
  switch (*input) {
  case 'b':
    return buffer_append(output, '\b');
  case 'f':
    return buffer_append(output, '\f');
  case 'n':
    return buffer_append(output, '\n');
  case 'r':
    return buffer_append(output, '\r');
  case 't':
    return buffer_append(output, '\t');
  case 'u':
    return decode_unicode(output, input + 1, end);
  default:
    return buffer_append(output, *input);
  }
}


x86 assembly (clang, -O0):
<decode_escape>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jb     114e <decode_escape+0x2e>
movl   $0x1,-0x4(%rbp)
jmp    1219 <decode_escape+0xf9>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
add    $0xffffff9e,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x13,%eax
ja     1206 <decode_escape+0xe6>
mov    -0x28(%rbp),%rax
lea    0xe8e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rdi
mov    $0x8,%esi
call   1040 <buffer_append@plt>
mov    %eax,-0x4(%rbp)
jmp    1219 <decode_escape+0xf9>
mov    -0x10(%rbp),%rdi
mov    $0xc,%esi
call   1040 <buffer_append@plt>
mov    %eax,-0x4(%rbp)
jmp    1219 <decode_escape+0xf9>
mov    -0x10(%rbp),%rdi
mov    $0xa,%esi
call   1040 <buffer_append@plt>
mov    %eax,-0x4(%rbp)
jmp    1219 <decode_escape+0xf9>
mov    -0x10(%rbp),%rdi
mov    $0xd,%esi
call   1040 <buffer_append@plt>
mov    %eax,-0x4(%rbp)
jmp    1219 <decode_escape+0xf9>
mov    -0x10(%rbp),%rdi
mov    $0x9,%esi
call   1040 <buffer_append@plt>
mov    %eax,-0x4(%rbp)
jmp    1219 <decode_escape+0xf9>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
add    $0x1,%rsi
mov    -0x20(%rbp),%rdx
call   1030 <decode_unicode@plt>
mov    %eax,-0x4(%rbp)
jmp    1219 <decode_escape+0xf9>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
movsbl (%rax),%esi
call   1040 <buffer_append@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decode_escape>:
cmp    %rdx,%rsi
jae    114a <decode_escape+0x2a>
movsbl (%rsi),%eax
lea    -0x62(%rax),%ecx
cmp    $0x13,%ecx
ja     1150 <decode_escape+0x30>
lea    0xec9(%rip),%r8
movslq (%r8,%rcx,4),%rcx
add    %r8,%rcx
jmp    *%rcx
mov    $0x8,%esi
jmp    1040 <buffer_append@plt>
mov    $0x1,%eax
ret
movsbl %al,%esi
jmp    1040 <buffer_append@plt>
mov    $0xc,%esi
jmp    1040 <buffer_append@plt>
mov    $0xa,%esi
jmp    1040 <buffer_append@plt>
mov    $0xd,%esi
jmp    1040 <buffer_append@plt>
mov    $0x9,%esi
jmp    1040 <buffer_append@plt>
add    $0x1,%rsi
jmp    1030 <decode_unicode@plt>

LLVM IR (-O0):
%struct.buffer = type { i32 }
define i32 @decode_escape(%struct.buffer* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca %struct.buffer*
%6 = alloca i8*
%7 = alloca i8*
store %struct.buffer* %0, %struct.buffer** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%8 = load i8*, i8** %6
%9 = load i8*, i8** %7
%10 = icmp uge i8* %8, %9
br i1 %10, label %11, label %12
11: ; preds = %3
store i32 1, i32* %4
br label %42
12: ; preds = %3
%13 = load i8*, i8** %6
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
switch i32 %15, label %37 [
i32 98, label %16
i32 102, label %19
i32 110, label %22
i32 114, label %25
i32 116, label %28
i32 117, label %31
]
16: ; preds = %12
%17 = load %struct.buffer*, %struct.buffer** %5
%18 = call i32 @buffer_append(%struct.buffer* %17, i8 signext 8)
store i32 %18, i32* %4
br label %42
19: ; preds = %12
%20 = load %struct.buffer*, %struct.buffer** %5
%21 = call i32 @buffer_append(%struct.buffer* %20, i8 signext 12)
store i32 %21, i32* %4
br label %42
22: ; preds = %12
%23 = load %struct.buffer*, %struct.buffer** %5
%24 = call i32 @buffer_append(%struct.buffer* %23, i8 signext 10)
store i32 %24, i32* %4
br label %42
25: ; preds = %12
%26 = load %struct.buffer*, %struct.buffer** %5
%27 = call i32 @buffer_append(%struct.buffer* %26, i8 signext 13)
store i32 %27, i32* %4
br label %42
28: ; preds = %12
%29 = load %struct.buffer*, %struct.buffer** %5
%30 = call i32 @buffer_append(%struct.buffer* %29, i8 signext 9)
store i32 %30, i32* %4
br label %42
31: ; preds = %12
%32 = load %struct.buffer*, %struct.buffer** %5
%33 = load i8*, i8** %6
%34 = getelementptr inbounds i8, i8* %33, i64 1
%35 = load i8*, i8** %7
%36 = call i32 @decode_unicode(%struct.buffer* %32, i8* %34, i8* %35)
store i32 %36, i32* %4
br label %42
37: ; preds = %12
%38 = load %struct.buffer*, %struct.buffer** %5
%39 = load i8*, i8** %6
%40 = load i8, i8* %39
%41 = call i32 @buffer_append(%struct.buffer* %38, i8 signext %40)
store i32 %41, i32* %4
br label %42
42: ; preds = %37, %31, %28, %25, %22, %19, %16, %11
%43 = load i32, i32* %4
ret i32 %43
}

LLVM IR (-O2):
%struct.buffer = type { i32 }
define i32 @decode_escape(%struct.buffer* %0, i8* %1, i8* %2) {
%4 = icmp ult i8* %1, %2
br i1 %4, label %5, label %23
5: ; preds = %3
%6 = load i8, i8* %1
%7 = sext i8 %6 to i32
switch i32 %7, label %21 [
i32 98, label %8
i32 102, label %10
i32 110, label %12
i32 114, label %14
i32 116, label %16
i32 117, label %18
]
8: ; preds = %5
%9 = tail call i32 @buffer_append(%struct.buffer* %0, i8 signext 8)
br label %23
10: ; preds = %5
%11 = tail call i32 @buffer_append(%struct.buffer* %0, i8 signext 12)
br label %23
12: ; preds = %5
%13 = tail call i32 @buffer_append(%struct.buffer* %0, i8 signext 10)
br label %23
14: ; preds = %5
%15 = tail call i32 @buffer_append(%struct.buffer* %0, i8 signext 13)
br label %23
16: ; preds = %5
%17 = tail call i32 @buffer_append(%struct.buffer* %0, i8 signext 9)
br label %23
18: ; preds = %5
%19 = getelementptr inbounds i8, i8* %1, i64 1
%20 = tail call i32 @decode_unicode(%struct.buffer* %0, i8* %19, i8* %2)
br label %23
21: ; preds = %5
%22 = tail call i32 @buffer_append(%struct.buffer* %0, i8 signext %6)
br label %23
23: ; preds = %3, %21, %18, %16, %14, %12, %10, %8
%24 = phi i32 [ %22, %21 ], [ %20, %18 ], [ %17, %16 ], [ %15, %14 ], [ %13, %12 ], [ %11, %10 ], [ %9, %8 ], [ 1, %3 ]
ret i32 %24
}