#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*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ invert_str(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int strlen(char *);
int main(int i, char *c[]) {
  char dest_fname[80], in_linebuffer[180];
  FILE *fileout, *filein;
  if (i > 1) {
    sprintf(dest_fname, "%s.c", c[1]);
    fileout = fopen(dest_fname, "w");
    filein = fopen(c[1], "r");
    if (fileout && filein) {
      fgets(in_linebuffer, 180, filein);
      (in_linebuffer[strlen(in_linebuffer) - 1] = 0);
      invert_str(in_linebuffer);
      fputs("char *s_leading=\"", fileout);
      fputs(in_linebuffer, fileout);
      fputs("\";\n", fileout);
      fputs("char *s_messages[]={\n", fileout);
      while (fgets(in_linebuffer, 180, filein)) {
        (in_linebuffer[strlen(in_linebuffer) - 1] = 0);
        invert_str(in_linebuffer);
        fputs("\"", fileout);
        fputs(in_linebuffer, fileout);
        fputs("\",\n", fileout);
      }
      fputs("};\n", fileout);
      fputs("unsigned s_mess_num = sizeof(s_messages)/sizeof(char *);\n",
            fileout);
      fclose(filein);
      fclose(fileout);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    134a <main+0x1da>
lea    -0x60(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe5a(%rip),%rsi
call   1090 <sprintf@plt>
lea    -0x60(%rbp),%rdi
lea    0xe4f(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x128(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe36(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x130(%rbp)
cmpq   $0x0,-0x128(%rbp)
je     1345 <main+0x1d5>
cmpq   $0x0,-0x130(%rbp)
je     1345 <main+0x1d5>
lea    -0x120(%rbp),%rdi
mov    -0x130(%rbp),%rdx
mov    $0xb4,%esi
call   1060 <fgets@plt>
lea    -0x120(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x120(%rbp,%rax,1)
lea    -0x120(%rbp),%rdi
call   1070 <invert_str@plt>
mov    -0x128(%rbp),%rsi
lea    0xdc5(%rip),%rdi
call   1050 <fputs@plt>
lea    -0x120(%rbp),%rdi
mov    -0x128(%rbp),%rsi
call   1050 <fputs@plt>
mov    -0x128(%rbp),%rsi
lea    0xdb1(%rip),%rdi
call   1050 <fputs@plt>
mov    -0x128(%rbp),%rsi
lea    0xda2(%rip),%rdi
call   1050 <fputs@plt>
lea    -0x120(%rbp),%rdi
mov    -0x130(%rbp),%rdx
mov    $0xb4,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     1307 <main+0x197>
lea    -0x120(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x120(%rbp,%rax,1)
lea    -0x120(%rbp),%rdi
call   1070 <invert_str@plt>
mov    -0x128(%rbp),%rsi
lea    0xd42(%rip),%rdi
call   1050 <fputs@plt>
lea    -0x120(%rbp),%rdi
mov    -0x128(%rbp),%rsi
call   1050 <fputs@plt>
mov    -0x128(%rbp),%rsi
lea    0xd38(%rip),%rdi
call   1050 <fputs@plt>
jmp    1282 <main+0x112>
mov    -0x128(%rbp),%rsi
lea    0xd24(%rip),%rdi
call   1050 <fputs@plt>
mov    -0x128(%rbp),%rsi
lea    0xd15(%rip),%rdi
call   1050 <fputs@plt>
mov    -0x130(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x128(%rbp),%rdi
call   1030 <fclose@plt>
jmp    134a <main+0x1da>
xor    %eax,%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x108,%rsp
cmp    $0x2,%edi
jl     133b <main+0x1ab>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdx
lea    0xe4b(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
call   10a0 <sprintf@plt>
lea    0xe3e(%rip),%rsi
mov    %r14,%rdi
call   1090 <fopen@plt>
mov    %rax,%r15
mov    0x8(%rbx),%rdi
lea    0xe2a(%rip),%rsi
call   1090 <fopen@plt>
test   %r15,%r15
je     133b <main+0x1ab>
mov    %rax,%r14
test   %rax,%rax
je     133b <main+0x1ab>
lea    0x50(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xb4,%esi
mov    %r14,%rdx
call   1070 <fgets@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    %rbx,%rdi
call   1080 <invert_str@plt>
lea    0xddf(%rip),%rdi
mov    $0x11,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   10b0 <fwrite@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <fputs@plt>
lea    0xdcd(%rip),%rdi
mov    $0x3,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   10b0 <fwrite@plt>
lea    0xdb8(%rip),%rdi
mov    $0x15,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   10b0 <fwrite@plt>
mov    %rbx,%rdi
mov    $0xb4,%esi
mov    %r14,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     12f9 <main+0x169>
lea    0xda0(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    %rbx,%rdi
call   1080 <invert_str@plt>
mov    $0x22,%edi
mov    %r15,%rsi
call   1060 <fputc@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <fputs@plt>
mov    $0x3,%esi
mov    $0x1,%edx
mov    %r12,%rdi
mov    %r15,%rcx
call   10b0 <fwrite@plt>
mov    %rbx,%rdi
mov    $0xb4,%esi
mov    %r14,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
jne    12a0 <main+0x110>
lea    0xd39(%rip),%rdi
mov    $0x3,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   10b0 <fwrite@plt>
lea    0xd24(%rip),%rdi
mov    $0x39,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   10b0 <fwrite@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    %r15,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%s.c\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [18 x i8] c"char *s_leading=\22\00"
@.str.4 = [4 x i8] c"\22;\0A\00"
@.str.5 = [22 x i8] c"char *s_messages[]={\0A\00"
@.str.6 = [2 x i8] c"\22\00"
@.str.7 = [4 x i8] c"\22,\0A\00"
@.str.8 = [4 x i8] c"};\0A\00"
@.str.9 = [58 x i8] c"unsigned s_mess_num = sizeof(s_messages)/sizeof(char *);\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [80 x i8]
%7 = alloca [180 x i8]
%8 = alloca i32*
%9 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp sgt i32 %10, 1
br i1 %11, label %12, label %79
12: ; preds = %2
%13 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @sprintf(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%19 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %19, i32** %8
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32* @fopen(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %23, i32** %9
%24 = load i32*, i32** %8
%25 = icmp ne i32* %24, null
br i1 %25, label %26, label %78
26: ; preds = %12
%27 = load i32*, i32** %9
%28 = icmp ne i32* %27, null
br i1 %28, label %29, label %78
29: ; preds = %26
%30 = getelementptr inbounds [180 x i8], [180 x i8]* %7, i64 0, i64 0
%31 = load i32*, i32** %9
%32 = call i64 @fgets(i8* %30, i32 180, i32* %31)
%33 = getelementptr inbounds [180 x i8], [180 x i8]* %7, i64 0, i64 0
%34 = call i32 @strlen(i8* %33)
%35 = sub nsw i32 %34, 1
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [180 x i8], [180 x i8]* %7, i64 0, i64 %36
store i8 0, i8* %37
%38 = getelementptr inbounds [180 x i8], [180 x i8]* %7, i64 0, i64 0
%39 = call i32 @invert_str(i8* %38)
%40 = load i32*, i32** %8
%41 = call i32 @fputs(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32* %40)
%42 = getelementptr inbounds [180 x i8], [180 x i8]* %7, i64 0, i64 0
%43 = load i32*, i32** %8
%44 = call i32 @fputs(i8* %42, i32* %43)
%45 = load i32*, i32** %8
%46 = call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32* %45)
%47 = load i32*, i32** %8
%48 = call i32 @fputs(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i32* %47)
br label %49
49: ; preds = %54, %29
%50 = getelementptr inbounds [180 x i8], [180 x i8]* %7, i64 0, i64 0
%51 = load i32*, i32** %9
%52 = call i64 @fgets(i8* %50, i32 180, i32* %51)
%53 = icmp ne i64 %52, 0
br i1 %53, label %54, label %69
54: ; preds = %49
%55 = getelementptr inbounds [180 x i8], [180 x i8]* %7, i64 0, i64 0
%56 = call i32 @strlen(i8* %55)
%57 = sub nsw i32 %56, 1
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [180 x i8], [180 x i8]* %7, i64 0, i64 %58
store i8 0, i8* %59
%60 = getelementptr inbounds [180 x i8], [180 x i8]* %7, i64 0, i64 0
%61 = call i32 @invert_str(i8* %60)
%62 = load i32*, i32** %8
%63 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i32* %62)
%64 = getelementptr inbounds [180 x i8], [180 x i8]* %7, i64 0, i64 0
%65 = load i32*, i32** %8
%66 = call i32 @fputs(i8* %64, i32* %65)
%67 = load i32*, i32** %8
%68 = call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32* %67)
br label %49
69: ; preds = %49
%70 = load i32*, i32** %8
%71 = call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i32* %70)
%72 = load i32*, i32** %8
%73 = call i32 @fputs(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.9, i64 0, i64 0), i32* %72)
%74 = load i32*, i32** %9
%75 = call i32 @fclose(i32* %74)
%76 = load i32*, i32** %8
%77 = call i32 @fclose(i32* %76)
br label %78
78: ; preds = %69, %26, %12
br label %79
79: ; preds = %78, %2
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%s.c\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [18 x i8] c"char *s_leading=\22\00"
@.str.4 = [4 x i8] c"\22;\0A\00"
@.str.5 = [22 x i8] c"char *s_messages[]={\0A\00"
@.str.7 = [4 x i8] c"\22,\0A\00"
@.str.8 = [4 x i8] c"};\0A\00"
@.str.9 = [58 x i8] c"unsigned s_mess_num = sizeof(s_messages)/sizeof(char *);\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [80 x i8]
%4 = alloca [180 x i8]
%5 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [180 x i8], [180 x i8]* %4, i64 0, i64 0
%7 = icmp sgt i32 %0, 1
br i1 %7, label %8, label %47
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = load i8*, i8** %9
%14 = tail call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp ne i32* %12, null
%16 = icmp ne i32* %14, null
%17 = and i1 %15, %16
br i1 %17, label %18, label %47
18: ; preds = %8
%19 = call i64 @fgets(i8* %6, i32 180, i32* %14)
%20 = call i32 @strlen(i8* %6)
%21 = add nsw i32 %20, -1
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [180 x i8], [180 x i8]* %4, i64 0, i64 %22
store i8 0, i8* %23
%24 = call i32 @invert_str(i8* %6)
%25 = call i64 @fwrite(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i64 17, i64 1, i32* %12)
%26 = call i32 @fputs(i8* %6, i32* %12)
%27 = call i64 @fwrite(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i64 3, i64 1, i32* %12)
%28 = call i64 @fwrite(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i64 21, i64 1, i32* %12)
%29 = call i64 @fgets(i8* %6, i32 180, i32* %14)
%30 = icmp eq i64 %29, 0
br i1 %30, label %42, label %31
31: ; preds = %18, %31
%32 = call i32 @strlen(i8* %6)
%33 = add nsw i32 %32, -1
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [180 x i8], [180 x i8]* %4, i64 0, i64 %34
store i8 0, i8* %35
%36 = call i32 @invert_str(i8* %6)
%37 = call i32 @fputc(i32 34, i32* %12)
%38 = call i32 @fputs(i8* %6, i32* %12)
%39 = call i64 @fwrite(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i64 3, i64 1, i32* %12)
%40 = call i64 @fgets(i8* %6, i32 180, i32* %14)
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %31
42: ; preds = %31, %18
%43 = call i64 @fwrite(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i64 3, i64 1, i32* %12)
%44 = call i64 @fwrite(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.9, i64 0, i64 0), i64 57, i64 1, i32* %12)
%45 = call i32 @fclose(i32* %14)
%46 = call i32 @fclose(i32* %12)
br label %47
47: ; preds = %8, %42, %2
ret i32 0
}