#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 EOF;
int fgetc(int /*<<< orphan*/);
int /*<<< orphan*/ fputc(int, int /*<<< orphan*/);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int main(int argc, char **argv) {
  int c;
  int n = 0;
  if (argc != 2)
    return -1;
  printf("char* %s=\"", argv[1]);
  while ((c = fgetc(stdin)) != EOF) {
    ++n;
    switch (c) {
    case '\n':
      fputs("\\n", stdout);
      break;
    case '\b':
      fputs("\\b", stdout);
      break;
    case '\v':
      fputs("\\v", stdout);
      break;
    case '\r':
      fputs("\\r", stdout);
      break;
    case '\t':
      fputs("\\t", stdout);
      break;
    case '\\':
      fputs("\\\\", stdout);
      break;
    case '\"':
      fputs("\\\"", stdout);
      break;
    case '\'':
      fputs("\\\'", stdout);
      break;
    default:
      fputc(c, stdout);
      break;
    }
  }
  printf("\";\n");
  printf("unsigned long %s_length=%d;\n", argv[1], n);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1173 <main+0x33>
movl   $0xffffffff,-0x4(%rbp)
jmp    1351 <main+0x211>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e58(%rip),%rax
mov    (%rax),%edi
call   1050 <fgetc@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e3f(%rip),%rcx
cmp    (%rcx),%eax
je     1323 <main+0x1e3>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x8,%eax
je     1257 <main+0x117>
jmp    11c6 <main+0x86>
mov    -0x1c(%rbp),%eax
sub    $0x9,%eax
je     12a5 <main+0x165>
jmp    11d7 <main+0x97>
mov    -0x1c(%rbp),%eax
sub    $0xa,%eax
je     123d <main+0xfd>
jmp    11e8 <main+0xa8>
mov    -0x1c(%rbp),%eax
sub    $0xb,%eax
je     1271 <main+0x131>
jmp    11f9 <main+0xb9>
mov    -0x1c(%rbp),%eax
sub    $0xd,%eax
je     128b <main+0x14b>
jmp    120a <main+0xca>
mov    -0x1c(%rbp),%eax
sub    $0x22,%eax
je     12d9 <main+0x199>
jmp    121b <main+0xdb>
mov    -0x1c(%rbp),%eax
sub    $0x27,%eax
je     12f3 <main+0x1b3>
jmp    122c <main+0xec>
mov    -0x1c(%rbp),%eax
sub    $0x5c,%eax
je     12bf <main+0x17f>
jmp    130d <main+0x1cd>
mov    0x2d8c(%rip),%rax
mov    (%rax),%esi
lea    0xdbe(%rip),%rdi
call   1040 <fputs@plt>
jmp    131e <main+0x1de>
mov    0x2d72(%rip),%rax
mov    (%rax),%esi
lea    0xda7(%rip),%rdi
call   1040 <fputs@plt>
jmp    131e <main+0x1de>
mov    0x2d58(%rip),%rax
mov    (%rax),%esi
lea    0xd90(%rip),%rdi
call   1040 <fputs@plt>
jmp    131e <main+0x1de>
mov    0x2d3e(%rip),%rax
mov    (%rax),%esi
lea    0xd79(%rip),%rdi
call   1040 <fputs@plt>
jmp    131e <main+0x1de>
mov    0x2d24(%rip),%rax
mov    (%rax),%esi
lea    0xd62(%rip),%rdi
call   1040 <fputs@plt>
jmp    131e <main+0x1de>
mov    0x2d0a(%rip),%rax
mov    (%rax),%esi
lea    0xd4b(%rip),%rdi
call   1040 <fputs@plt>
jmp    131e <main+0x1de>
mov    0x2cf0(%rip),%rax
mov    (%rax),%esi
lea    0xd34(%rip),%rdi
call   1040 <fputs@plt>
jmp    131e <main+0x1de>
mov    0x2cd6(%rip),%rax
mov    (%rax),%esi
lea    0xd1d(%rip),%rdi
call   1040 <fputs@plt>
jmp    131e <main+0x1de>
mov    -0x14(%rbp),%edi
mov    0x2cb9(%rip),%rax
mov    (%rax),%esi
call   1060 <fputc@plt>
jmp    1189 <main+0x49>
lea    0xcf9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x18(%rbp),%edx
lea    0xce4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0xffffffff,%ebx
cmp    $0x2,%edi
jne    11c2 <main+0x72>
mov    %rsi,(%rsp)
mov    0x8(%rsi),%rsi
lea    0xf0c(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e64(%rip),%r13
mov    0x0(%r13),%edi
call   1060 <fgetc@plt>
mov    0x2e4c(%rip),%r15
mov    $0x0,%ebp
cmp    (%r15),%eax
jne    11d3 <main+0x83>
lea    0xf1b(%rip),%rdi
call   1030 <puts@plt>
mov    (%rsp),%rax
mov    0x8(%rax),%rsi
lea    0xeea(%rip),%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebp,%ebp
mov    0x2df4(%rip),%r12
lea    0xe1d(%rip),%r14
jmp    1201 <main+0xb1>
mov    (%r12),%esi
mov    %eax,%edi
call   1070 <fputc@plt>
mov    0x0(%r13),%edi
call   1060 <fgetc@plt>
add    $0x1,%ebp
cmp    (%r15),%eax
je     119e <main+0x4e>
lea    -0x8(%rax),%ecx
cmp    $0x1f,%ecx
ja     1224 <main+0xd4>
movslq (%r14,%rcx,4),%rcx
add    %r14,%rcx
jmp    *%rcx
mov    (%r12),%esi
lea    0xe71(%rip),%rdi
call   1050 <fputs@plt>
jmp    11f0 <main+0xa0>
cmp    $0x5c,%eax
jne    11e5 <main+0x95>
mov    (%r12),%esi
lea    0xe66(%rip),%rdi
call   1050 <fputs@plt>
jmp    11f0 <main+0xa0>
mov    (%r12),%esi
lea    0xe51(%rip),%rdi
call   1050 <fputs@plt>
jmp    11f0 <main+0xa0>
mov    (%r12),%esi
lea    0xe33(%rip),%rdi
call   1050 <fputs@plt>
jmp    11f0 <main+0xa0>
mov    (%r12),%esi
lea    0xe27(%rip),%rdi
call   1050 <fputs@plt>
jmp    11f0 <main+0xa0>
mov    (%r12),%esi
lea    0xe15(%rip),%rdi
call   1050 <fputs@plt>
jmp    11f0 <main+0xa0>
mov    (%r12),%esi
lea    0xe09(%rip),%rdi
call   1050 <fputs@plt>
jmp    11f0 <main+0xa0>
mov    (%r12),%esi
lea    0xdf7(%rip),%rdi
call   1050 <fputs@plt>
jmp    11f0 <main+0xa0>

LLVM IR (-O0):
@.str = [11 x i8] c"char* %s=\22\00"
@stdin = global i32 0
@EOF = global i32 0
@.str.1 = [3 x i8] c"\\n\00"
@stdout = global i32 0
@.str.2 = [3 x i8] c"\\b\00"
@.str.3 = [3 x i8] c"\\v\00"
@.str.4 = [3 x i8] c"\\r\00"
@.str.5 = [3 x i8] c"\\t\00"
@.str.6 = [3 x i8] c"\\\\\00"
@.str.7 = [3 x i8] c"\\\22\00"
@.str.8 = [3 x i8] c"\\'\00"
@.str.9 = [4 x i8] c"\22;\0A\00"
@.str.10 = [29 x i8] c"unsigned long %s_length=%d;\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 2
br i1 %9, label %10, label %11
10: ; preds = %2
store i32 -1, i32* %3
br label %61
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %14)
br label %16
16: ; preds = %53, %11
%17 = load i32, i32* @stdin
%18 = call i32 @fgetc(i32 %17)
store i32 %18, i32* %6
%19 = load i32, i32* @EOF
%20 = icmp ne i32 %18, %19
br i1 %20, label %21, label %54
21: ; preds = %16
%22 = load i32, i32* %7
%23 = add nsw i32 %22, 1
store i32 %23, i32* %7
%24 = load i32, i32* %6
switch i32 %24, label %49 [
i32 10, label %25
i32 8, label %28
i32 11, label %31
i32 13, label %34
i32 9, label %37
i32 92, label %40
i32 34, label %43
i32 39, label %46
]
25: ; preds = %21
%26 = load i32, i32* @stdout
%27 = call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %26)
br label %53
28: ; preds = %21
%29 = load i32, i32* @stdout
%30 = call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %29)
br label %53
31: ; preds = %21
%32 = load i32, i32* @stdout
%33 = call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %32)
br label %53
34: ; preds = %21
%35 = load i32, i32* @stdout
%36 = call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %35)
br label %53
37: ; preds = %21
%38 = load i32, i32* @stdout
%39 = call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %38)
br label %53
40: ; preds = %21
%41 = load i32, i32* @stdout
%42 = call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %41)
br label %53
43: ; preds = %21
%44 = load i32, i32* @stdout
%45 = call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32 %44)
br label %53
46: ; preds = %21
%47 = load i32, i32* @stdout
%48 = call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32 %47)
br label %53
49: ; preds = %21
%50 = load i32, i32* %6
%51 = load i32, i32* @stdout
%52 = call i32 @fputc(i32 %50, i32 %51)
br label %53
53: ; preds = %49, %46, %43, %40, %37, %34, %31, %28, %25
br label %16
54: ; preds = %16
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%56 = load i8**, i8*** %5
%57 = getelementptr inbounds i8*, i8** %56, i64 1
%58 = load i8*, i8** %57
%59 = load i32, i32* %7
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0), i8* %58, i32 %59)
store i32 0, i32* %3
br label %61
61: ; preds = %54, %10
%62 = load i32, i32* %3
ret i32 %62
}

LLVM IR (-O2):
@.str = [11 x i8] c"char* %s=\22\00"
@stdin = global i32 0
@EOF = global i32 0
@.str.1 = [3 x i8] c"\\n\00"
@stdout = global i32 0
@.str.2 = [3 x i8] c"\\b\00"
@.str.3 = [3 x i8] c"\\v\00"
@.str.4 = [3 x i8] c"\\r\00"
@.str.5 = [3 x i8] c"\\t\00"
@.str.6 = [3 x i8] c"\\\\\00"
@.str.7 = [3 x i8] c"\\\22\00"
@.str.8 = [3 x i8] c"\\'\00"
@.str.10 = [29 x i8] c"unsigned long %s_length=%d;\0A\00"
@str = [3 x i8] c"\22;\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %4, label %53
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = load i32, i32* @stdin
%9 = tail call i32 @fgetc(i32 %8)
%10 = load i32, i32* @EOF
%11 = icmp eq i32 %9, %10
br i1 %11, label %48, label %12
12: ; preds = %4, %43
%13 = phi i32 [ %45, %43 ], [ %9, %4 ]
%14 = phi i32 [ %15, %43 ], [ 0, %4 ]
%15 = add nuw nsw i32 %14, 1
switch i32 %13, label %40 [
i32 10, label %16
i32 8, label %19
i32 11, label %22
i32 13, label %25
i32 9, label %28
i32 92, label %31
i32 34, label %34
i32 39, label %37
]
16: ; preds = %12
%17 = load i32, i32* @stdout
%18 = tail call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %17)
br label %43
19: ; preds = %12
%20 = load i32, i32* @stdout
%21 = tail call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %20)
br label %43
22: ; preds = %12
%23 = load i32, i32* @stdout
%24 = tail call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %23)
br label %43
25: ; preds = %12
%26 = load i32, i32* @stdout
%27 = tail call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %26)
br label %43
28: ; preds = %12
%29 = load i32, i32* @stdout
%30 = tail call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %29)
br label %43
31: ; preds = %12
%32 = load i32, i32* @stdout
%33 = tail call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %32)
br label %43
34: ; preds = %12
%35 = load i32, i32* @stdout
%36 = tail call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32 %35)
br label %43
37: ; preds = %12
%38 = load i32, i32* @stdout
%39 = tail call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32 %38)
br label %43
40: ; preds = %12
%41 = load i32, i32* @stdout
%42 = tail call i32 @fputc(i32 %13, i32 %41)
br label %43
43: ; preds = %40, %37, %34, %31, %28, %25, %22, %19, %16
%44 = load i32, i32* @stdin
%45 = tail call i32 @fgetc(i32 %44)
%46 = load i32, i32* @EOF
%47 = icmp eq i32 %45, %46
br i1 %47, label %48, label %12
48: ; preds = %43, %4
%49 = phi i32 [ 0, %4 ], [ %15, %43 ]
%50 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
%51 = load i8*, i8** %5
%52 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0), i8* %51, i32 %49)
br label %53
53: ; preds = %2, %48
%54 = phi i32 [ 0, %48 ], [ -1, %2 ]
ret i32 %54
}