#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*/ decls(int, char *);
int /*<<< orphan*/ printf(char *);
main() {
  char *s1 =
      "decls(int d, char *s) {\nprintf(\"char *s%%d=\\\"\",d);\nfor (;*s;s++) "
      "{\nif (*s=='\\n') printf(\"\\\\n\");\nelse if (*s=='\\\\') "
      "printf(\"\\\\\\\\\");\nelse if (*s=='\\\"') printf(\"\\\\\\\"\");\nelse "
      "putchar((int)(*s));\n}\nprintf(\"\\\";\\n\");\n}\nmain()\n{\n";
  char *s2 = "printf(s1);\ndecls(1, s1);\ndecls(2, s2);\nprintf(s2);\n}\n";
  printf(s1);
  decls(1, s1);
  decls(2, s2);
  printf(s2);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rax
mov    %rax,-0x8(%rbp)
lea    0xfa4(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rsi
mov    $0x1,%edi
call   1040 <decls@plt>
mov    -0x10(%rbp),%rsi
mov    $0x2,%edi
call   1040 <decls@plt>
mov    -0x10(%rbp),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xec8(%rip),%rbx
mov    %rbx,%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
call   1050 <decls@plt>
lea    0xf8a(%rip),%rsi
mov    $0x2,%edi
call   1050 <decls@plt>
lea    0xfb0(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [222 x i8] c"decls(int d, char *s) {\0Aprintf(\22char *s%%d=\\\22\22,d);\0Afor (;*s;s++) {\0Aif (*s=='\\n') printf(\22\\\\n\22);\0Aelse if (*s=='\\\\') printf(\22\\\\\\\\\22);\0Aelse if (*s=='\\\22') printf(\22\\\\\\\22\22);\0Aelse putchar((int)(*s));\0A}\0Aprintf(\22\\\22;\\n\22);\0A}\0Amain()\0A{\0A\00"
@.str.1 = [55 x i8] c"printf(s1);\0Adecls(1, s1);\0Adecls(2, s2);\0Aprintf(s2);\0A}\0A\00"
define i32 @main() {
%1 = alloca i8*
%2 = alloca i8*
store i8* getelementptr inbounds ([222 x i8], [222 x i8]* @.str, i64 0, i64 0), i8** %1
store i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0), i8** %2
%3 = load i8*, i8** %1
%4 = call i32 @printf(i8* %3)
%5 = load i8*, i8** %1
%6 = call i32 @decls(i32 1, i8* %5)
%7 = load i8*, i8** %2
%8 = call i32 @decls(i32 2, i8* %7)
%9 = load i8*, i8** %2
%10 = call i32 @printf(i8* %9)
ret i32 0
}

LLVM IR (-O2):
@.str = [222 x i8] c"decls(int d, char *s) {\0Aprintf(\22char *s%%d=\\\22\22,d);\0Afor (;*s;s++) {\0Aif (*s=='\\n') printf(\22\\\\n\22);\0Aelse if (*s=='\\\\') printf(\22\\\\\\\\\22);\0Aelse if (*s=='\\\22') printf(\22\\\\\\\22\22);\0Aelse putchar((int)(*s));\0A}\0Aprintf(\22\\\22;\\n\22);\0A}\0Amain()\0A{\0A\00"
@.str.1 = [55 x i8] c"printf(s1);\0Adecls(1, s1);\0Adecls(2, s2);\0Aprintf(s2);\0A}\0A\00"
@str = [54 x i8] c"printf(s1);\0Adecls(1, s1);\0Adecls(2, s2);\0Aprintf(s2);\0A}\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([222 x i8], [222 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @decls(i32 1, i8* getelementptr inbounds ([222 x i8], [222 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @decls(i32 2, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str, i64 0, i64 0))
ret i32 0
}