#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, char);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdout;
int main(int argc, char **args) {
  char *name;
  int i = 0, len;
  char *content;
  char outstrs[50][3];
  FILE *outFile;
  if (argc == 3) {
    outFile = stdout;
  } else if (argc == 4) {
    outFile = fopen(args[3], "w");
  } else {
    fprintf(stderr, "%s <VarialbeName> <StringContent>\n", args[0]);
    fprintf(stderr, "%s <VarialbeName> <StringContent> <OutputFile>\n",
            args[0]);
    exit(1);
  }
  name = args[1];
  content = args[2];
  while (*content != '\0') {
    if (*content == '\\') {
      content++;
      sprintf(outstrs[i], "\\%c", *content);
    } else {
      sprintf(outstrs[i], "%c", *content);
    }
    content++;
    i++;
  }
  len = i;
  fprintf(outFile, "char %s[%u];\n", name, len + 1);
  for (i = 0; i < len; i++)
    fprintf(outFile, "%s[%d] = '%s';\n", name, i, outstrs[i]);
  fprintf(outFile, "%s[%d] = '\\0';\n", name, len);
  fclose(outFile);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3,-0x8(%rbp)
jne    1190 <main+0x40>
mov    0x2e57(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0xc8(%rbp)
jmp    1207 <main+0xb7>
cmpl   $0x4,-0x8(%rbp)
jne    11ba <main+0x6a>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xe57(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0xc8(%rbp)
jmp    1202 <main+0xb2>
mov    0x2e1f(%rip),%rax
movslq (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe30(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e00(%rip),%rax
movslq (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe34(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
jmp    1207 <main+0xb7>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     12b4 <main+0x164>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    1275 <main+0x125>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
movslq -0x1c(%rbp),%rax
lea    -0xc0(%rbp),%rdi
imul   $0x3,%rax,%rax
add    %rax,%rdi
mov    -0x28(%rbp),%rax
lea    0xded(%rip),%rsi
movsbl (%rax),%edx
call   1060 <sprintf@plt>
jmp    129a <main+0x14a>
movslq -0x1c(%rbp),%rax
lea    -0xc0(%rbp),%rdi
imul   $0x3,%rax,%rax
add    %rax,%rdi
mov    -0x28(%rbp),%rax
lea    0xdc4(%rip),%rsi
movsbl (%rax),%edx
call   1060 <sprintf@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    121f <main+0xcf>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0xc8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
lea    0xd87(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1328 <main+0x1d8>
mov    -0xc8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
movslq -0x1c(%rbp),%rax
lea    -0xc0(%rbp),%r8
imul   $0x3,%rax,%rax
add    %rax,%r8
lea    0xd54(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    12e0 <main+0x190>
mov    -0xc8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%ecx
lea    0xd3a(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0xc8(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %rsi,%rbx
cmp    $0x4,%edi
je     117e <main+0x2e>
cmp    $0x3,%edi
jne    1269 <main+0x119>
mov    0x2e5f(%rip),%rax
mov    (%rax),%r14
jmp    1191 <main+0x41>
mov    0x18(%rbx),%rdi
lea    0xe77(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%r14
mov    0x8(%rbx),%r15
mov    0x10(%rbx),%rbp
xor    %r12d,%r12d
mov    %rsp,%rbx
lea    0xeaf(%rip),%r13
jmp    11cf <main+0x7f>
nopl   0x0(%rax,%rax,1)
movsbl 0x1(%rbp),%edx
add    $0x1,%rbp
mov    %rbx,%rdi
mov    %r13,%rsi
call   1060 <sprintf@plt>
add    $0x1,%rbp
add    $0x1,%r12d
add    $0x3,%rbx
movzbl 0x0(%rbp),%eax
cmp    $0x5c,%al
je     11b0 <main+0x60>
test   %al,%al
je     11e3 <main+0x93>
mov    %al,(%rbx)
movb   $0x0,0x1(%rbx)
jmp    11c3 <main+0x73>
lea    0x1(%r12),%ecx
lea    0xe6a(%rip),%rsi
mov    %r14,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
test   %r12d,%r12d
mov    %r14,%r13
je     1236 <main+0xe6>
mov    %r12d,%r14d
mov    %rsp,%rbx
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    %r13,%rdi
lea    0xe4d(%rip),%rsi
mov    %r15,%rdx
mov    %ebp,%ecx
mov    %rbx,%r8
xor    %eax,%eax
call   1040 <fprintf@plt>
add    $0x1,%rbp
add    $0x3,%rbx
cmp    %rbp,%r14
jne    1210 <main+0xc0>
lea    0xe3a(%rip),%rsi
mov    %r13,%rdi
mov    %r15,%rdx
mov    %r12d,%ecx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %r13,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d70(%rip),%rbp
movslq 0x0(%rbp),%rdi
mov    (%rbx),%rdx
lea    0xd84(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
movslq 0x0(%rbp),%rdi
mov    (%rbx),%rdx
lea    0xd92(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stdout = global i32* null
@.str = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.1 = [35 x i8] c"%s <VarialbeName> <StringContent>\0A\00"
@.str.2 = [48 x i8] c"%s <VarialbeName> <StringContent> <OutputFile>\0A\00"
@.str.3 = [4 x i8] c"\\%c\00"
@.str.4 = [3 x i8] c"%c\00"
@.str.5 = [14 x i8] c"char %s[%u];\0A\00"
@.str.6 = [16 x i8] c"%s[%d] = '%s';\0A\00"
@.str.7 = [16 x i8] c"%s[%d] = '\\0';\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca [50 x [3 x i8]]
%11 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, 3
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = load i32*, i32** @stdout
store i32* %15, i32** %11
br label %41
16: ; preds = %2
%17 = load i32, i32* %4
%18 = icmp eq i32 %17, 4
br i1 %18, label %19, label %24
19: ; preds = %16
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 3
%22 = load i8*, i8** %21
%23 = call i32* @fopen(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %23, i32** %11
br label %40
24: ; preds = %16
%25 = load i32, i32* @stderr
%26 = sext i32 %25 to i64
%27 = inttoptr i64 %26 to i32*
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 0
%30 = load i8*, i8** %29
%31 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %27, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* %30)
%32 = load i32, i32* @stderr
%33 = sext i32 %32 to i64
%34 = inttoptr i64 %33 to i32*
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 0
%37 = load i8*, i8** %36
%38 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %34, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i8* %37)
%39 = call i32 @exit(i32 1)
unreachable
40: ; preds = %19
br label %41
41: ; preds = %40, %14
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 1
%44 = load i8*, i8** %43
store i8* %44, i8** %6
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 2
%47 = load i8*, i8** %46
store i8* %47, i8** %9
br label %48
48: ; preds = %76, %41
%49 = load i8*, i8** %9
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = icmp ne i32 %51, 0
br i1 %52, label %53, label %81
53: ; preds = %48
%54 = load i8*, i8** %9
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = icmp eq i32 %56, 92
br i1 %57, label %58, label %68
58: ; preds = %53
%59 = load i8*, i8** %9
%60 = getelementptr inbounds i8, i8* %59, i32 1
store i8* %60, i8** %9
%61 = load i32, i32* %7
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [50 x [3 x i8]], [50 x [3 x i8]]* %10, i64 0, i64 %62
%64 = getelementptr inbounds [3 x i8], [3 x i8]* %63, i64 0, i64 0
%65 = load i8*, i8** %9
%66 = load i8, i8* %65
%67 = call i32 @sprintf(i8* %64, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8 signext %66)
br label %76
68: ; preds = %53
%69 = load i32, i32* %7
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [50 x [3 x i8]], [50 x [3 x i8]]* %10, i64 0, i64 %70
%72 = getelementptr inbounds [3 x i8], [3 x i8]* %71, i64 0, i64 0
%73 = load i8*, i8** %9
%74 = load i8, i8* %73
%75 = call i32 @sprintf(i8* %72, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8 signext %74)
br label %76
76: ; preds = %68, %58
%77 = load i8*, i8** %9
%78 = getelementptr inbounds i8, i8* %77, i32 1
store i8* %78, i8** %9
%79 = load i32, i32* %7
%80 = add nsw i32 %79, 1
store i32 %80, i32* %7
br label %48
81: ; preds = %48
%82 = load i32, i32* %7
store i32 %82, i32* %8
%83 = load i32*, i32** %11
%84 = load i8*, i8** %6
%85 = load i32, i32* %8
%86 = add nsw i32 %85, 1
%87 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %83, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* %84, i32 %86)
store i32 0, i32* %7
br label %88
88: ; preds = %101, %81
%89 = load i32, i32* %7
%90 = load i32, i32* %8
%91 = icmp slt i32 %89, %90
br i1 %91, label %92, label %104
92: ; preds = %88
%93 = load i32*, i32** %11
%94 = load i8*, i8** %6
%95 = load i32, i32* %7
%96 = load i32, i32* %7
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds [50 x [3 x i8]], [50 x [3 x i8]]* %10, i64 0, i64 %97
%99 = getelementptr inbounds [3 x i8], [3 x i8]* %98, i64 0, i64 0
%100 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %93, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i8* %94, i32 %95, i8* %99)
br label %101
101: ; preds = %92
%102 = load i32, i32* %7
%103 = add nsw i32 %102, 1
store i32 %103, i32* %7
br label %88
104: ; preds = %88
%105 = load i32*, i32** %11
%106 = load i8*, i8** %6
%107 = load i32, i32* %8
%108 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %105, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i8* %106, i32 %107)
%109 = load i32*, i32** %11
%110 = call i32 @fclose(i32* %109)
ret i32 0
}

LLVM IR (-O2):
@stdout = global i32* null
@.str = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.1 = [35 x i8] c"%s <VarialbeName> <StringContent>\0A\00"
@.str.2 = [48 x i8] c"%s <VarialbeName> <StringContent> <OutputFile>\0A\00"
@.str.3 = [4 x i8] c"\\%c\00"
@.str.5 = [14 x i8] c"char %s[%u];\0A\00"
@.str.6 = [16 x i8] c"%s[%d] = '%s';\0A\00"
@.str.7 = [16 x i8] c"%s[%d] = '\\0';\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [50 x [3 x i8]]
%4 = getelementptr inbounds [50 x [3 x i8]], [50 x [3 x i8]]* %3, i64 0, i64 0, i64 0
switch i32 %0, label %11 [
i32 3, label %5
i32 4, label %7
]
5: ; preds = %2
%6 = load i32*, i32** @stdout
br label %23
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 3
%9 = load i8*, i8** %8
%10 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %23
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = sext i32 %12 to i64
%14 = inttoptr i64 %13 to i32*
%15 = load i8*, i8** %1
%16 = tail call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %14, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = load i32, i32* @stderr
%18 = sext i32 %17 to i64
%19 = inttoptr i64 %18 to i32*
%20 = load i8*, i8** %1
%21 = tail call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %19, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i8* %20)
%22 = tail call i32 @exit(i32 1)
unreachable
23: ; preds = %7, %5
%24 = phi i32* [ %6, %5 ], [ %10, %7 ]
%25 = getelementptr inbounds i8*, i8** %1, i64 1
%26 = load i8*, i8** %25
%27 = getelementptr inbounds i8*, i8** %1, i64 2
%28 = load i8*, i8** %27
br label %29
29: ; preds = %41, %23
%30 = phi i64 [ %44, %41 ], [ 0, %23 ]
%31 = phi i8* [ %43, %41 ], [ %28, %23 ]
%32 = load i8, i8* %31
switch i8 %32, label %38 [
i8 0, label %45
i8 92, label %33
]
33: ; preds = %29
%34 = getelementptr inbounds i8, i8* %31, i64 1
%35 = getelementptr inbounds [50 x [3 x i8]], [50 x [3 x i8]]* %3, i64 0, i64 %30, i64 0
%36 = load i8, i8* %34
%37 = call i32 @sprintf(i8* %35, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8 signext %36)
br label %41
38: ; preds = %29
%39 = getelementptr inbounds [50 x [3 x i8]], [50 x [3 x i8]]* %3, i64 0, i64 %30, i64 0
store i8 %32, i8* %39
%40 = getelementptr [50 x [3 x i8]], [50 x [3 x i8]]* %3, i64 0, i64 %30, i64 1
store i8 0, i8* %40
br label %41
41: ; preds = %38, %33
%42 = phi i8* [ %34, %33 ], [ %31, %38 ]
%43 = getelementptr inbounds i8, i8* %42, i64 1
%44 = add nuw i64 %30, 1
br label %29
45: ; preds = %29
%46 = trunc i64 %30 to i32
%47 = add nuw nsw i32 %46, 1
%48 = tail call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %24, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* %26, i32 %47)
%49 = icmp eq i32 %46, 0
br i1 %49, label %59, label %50
50: ; preds = %45
%51 = and i64 %30, 4294967295
br label %52
52: ; preds = %50, %52
%53 = phi i64 [ 0, %50 ], [ %57, %52 ]
%54 = getelementptr inbounds [50 x [3 x i8]], [50 x [3 x i8]]* %3, i64 0, i64 %53, i64 0
%55 = trunc i64 %53 to i32
%56 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %24, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i8* %26, i32 %55, i8* %54)
%57 = add nuw nsw i64 %53, 1
%58 = icmp eq i64 %57, %51
br i1 %58, label %59, label %52
59: ; preds = %52, %45
%60 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %24, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i8* %26, i32 %46)
%61 = call i32 @fclose(i32* %24)
ret i32 0
}