#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 /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int getopt(int, char **, char *);
int optind;
int optopt;
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ tt_close();
int /*<<< orphan*/ tt_close_script();
int /*<<< orphan*/ tt_init();
int /*<<< orphan*/ tt_open_script(char const *);
int /*<<< orphan*/ tt_record();
int /*<<< orphan*/ tt_record_run(char const *);
int /*<<< orphan*/ tt_run(char const *);
int /*<<< orphan*/ tt_set_fastmode(int);
int /*<<< orphan*/ tt_set_xmloutput(int);
int /*<<< orphan*/ usage(char *);
int main(int argc, char *argv[]) {
  const char *script;
  const char *cmd;
  int c;
  while ((c = getopt(argc, argv, "fx")) != -1) {
    switch (c) {
    case 'f':
      tt_set_fastmode(1);
      break;
    case 'x':
      tt_set_xmloutput(1);
      break;
    case '?':
      fprintf(stderr, "Error: unknown option -%c\n", optopt);
      usage(argv[0]);
      return 1;
    }
  }
  if ((argc - optind) < 2) {
    usage(argv[0]);
    return 1;
  }
  script = argv[optind];
  cmd = argv[optind + 1];
  tt_init();
  if (!tt_open_script(script)) {
    fprintf(stderr, "Error: couldn't open `%s': %s\n", script, strerror(errno));
    return 1;
  }
  tt_record_run(cmd);
  tt_run(cmd);
  tt_record();
  tt_close_script();
  tt_close();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe0c(%rip),%rdx
call   10c0 <getopt@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
je     1296 <main+0xc6>
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
sub    $0x3f,%eax
je     1259 <main+0x89>
jmp    1219 <main+0x49>
mov    -0x28(%rbp),%eax
sub    $0x66,%eax
je     123b <main+0x6b>
jmp    122a <main+0x5a>
mov    -0x28(%rbp),%eax
sub    $0x78,%eax
je     124a <main+0x7a>
jmp    1291 <main+0xc1>
mov    $0x1,%edi
call   1090 <tt_set_fastmode@plt>
jmp    1291 <main+0xc1>
mov    $0x1,%edi
call   10b0 <tt_set_xmloutput@plt>
jmp    1291 <main+0xc1>
mov    0x2d70(%rip),%rax
mov    (%rax),%edi
mov    0x2d7f(%rip),%rax
mov    (%rax),%edx
lea    0xd91(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10a0 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    1381 <main+0x1b1>
jmp    11e6 <main+0x16>
mov    -0x8(%rbp),%eax
mov    0x2d40(%rip),%rcx
sub    (%rcx),%eax
cmp    $0x2,%eax
jge    12c3 <main+0xf3>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10a0 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    1381 <main+0x1b1>
mov    -0x10(%rbp),%rax
mov    0x2d12(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x2cfc(%rip),%rcx
mov    (%rcx),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   10e0 <tt_init@plt>
mov    -0x18(%rbp),%rdi
call   10d0 <tt_open_script@plt>
cmp    $0x0,%eax
jne    1353 <main+0x183>
mov    0x2cbc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    0x2ca0(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    -0x34(%rbp),%edi
mov    -0x30(%rbp),%rdx
mov    %rax,%rcx
lea    0xcde(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1381 <main+0x1b1>
mov    -0x20(%rbp),%rdi
call   1080 <tt_record_run@plt>
mov    -0x20(%rbp),%rdi
call   1030 <tt_run@plt>
mov    $0x0,%al
call   1050 <tt_record@plt>
mov    $0x0,%al
call   1060 <tt_close_script@plt>
mov    $0x0,%al
call   1040 <tt_close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xe20(%rip),%r14
jmp    11ff <main+0x2f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    $0x66,%eax
jne    1222 <main+0x52>
mov    $0x1,%edi
call   1090 <tt_set_fastmode@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   10c0 <getopt@plt>
cmp    $0x77,%eax
jle    11f0 <main+0x20>
cmp    $0x78,%eax
jne    11ff <main+0x2f>
mov    $0x1,%edi
call   10b0 <tt_set_xmloutput@plt>
jmp    11ff <main+0x2f>
cmp    $0xffffffff,%eax
je     124e <main+0x7e>
cmp    $0x3f,%eax
jne    11ff <main+0x2f>
mov    0x2d9d(%rip),%rax
mov    (%rax),%edi
mov    0x2dac(%rip),%rax
mov    (%rax),%edx
lea    0xdbe(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    125f <main+0x8f>
mov    0x2d8b(%rip),%rax
movslq (%rax),%rax
sub    %eax,%ebp
cmp    $0x1,%ebp
jg     1273 <main+0xa3>
mov    (%rbx),%rdi
call   10a0 <usage@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    (%rbx,%rax,8),%r14
mov    0x8(%rbx,%rax,8),%rbp
xor    %ebx,%ebx
xor    %eax,%eax
call   10e0 <tt_init@plt>
mov    %r14,%rdi
call   10d0 <tt_open_script@plt>
test   %eax,%eax
je     12b8 <main+0xe8>
mov    %rbp,%rdi
call   1080 <tt_record_run@plt>
mov    %rbp,%rdi
call   1030 <tt_run@plt>
xor    %eax,%eax
call   1050 <tt_record@plt>
xor    %eax,%eax
call   1060 <tt_close_script@plt>
xor    %eax,%eax
call   1040 <tt_close@plt>
jmp    126c <main+0x9c>
mov    0x2d11(%rip),%rax
mov    (%rax),%ebx
mov    0x2d00(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
lea    0xd48(%rip),%rsi
mov    %ebx,%edi
mov    %r14,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    1267 <main+0x97>

LLVM IR (-O0):
@.str = [3 x i8] c"fx\00"
@stderr = global i32 0
@.str.1 = [27 x i8] c"Error: unknown option -%c\0A\00"
@optopt = global i32 0
@optind = global i32 0
@.str.2 = [31 x i8] c"Error: couldn't open `%s': %s\0A\00"
@errno = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %9
9: ; preds = %28, %2
%10 = load i32, i32* %4
%11 = load i8**, i8*** %5
%12 = call i32 @getopt(i32 %10, i8** %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 %12, i32* %8
%13 = icmp ne i32 %12, -1
br i1 %13, label %14, label %29
14: ; preds = %9
%15 = load i32, i32* %8
switch i32 %15, label %28 [
i32 102, label %16
i32 120, label %18
i32 63, label %20
]
16: ; preds = %14
%17 = call i32 @tt_set_fastmode(i32 1)
br label %28
18: ; preds = %14
%19 = call i32 @tt_set_xmloutput(i32 1)
br label %28
20: ; preds = %14
%21 = load i32, i32* @stderr
%22 = load i32, i32* @optopt
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %22)
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 0
%26 = load i8*, i8** %25
%27 = call i32 @usage(i8* %26)
store i32 1, i32* %3
br label %69
28: ; preds = %14, %18, %16
br label %9
29: ; preds = %9
%30 = load i32, i32* %4
%31 = load i32, i32* @optind
%32 = sub nsw i32 %30, %31
%33 = icmp slt i32 %32, 2
br i1 %33, label %34, label %39
34: ; preds = %29
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 0
%37 = load i8*, i8** %36
%38 = call i32 @usage(i8* %37)
store i32 1, i32* %3
br label %69
39: ; preds = %29
%40 = load i8**, i8*** %5
%41 = load i32, i32* @optind
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8*, i8** %40, i64 %42
%44 = load i8*, i8** %43
store i8* %44, i8** %6
%45 = load i8**, i8*** %5
%46 = load i32, i32* @optind
%47 = add nsw i32 %46, 1
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8*, i8** %45, i64 %48
%50 = load i8*, i8** %49
store i8* %50, i8** %7
%51 = call i32 (...) @tt_init()
%52 = load i8*, i8** %6
%53 = call i32 @tt_open_script(i8* %52)
%54 = icmp ne i32 %53, 0
br i1 %54, label %61, label %55
55: ; preds = %39
%56 = load i32, i32* @stderr
%57 = load i8*, i8** %6
%58 = load i32, i32* @errno
%59 = call i8* @strerror(i32 %58)
%60 = call i32 (i32, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %57, i8* %59)
store i32 1, i32* %3
br label %69
61: ; preds = %39
%62 = load i8*, i8** %7
%63 = call i32 @tt_record_run(i8* %62)
%64 = load i8*, i8** %7
%65 = call i32 @tt_run(i8* %64)
%66 = call i32 (...) @tt_record()
%67 = call i32 (...) @tt_close_script()
%68 = call i32 (...) @tt_close()
store i32 0, i32* %3
br label %69
69: ; preds = %61, %55, %34, %20
%70 = load i32, i32* %3
ret i32 %70
}

LLVM IR (-O2):
@.str = [3 x i8] c"fx\00"
@stderr = global i32 0
@.str.1 = [27 x i8] c"Error: unknown option -%c\0A\00"
@optopt = global i32 0
@optind = global i32 0
@.str.2 = [31 x i8] c"Error: couldn't open `%s': %s\0A\00"
@errno = global i32 0
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %5, %2
%4 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
switch i32 %4, label %5 [
i32 -1, label %16
i32 102, label %6
i32 120, label %8
i32 63, label %10
]
5: ; preds = %3, %8, %6
br label %3
6: ; preds = %3
%7 = tail call i32 @tt_set_fastmode(i32 1)
br label %5
8: ; preds = %3
%9 = tail call i32 @tt_set_xmloutput(i32 1)
br label %5
10: ; preds = %3
%11 = load i32, i32* @stderr
%12 = load i32, i32* @optopt
%13 = tail call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = load i8*, i8** %1
%15 = tail call i32 @usage(i8* %14)
br label %45
16: ; preds = %3
%17 = load i32, i32* @optind
%18 = sub nsw i32 %0, %17
%19 = icmp slt i32 %18, 2
br i1 %19, label %20, label %23
20: ; preds = %16
%21 = load i8*, i8** %1
%22 = tail call i32 @usage(i8* %21)
br label %45
23: ; preds = %16
%24 = sext i32 %17 to i64
%25 = getelementptr inbounds i8*, i8** %1, i64 %24
%26 = load i8*, i8** %25
%27 = add nsw i32 %17, 1
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8*, i8** %1, i64 %28
%30 = load i8*, i8** %29
%31 = tail call i32 (...) @tt_init()
%32 = tail call i32 @tt_open_script(i8* %26)
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %39
34: ; preds = %23
%35 = load i32, i32* @stderr
%36 = load i32, i32* @errno
%37 = tail call i8* @strerror(i32 %36)
%38 = tail call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %26, i8* %37)
br label %45
39: ; preds = %23
%40 = tail call i32 @tt_record_run(i8* %30)
%41 = tail call i32 @tt_run(i8* %30)
%42 = tail call i32 (...) @tt_record()
%43 = tail call i32 (...) @tt_close_script()
%44 = tail call i32 (...) @tt_close()
br label %45
45: ; preds = %39, %34, %20, %10
%46 = phi i32 [ 1, %10 ], [ 1, %20 ], [ 0, %39 ], [ 1, %34 ]
ret i32 %46
}