#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 fh_ast {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void dump_string(struct fh_ast *ast, const char *str) {
  ((void)(ast));
  printf("\"");
  for (const char *p = str; *p != '\0'; p++) {
    switch (*p) {
    case '\n':
      printf("\\n");
      break;
    case '\r':
      printf("\\r");
      break;
    case '\t':
      printf("\\t");
      break;
    case '\\':
      printf("\\\\");
      break;
    case '"':
      printf("\\\"");
      break;
    default:
      if (*p < 32)
        printf("\\x%02x", (unsigned char)*p);
      else
        printf("%c", *p);
      break;
    }
  }
  printf("\"");
}


x86 assembly (clang, -O0):
<dump_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xee6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     125b <dump_string+0x14b>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x9,%eax
je     11c8 <dump_string+0xb8>
jmp    115e <dump_string+0x4e>
mov    -0x1c(%rbp),%eax
sub    $0xa,%eax
je     11a2 <dump_string+0x92>
jmp    116f <dump_string+0x5f>
mov    -0x1c(%rbp),%eax
sub    $0xd,%eax
je     11b5 <dump_string+0xa5>
jmp    1180 <dump_string+0x70>
mov    -0x1c(%rbp),%eax
sub    $0x22,%eax
je     11ee <dump_string+0xde>
jmp    1191 <dump_string+0x81>
mov    -0x1c(%rbp),%eax
sub    $0x5c,%eax
je     11db <dump_string+0xcb>
jmp    1201 <dump_string+0xf1>
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1245 <dump_string+0x135>
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1245 <dump_string+0x135>
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1245 <dump_string+0x135>
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1245 <dump_string+0x135>
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1245 <dump_string+0x135>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jge    122b <dump_string+0x11b>
mov    -0x18(%rbp),%rax
movzbl (%rax),%esi
lea    0xdf0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1240 <dump_string+0x130>
mov    -0x18(%rbp),%rax
movsbl (%rax),%esi
lea    0xddd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1245 <dump_string+0x135>
jmp    124a <dump_string+0x13a>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1136 <dump_string+0x26>
lea    0xdab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_string>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    $0x22,%edi
call   1030 <putchar@plt>
mov    (%rbx),%al
test   %al,%al
je     11d6 <dump_string+0xb6>
add    $0x1,%rbx
lea    0xeb3(%rip),%r14
lea    0xf1a(%rip),%r12
lea    0xf0d(%rip),%r13
lea    0xf09(%rip),%rbp
lea    0xf0b(%rip),%r15
jmp    1180 <dump_string+0x60>
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     11d6 <dump_string+0xb6>
movsbl %al,%edi
lea    -0x9(%rdi),%ecx
cmp    $0x19,%ecx
ja     11a0 <dump_string+0x80>
movslq (%r14,%rcx,4),%rcx
add    %r14,%rcx
jmp    *%rcx
mov    %r12,%rdi
jmp    116e <dump_string+0x4e>
nopl   0x0(%rax)
cmp    $0x5c,%edi
jne    11ae <dump_string+0x8e>
lea    0xec5(%rip),%rdi
jmp    116e <dump_string+0x4e>
cmp    $0x1f,%al
jg     11cf <dump_string+0xaf>
movzbl %al,%esi
lea    0xebb(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1175 <dump_string+0x55>
mov    %rbp,%rdi
jmp    116e <dump_string+0x4e>
mov    %r15,%rdi
jmp    116e <dump_string+0x4e>
call   1030 <putchar@plt>
jmp    1175 <dump_string+0x55>
mov    $0x22,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
%struct.fh_ast = type { i32 }
@.str = [2 x i8] c"\22\00"
@.str.1 = [3 x i8] c"\\n\00"
@.str.2 = [3 x i8] c"\\r\00"
@.str.3 = [3 x i8] c"\\t\00"
@.str.4 = [3 x i8] c"\\\\\00"
@.str.5 = [3 x i8] c"\\\22\00"
@.str.6 = [7 x i8] c"\\x%02x\00"
@.str.7 = [3 x i8] c"%c\00"
define void @dump_string(%struct.fh_ast* %0, i8* %1) {
%3 = alloca %struct.fh_ast*
%4 = alloca i8*
%5 = alloca i8*
store %struct.fh_ast* %0, %struct.fh_ast** %3
store i8* %1, i8** %4
%6 = load %struct.fh_ast*, %struct.fh_ast** %3
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = load i8*, i8** %4
store i8* %8, i8** %5
br label %9
9: ; preds = %45, %2
%10 = load i8*, i8** %5
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %48
14: ; preds = %9
%15 = load i8*, i8** %5
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
switch i32 %17, label %28 [
i32 10, label %18
i32 13, label %20
i32 9, label %22
i32 92, label %24
i32 34, label %26
]
18: ; preds = %14
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %44
20: ; preds = %14
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %44
22: ; preds = %14
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %44
24: ; preds = %14
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %44
26: ; preds = %14
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %44
28: ; preds = %14
%29 = load i8*, i8** %5
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp slt i32 %31, 32
br i1 %32, label %33, label %38
33: ; preds = %28
%34 = load i8*, i8** %5
%35 = load i8, i8* %34
%36 = zext i8 %35 to i32
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 %36)
br label %43
38: ; preds = %28
%39 = load i8*, i8** %5
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32 %41)
br label %43
43: ; preds = %38, %33
br label %44
44: ; preds = %43, %26, %24, %22, %20, %18
br label %45
45: ; preds = %44
%46 = load i8*, i8** %5
%47 = getelementptr inbounds i8, i8* %46, i32 1
store i8* %47, i8** %5
br label %9
48: ; preds = %9
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.fh_ast = type { i32 }
@.str.1 = [3 x i8] c"\\n\00"
@.str.2 = [3 x i8] c"\\r\00"
@.str.3 = [3 x i8] c"\\t\00"
@.str.4 = [3 x i8] c"\\\\\00"
@.str.5 = [3 x i8] c"\\\22\00"
@.str.6 = [7 x i8] c"\\x%02x\00"
define void @dump_string(%struct.fh_ast* nocapture readnone %0, i8* nocapture %1) {
%3 = tail call i32 @putchar(i32 34)
%4 = load i8, i8* %1
%5 = icmp eq i8 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %29, %2
%7 = tail call i32 @putchar(i32 34)
ret void
8: ; preds = %2, %29
%9 = phi i8 [ %31, %29 ], [ %4, %2 ]
%10 = phi i8* [ %30, %29 ], [ %1, %2 ]
%11 = sext i8 %9 to i32
switch i32 %11, label %22 [
i32 10, label %12
i32 13, label %14
i32 9, label %16
i32 92, label %18
i32 34, label %20
]
12: ; preds = %8
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %29
14: ; preds = %8
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %29
16: ; preds = %8
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %29
18: ; preds = %8
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %29
20: ; preds = %8
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %29
22: ; preds = %8
%23 = icmp slt i8 %9, 32
br i1 %23, label %24, label %27
24: ; preds = %22
%25 = zext i8 %9 to i32
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 %25)
br label %29
27: ; preds = %22
%28 = tail call i32 @putchar(i32 %11)
br label %29
29: ; preds = %12, %14, %16, %18, %20, %27, %24
%30 = getelementptr inbounds i8, i8* %10, i64 1
%31 = load i8, i8* %30
%32 = icmp eq i8 %31, 0
br i1 %32, label %6, label %8
}