#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*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ remove(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, ...);
int /*<<< orphan*/ stdin;
int strlen(char *);
int /*<<< orphan*/ strtok(char *, char *);
int system(char *);
int main(int argc, char *argv[]) {
  if (argc != 2) {
    printf("Usage: gorak {output code}\n");
    return 1;
  }
  if (strlen(argv[1]) > 256) {
    printf("{output code} cannot be longer than %d\n", 256);
    return 2;
  }
  char oName[256];
  char iCode[256];
  char oComp[256];
  printf("Input text:");
  fgets(iCode, 32, stdin);
  if (strlen(iCode) < 2) {
    printf("Input text must be entered\n");
    return 3;
  }
  strtok(iCode, "\n");
  sprintf(oName, "%s.c", argv[1]);
  FILE *oFile = fopen(oName, "w");
  fprintf(oFile, "#include <stdio.h>\n");
  fprintf(oFile, "void main()\n");
  fprintf(oFile, "{\n");
  fprintf(oFile, "  printf(\"%s\");\n", iCode);
  fprintf(oFile, "}\n");
  fclose(oFile);
  sprintf(oComp, "cc -o %s %s", argv[1], oName);
  int cRet = system(oComp);
  if (cRet) {
    printf("Error making output: %d\n", cRet);
  } else {
    printf("All good\n");
  }
  remove(oName);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x320,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11dd <main+0x3d>
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13a7 <main+0x207>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <strlen@plt>
cmp    $0x100,%eax
jle    1214 <main+0x74>
lea    0xe20(%rip),%rdi
mov    $0x100,%esi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    13a7 <main+0x207>
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x210(%rbp),%rdi
mov    0x2db8(%rip),%rax
mov    (%rax),%edx
mov    $0x20,%esi
call   1080 <fgets@plt>
lea    -0x210(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x2,%eax
jge    126b <main+0xcb>
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x3,-0x4(%rbp)
jmp    13a7 <main+0x207>
lea    -0x210(%rbp),%rdi
lea    0xe19(%rip),%rsi
call   10b0 <strtok@plt>
lea    -0x110(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xdd8(%rip),%rsi
mov    $0x0,%al
call   10c0 <sprintf@plt>
lea    -0x110(%rbp),%rdi
lea    0xdc8(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x318(%rbp)
mov    -0x318(%rbp),%rdi
lea    0xdb0(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x318(%rbp),%rdi
lea    0xdaf(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x318(%rbp),%rdi
lea    0xda7(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x318(%rbp),%rdi
lea    -0x210(%rbp),%rdx
lea    0xd8e(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x318(%rbp),%rdi
lea    0xcfb(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x318(%rbp),%rdi
call   1040 <fclose@plt>
lea    -0x310(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    -0x110(%rbp),%rcx
lea    0xd5a(%rip),%rsi
mov    $0x0,%al
call   10c0 <sprintf@plt>
lea    -0x310(%rbp),%rdi
call   1060 <system@plt>
mov    %eax,-0x31c(%rbp)
cmpl   $0x0,-0x31c(%rbp)
je     138d <main+0x1ed>
mov    -0x31c(%rbp),%esi
lea    0xd33(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    139b <main+0x1fb>
lea    0xd39(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x110(%rbp),%rdi
call   1030 <remove@plt>
mov    -0x4(%rbp),%eax
add    $0x320,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x308,%rsp
cmp    $0x2,%edi
jne    1200 <main+0x40>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1060 <strlen@plt>
cmp    $0x101,%eax
jl     1220 <main+0x60>
lea    0xe13(%rip),%rdi
mov    $0x100,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0x2,%eax
jmp    1211 <main+0x51>
lea    0xeb5(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%eax
add    $0x308,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xe01(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x2db3(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x20,%esi
call   1090 <fgets@plt>
mov    %r14,%rdi
call   1060 <strlen@plt>
cmp    $0x1,%eax
jg     1267 <main+0xa7>
lea    0xe46(%rip),%rdi
call   1040 <puts@plt>
mov    $0x3,%eax
jmp    1211 <main+0x51>
lea    0xdec(%rip),%rsi
mov    %rsp,%r15
mov    %r15,%rdi
call   10c0 <strtok@plt>
mov    0x8(%rbx),%rdx
lea    0xdb0(%rip),%rsi
lea    0x100(%rsp),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   10d0 <sprintf@plt>
lea    0xd9c(%rip),%rsi
mov    %r14,%rdi
call   10b0 <fopen@plt>
mov    %rax,%r12
lea    0xd8c(%rip),%rdi
mov    $0x13,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   10e0 <fwrite@plt>
lea    0xd87(%rip),%rdi
mov    $0xc,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   10e0 <fwrite@plt>
lea    0xd7b(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   10e0 <fwrite@plt>
lea    0xd65(%rip),%rsi
mov    %r12,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
lea    0xd62(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   10e0 <fwrite@plt>
mov    %r12,%rdi
call   1050 <fclose@plt>
mov    0x8(%rbx),%rdx
lea    0xd40(%rip),%rsi
lea    0x200(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14,%rcx
xor    %eax,%eax
call   10d0 <sprintf@plt>
mov    %rbx,%rdi
call   1070 <system@plt>
test   %eax,%eax
je     1366 <main+0x1a6>
lea    0xd24(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    1372 <main+0x1b2>
lea    0xd2b(%rip),%rdi
call   1040 <puts@plt>
lea    0x100(%rsp),%rdi
call   1030 <remove@plt>
xor    %eax,%eax
jmp    1211 <main+0x51>

LLVM IR (-O0):
@.str = [28 x i8] c"Usage: gorak {output code}\0A\00"
@.str.1 = [40 x i8] c"{output code} cannot be longer than %d\0A\00"
@.str.2 = [12 x i8] c"Input text:\00"
@stdin = global i32 0
@.str.3 = [28 x i8] c"Input text must be entered\0A\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [5 x i8] c"%s.c\00"
@.str.6 = [2 x i8] c"w\00"
@.str.7 = [20 x i8] c"#include <stdio.h>\0A\00"
@.str.8 = [13 x i8] c"void main()\0A\00"
@.str.9 = [3 x i8] c"{\0A\00"
@.str.10 = [17 x i8] c" printf(\22%s\22);\0A\00"
@.str.11 = [3 x i8] c"}\0A\00"
@.str.12 = [12 x i8] c"cc -o %s %s\00"
@.str.13 = [25 x i8] c"Error making output: %d\0A\00"
@.str.14 = [10 x i8] c"All good\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [256 x i8]
%7 = alloca [256 x i8]
%8 = alloca [256 x i8]
%9 = alloca i32*
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 2
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %74
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @strlen(i8* %18)
%20 = icmp sgt i32 %19, 256
br i1 %20, label %21, label %23
21: ; preds = %15
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i32 256)
store i32 2, i32* %3
br label %74
23: ; preds = %15
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%25 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%26 = load i32, i32* @stdin
%27 = call i32 @fgets(i8* %25, i32 32, i32 %26)
%28 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%29 = call i32 @strlen(i8* %28)
%30 = icmp slt i32 %29, 2
br i1 %30, label %31, label %33
31: ; preds = %23
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
store i32 3, i32* %3
br label %74
33: ; preds = %23
%34 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%35 = call i32 @strtok(i8* %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%36 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 1
%39 = load i8*, i8** %38
%40 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %36, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* %39)
%41 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%42 = call i32* @fopen(i8* %41, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
store i32* %42, i32** %9
%43 = load i32*, i32** %9
%44 = call i32 (i32*, i8*, ...) @fprintf(i32* %43, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
%45 = load i32*, i32** %9
%46 = call i32 (i32*, i8*, ...) @fprintf(i32* %45, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
%47 = load i32*, i32** %9
%48 = call i32 (i32*, i8*, ...) @fprintf(i32* %47, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
%49 = load i32*, i32** %9
%50 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%51 = call i32 (i32*, i8*, ...) @fprintf(i32* %49, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.10, i64 0, i64 0), i8* %50)
%52 = load i32*, i32** %9
%53 = call i32 (i32*, i8*, ...) @fprintf(i32* %52, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0))
%54 = load i32*, i32** %9
%55 = call i32 @fclose(i32* %54)
%56 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%57 = load i8**, i8*** %5
%58 = getelementptr inbounds i8*, i8** %57, i64 1
%59 = load i8*, i8** %58
%60 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%61 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %56, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0), i8* %59, i8* %60)
%62 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%63 = call i32 @system(i8* %62)
store i32 %63, i32* %10
%64 = load i32, i32* %10
%65 = icmp ne i32 %64, 0
br i1 %65, label %66, label %69
66: ; preds = %33
%67 = load i32, i32* %10
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.13, i64 0, i64 0), i32 %67)
br label %71
69: ; preds = %33
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.14, i64 0, i64 0))
br label %71
71: ; preds = %69, %66
%72 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%73 = call i32 @remove(i8* %72)
br label %74
74: ; preds = %71, %31, %21, %13
%75 = load i32, i32* %3
ret i32 %75
}

LLVM IR (-O2):
@.str.1 = [40 x i8] c"{output code} cannot be longer than %d\0A\00"
@.str.2 = [12 x i8] c"Input text:\00"
@stdin = global i32 0
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [5 x i8] c"%s.c\00"
@.str.6 = [2 x i8] c"w\00"
@.str.7 = [20 x i8] c"#include <stdio.h>\0A\00"
@.str.8 = [13 x i8] c"void main()\0A\00"
@.str.9 = [3 x i8] c"{\0A\00"
@.str.10 = [17 x i8] c" printf(\22%s\22);\0A\00"
@.str.11 = [3 x i8] c"}\0A\00"
@.str.12 = [12 x i8] c"cc -o %s %s\00"
@.str.13 = [25 x i8] c"Error making output: %d\0A\00"
@str = [9 x i8] c"All good\00"
@str.15 = [27 x i8] c"Input text must be entered\00"
@str.16 = [27 x i8] c"Usage: gorak {output code}\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i8]
%4 = alloca [256 x i8]
%5 = alloca [256 x i8]
%6 = icmp eq i32 %0, 2
br i1 %6, label %9, label %7
7: ; preds = %2
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.16, i64 0, i64 0))
br label %50
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 @strlen(i8* %11)
%13 = icmp sgt i32 %12, 256
br i1 %13, label %14, label %16
14: ; preds = %9
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i32 256)
br label %50
16: ; preds = %9
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%19 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%21 = load i32, i32* @stdin
%22 = call i32 @fgets(i8* %18, i32 32, i32 %21)
%23 = call i32 @strlen(i8* %18)
%24 = icmp slt i32 %23, 2
br i1 %24, label %25, label %27
25: ; preds = %16
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.15, i64 0, i64 0))
br label %48
27: ; preds = %16
%28 = call i32 @strtok(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%29 = load i8*, i8** %10
%30 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %17, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* %29)
%31 = call i32* @fopen(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%32 = call i64 @fwrite(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), i64 19, i64 1, i32* %31)
%33 = call i64 @fwrite(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i64 12, i64 1, i32* %31)
%34 = call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i64 2, i64 1, i32* %31)
%35 = call i32 (i32*, i8*, ...) @fprintf(i32* %31, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.10, i64 0, i64 0), i8* %18)
%36 = call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i64 2, i64 1, i32* %31)
%37 = call i32 @fclose(i32* %31)
%38 = load i8*, i8** %10
%39 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %19, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0), i8* %38, i8* %17)
%40 = call i32 @system(i8* %19)
%41 = icmp eq i32 %40, 0
br i1 %41, label %44, label %42
42: ; preds = %27
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.13, i64 0, i64 0), i32 %40)
br label %46
44: ; preds = %27
%45 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
br label %46
46: ; preds = %44, %42
%47 = call i32 @remove(i8* %17)
br label %48
48: ; preds = %46, %25
%49 = phi i32 [ 3, %25 ], [ 0, %46 ]
br label %50
50: ; preds = %48, %7, %14
%51 = phi i32 [ 1, %7 ], [ 2, %14 ], [ %49, %48 ]
ret i32 %51
}