#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 quine(char *s) {
  printf("%s(\"\\\n", s);
  while (*s != '\0') {
    switch (*s) {
    case '"':
    case '\\':
      printf("\\");
      break;
    case '\n':
      printf("\\n\\");
      break;
    }
    printf("%c", *s++);
  }
  printf("\"\n    );\n    return 0;\n}\n");
}


x86 assembly (clang, -O0):
<quine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xed9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11be <quine+0xae>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0xc(%rbp)
sub    $0xa,%eax
je     118b <quine+0x7b>
jmp    1156 <quine+0x46>
mov    -0xc(%rbp),%eax
sub    $0x22,%eax
je     1178 <quine+0x68>
jmp    1167 <quine+0x57>
mov    -0xc(%rbp),%eax
sub    $0x5c,%eax
jne    1199 <quine+0x89>
jmp    1178 <quine+0x68>
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1199 <quine+0x89>
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movsbl (%rax),%esi
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    112e <quine+0x1e>
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quine>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xec2(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx),%al
test   %al,%al
je     11ac <quine+0x7c>
add    $0x1,%rbx
lea    0xeae(%rip),%r14
jmp    117e <quine+0x4e>
nopl   0x0(%rax,%rax,1)
mov    $0x5c,%edi
call   1030 <putchar@plt>
movsbl -0x1(%rbx),%edi
call   1030 <putchar@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     11ac <quine+0x7c>
movsbl %al,%eax
cmp    $0xa,%eax
je     11a0 <quine+0x70>
cmp    $0x5c,%eax
je     1160 <quine+0x30>
cmp    $0x22,%eax
je     1160 <quine+0x30>
jmp    116a <quine+0x3a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    116a <quine+0x3a>
lea    0xe58(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <puts@plt>

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

LLVM IR (-O2):
@.str = [7 x i8] c"%s(\22\\\0A\00"
@.str.2 = [4 x i8] c"\\n\\\00"
@str = [25 x i8] c"\22\0A );\0A return 0;\0A}\00"
define void @quine(i8* %0) {
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %0)
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %20, label %5
5: ; preds = %1, %13
%6 = phi i8 [ %18, %13 ], [ %3, %1 ]
%7 = phi i8* [ %14, %13 ], [ %0, %1 ]
%8 = sext i8 %6 to i32
switch i32 %8, label %13 [
i32 34, label %9
i32 92, label %9
i32 10, label %11
]
9: ; preds = %5, %5
%10 = tail call i32 @putchar(i32 92)
br label %13
11: ; preds = %5
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %13
13: ; preds = %5, %11, %9
%14 = getelementptr inbounds i8, i8* %7, i64 1
%15 = load i8, i8* %7
%16 = sext i8 %15 to i32
%17 = tail call i32 @putchar(i32 %16)
%18 = load i8, i8* %14
%19 = icmp eq i8 %18, 0
br i1 %19, label %20, label %5
20: ; preds = %13, %1
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
ret void
}