#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 const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ onefile(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ perror(char const *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
scalar_t__ strcasecmp(char const *, char *);
int main(int argc, char **argv) {
  int skip_source;
  const char *name;
  if (argc < 2) {
    fprintf(stderr, "Usage: tcl2c++ name [ file ... ]\n");
    exit(1);
  }
  printf("static char code[] = \"");
  name = argv[1];
  skip_source = (strcasecmp(name, "et_tk") == 0) ? 1 : 0;
  if (argc == 2)
    onefile(stdin, skip_source);
  else {
    for (; --argc >= 2; ++argv) {
      const char *filename = argv[2];
      FILE *f = fopen(filename, "r");
      if (f == 0) {
        perror(filename);
        exit(1);
      }
      onefile(f, skip_source);
      fclose(f);
    }
  }
  printf("\";\n");
  printf("#include \"tclcl.h\"\n");
  printf("EmbeddedTcl %s(code);\n", name);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11bf <main+0x3f>
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
lea    0xe50(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe55(%rip),%rsi
call   1030 <strcasecmp@plt>
mov    %rax,%rdx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0x0,%rdx
cmove  %ecx,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    121e <main+0x9e>
mov    0x2dda(%rip),%rax
mov    (%rax),%rdi
mov    -0x14(%rbp),%esi
call   1040 <onefile@plt>
jmp    129e <main+0x11e>
jmp    1223 <main+0xa3>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmp    $0x2,%eax
jl     1299 <main+0x119>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xdf3(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1273 <main+0xf3>
mov    -0x28(%rbp),%rdi
call   1090 <perror@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x30(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <onefile@plt>
mov    -0x30(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    1223 <main+0xa3>
jmp    129e <main+0x11e>
lea    0xd9c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd92(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xd94(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x1,%edi
jle    1283 <main+0xf3>
mov    %rsi,%r13
mov    %edi,%ebp
lea    0xe72(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x8(%r13),%rdi
lea    0xe77(%rip),%rsi
mov    %rdi,(%rsp)
call   1030 <strcasecmp@plt>
xor    %r15d,%r15d
test   %rax,%rax
sete   %r15b
cmp    $0x2,%ebp
jne    11ee <main+0x5e>
mov    0x2e07(%rip),%rax
mov    (%rax),%rdi
mov    %r15d,%esi
call   1040 <onefile@plt>
jmp    1236 <main+0xa6>
add    $0x1,%ebp
add    $0x10,%r13
lea    0xe43(%rip),%r12
nopl   0x0(%rax)
mov    0x0(%r13),%rbx
mov    %rbx,%rdi
mov    %r12,%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     1271 <main+0xe1>
mov    %rax,%r14
mov    %rax,%rdi
mov    %r15d,%esi
call   1040 <onefile@plt>
mov    %r14,%rdi
call   1060 <fclose@plt>
add    $0xffffffff,%ebp
add    $0x8,%r13
cmp    $0x3,%ebp
jg     1200 <main+0x70>
lea    0xe1b(%rip),%rdi
call   1050 <puts@plt>
lea    0xe12(%rip),%rdi
call   1050 <puts@plt>
lea    0xdec(%rip),%rdi
mov    (%rsp),%rsi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbx,%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    0x2d4e(%rip),%rax
mov    (%rax),%edi
lea    0xd6d(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [34 x i8] c"Usage: tcl2c++ name [ file ... ]\0A\00"
@.str.1 = [23 x i8] c"static char code[] = \22\00"
@.str.2 = [6 x i8] c"et_tk\00"
@stdin = global i32* null
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [4 x i8] c"\22;\0A\00"
@.str.5 = [20 x i8] c"#include \22tclcl.h\22\0A\00"
@.str.6 = [23 x i8] c"EmbeddedTcl %s(code);\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%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 slt i32 %10, 2
br i1 %11, label %12, label %16
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %2
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
store i8* %20, i8** %7
%21 = load i8*, i8** %7
%22 = call i64 @strcasecmp(i8* %21, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
%24 = zext i1 %23 to i64
%25 = select i1 %23, i32 1, i32 0
store i32 %25, i32* %6
%26 = load i32, i32* %4
%27 = icmp eq i32 %26, 2
br i1 %27, label %28, label %32
28: ; preds = %16
%29 = load i32*, i32** @stdin
%30 = load i32, i32* %6
%31 = call i32 @onefile(i32* %29, i32 %30)
br label %59
32: ; preds = %16
br label %33
33: ; preds = %55, %32
%34 = load i32, i32* %4
%35 = add nsw i32 %34, -1
store i32 %35, i32* %4
%36 = icmp sge i32 %35, 2
br i1 %36, label %37, label %58
37: ; preds = %33
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 2
%40 = load i8*, i8** %39
store i8* %40, i8** %8
%41 = load i8*, i8** %8
%42 = call i32* @fopen(i8* %41, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %42, i32** %9
%43 = load i32*, i32** %9
%44 = icmp eq i32* %43, null
br i1 %44, label %45, label %49
45: ; preds = %37
%46 = load i8*, i8** %8
%47 = call i32 @perror(i8* %46)
%48 = call i32 @exit(i32 1)
unreachable
49: ; preds = %37
%50 = load i32*, i32** %9
%51 = load i32, i32* %6
%52 = call i32 @onefile(i32* %50, i32 %51)
%53 = load i32*, i32** %9
%54 = call i32 @fclose(i32* %53)
br label %55
55: ; preds = %49
%56 = load i8**, i8*** %5
%57 = getelementptr inbounds i8*, i8** %56, i32 1
store i8** %57, i8*** %5
br label %33
58: ; preds = %33
br label %59
59: ; preds = %58, %28
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
%62 = load i8*, i8** %7
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i8* %62)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [34 x i8] c"Usage: tcl2c++ name [ file ... ]\0A\00"
@.str.1 = [23 x i8] c"static char code[] = \22\00"
@.str.2 = [6 x i8] c"et_tk\00"
@stdin = global i32* null
@.str.3 = [2 x i8] c"r\00"
@.str.6 = [23 x i8] c"EmbeddedTcl %s(code);\0A\00"
@str = [3 x i8] c"\22;\00"
@str.7 = [19 x i8] c"#include \22tclcl.h\22\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %2
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i64 @strcasecmp(i8* %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
%14 = zext i1 %13 to i32
%15 = icmp eq i32 %0, 2
br i1 %15, label %16, label %19
16: ; preds = %8
%17 = load i32*, i32** @stdin
%18 = tail call i32 @onefile(i32* %17, i32 %14)
br label %35
19: ; preds = %8, %29
%20 = phi i32 [ %30, %29 ], [ %0, %8 ]
%21 = phi i8** [ %33, %29 ], [ %1, %8 ]
%22 = getelementptr inbounds i8*, i8** %21, i64 2
%23 = load i8*, i8** %22
%24 = tail call i32* @fopen(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %29
26: ; preds = %19
%27 = tail call i32 @perror(i8* %23)
%28 = tail call i32 @exit(i32 1)
unreachable
29: ; preds = %19
%30 = add nsw i32 %20, -1
%31 = tail call i32 @onefile(i32* %24, i32 %14)
%32 = tail call i32 @fclose(i32* %24)
%33 = getelementptr inbounds i8*, i8** %21, i64 1
%34 = icmp sgt i32 %20, 3
br i1 %34, label %19, label %35
35: ; preds = %29, %16
%36 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
%37 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.7, i64 0, i64 0))
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i8* %11)
ret i32 0
}