#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*/ WSQ_AddOp(int, char *, char *, char *, char *);
int /*<<< orphan*/ WSQ_BeginSubgraph(int);
int /*<<< orphan*/ WSQ_BeginTransaction(int);
int /*<<< orphan*/ WSQ_EndSubgraph();
int WSQ_EndTransaction();
int /*<<< orphan*/ WSQ_Init(char *);
int /*<<< orphan*/ WSQ_Pause();
int /*<<< orphan*/ WSQ_SetQueryName(char *);
int /*<<< orphan*/ abort();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int main(int argc, char *argv[]) {
  char *filename = "TAQ.1000000";
  char opargs[1000];
  if (argc <= 1) {
  } else if (argc == 2) {
    filename = argv[1];
    printf("Reading input tuples from file %s\n", filename);
  } else {
    printf("ERROR: wrong number of arguments!\n");
    abort();
  }
  WSQ_Init("");
  WSQ_SetQueryName("generated_query_1");
  WSQ_Pause();
  printf("PAUSED WSQ engine, run compiled query manually...\n");
  WSQ_BeginTransaction(1001);
  WSQ_BeginSubgraph(101);
  sprintf(opargs, "-1 || %s", filename);
  WSQ_AddOp(1, "ASCIIFileSource", "", "100", opargs);
  WSQ_AddOp(2, "UDF", "100", "200", "output_timer.ws | output_timer | 1.0 ");
  WSQ_EndSubgraph();
  int pid = WSQ_EndTransaction();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe30(%rip),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x1,-0x8(%rbp)
jg     11e3 <main+0x33>
jmp    122a <main+0x7a>
cmpl   $0x2,-0x8(%rbp)
jne    1210 <main+0x60>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1225 <main+0x75>
lea    0xe18(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    122a <main+0x7a>
lea    0xe20(%rip),%rdi
call   1060 <WSQ_Init@plt>
lea    0xe15(%rip),%rdi
call   1080 <WSQ_SetQueryName@plt>
mov    $0x0,%al
call   10d0 <WSQ_Pause@plt>
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x3e9,%edi
call   1070 <WSQ_BeginTransaction@plt>
mov    $0x65,%edi
call   10a0 <WSQ_BeginSubgraph@plt>
lea    -0x400(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe1a(%rip),%rsi
call   10c0 <sprintf@plt>
lea    -0x400(%rbp),%r8
mov    $0x1,%edi
lea    0xe0b(%rip),%rsi
lea    0xdb5(%rip),%rdx
lea    0xe0d(%rip),%rcx
call   1090 <WSQ_AddOp@plt>
mov    $0x2,%edi
lea    0xe00(%rip),%rsi
lea    0xdf5(%rip),%rdx
lea    0xdf6(%rip),%rcx
lea    0xdf3(%rip),%r8
call   1090 <WSQ_AddOp@plt>
mov    $0x0,%al
call   1050 <WSQ_EndSubgraph@plt>
mov    $0x0,%al
call   10b0 <WSQ_EndTransaction@plt>
mov    %eax,-0x404(%rbp)
xor    %eax,%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x3f0,%rsp
cmp    $0x2,%edi
jge    11da <main+0x1a>
lea    0xe28(%rip),%r15
jmp    11f5 <main+0x35>
jne    12ac <main+0xec>
mov    0x8(%rsi),%r15
lea    0xe21(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe32(%rip),%r14
mov    %r14,%rdi
call   1070 <WSQ_Init@plt>
lea    0xe24(%rip),%rdi
call   1090 <WSQ_SetQueryName@plt>
xor    %eax,%eax
call   10e0 <WSQ_Pause@plt>
lea    0xe90(%rip),%rdi
call   1040 <puts@plt>
mov    $0x3e9,%edi
call   1080 <WSQ_BeginTransaction@plt>
mov    $0x65,%edi
call   10b0 <WSQ_BeginSubgraph@plt>
lea    0xe03(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r15,%rdx
call   10d0 <sprintf@plt>
lea    0xdf7(%rip),%rsi
lea    0xe00(%rip),%r15
mov    $0x1,%edi
mov    %r14,%rdx
mov    %r15,%rcx
mov    %rbx,%r8
call   10a0 <WSQ_AddOp@plt>
lea    0xdea(%rip),%rsi
lea    0xde7(%rip),%rcx
lea    0xde4(%rip),%r8
mov    $0x2,%edi
mov    %r15,%rdx
call   10a0 <WSQ_AddOp@plt>
xor    %eax,%eax
call   1060 <WSQ_EndSubgraph@plt>
xor    %eax,%eax
call   10c0 <WSQ_EndTransaction@plt>
xor    %eax,%eax
add    $0x3f0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xdd9(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"TAQ.1000000\00"
@.str.1 = [35 x i8] c"Reading input tuples from file %s\0A\00"
@.str.2 = [35 x i8] c"ERROR: wrong number of arguments!\0A\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [18 x i8] c"generated_query_1\00"
@.str.5 = [51 x i8] c"PAUSED WSQ engine, run compiled query manually...\0A\00"
@.str.6 = [9 x i8] c"-1 || %s\00"
@.str.7 = [16 x i8] c"ASCIIFileSource\00"
@.str.8 = [4 x i8] c"100\00"
@.str.9 = [4 x i8] c"UDF\00"
@.str.10 = [4 x i8] c"200\00"
@.str.11 = [38 x i8] c"output_timer.ws | output_timer | 1.0 \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca [1000 x i8]
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %6
%9 = load i32, i32* %4
%10 = icmp sle i32 %9, 1
br i1 %10, label %11, label %12
11: ; preds = %2
br label %25
12: ; preds = %2
%13 = load i32, i32* %4
%14 = icmp eq i32 %13, 2
br i1 %14, label %15, label %21
15: ; preds = %12
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
store i8* %18, i8** %6
%19 = load i8*, i8** %6
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* %19)
br label %24
21: ; preds = %12
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
%23 = call i32 (...) @abort()
unreachable
24: ; preds = %15
br label %25
25: ; preds = %24, %11
%26 = call i32 @WSQ_Init(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
%27 = call i32 @WSQ_SetQueryName(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%28 = call i32 (...) @WSQ_Pause()
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.5, i64 0, i64 0))
%30 = call i32 @WSQ_BeginTransaction(i32 1001)
%31 = call i32 @WSQ_BeginSubgraph(i32 101)
%32 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%33 = load i8*, i8** %6
%34 = call i32 @sprintf(i8* %32, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i8* %33)
%35 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%36 = call i32 @WSQ_AddOp(i32 1, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* %35)
%37 = call i32 @WSQ_AddOp(i32 2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.11, i64 0, i64 0))
%38 = call i32 (...) @WSQ_EndSubgraph()
%39 = call i32 (...) @WSQ_EndTransaction()
store i32 %39, i32* %8
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"TAQ.1000000\00"
@.str.1 = [35 x i8] c"Reading input tuples from file %s\0A\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [18 x i8] c"generated_query_1\00"
@.str.6 = [9 x i8] c"-1 || %s\00"
@.str.7 = [16 x i8] c"ASCIIFileSource\00"
@.str.8 = [4 x i8] c"100\00"
@.str.9 = [4 x i8] c"UDF\00"
@.str.10 = [4 x i8] c"200\00"
@.str.11 = [38 x i8] c"output_timer.ws | output_timer | 1.0 \00"
@str = [34 x i8] c"ERROR: wrong number of arguments!\00"
@str.12 = [50 x i8] c"PAUSED WSQ engine, run compiled query manually...\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1000 x i8]
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%5 = icmp slt i32 %0, 2
br i1 %5, label %15, label %6
6: ; preds = %2
%7 = icmp eq i32 %0, 2
br i1 %7, label %8, label %12
8: ; preds = %6
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* %10)
br label %15
12: ; preds = %6
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%14 = tail call i32 (...) @abort()
unreachable
15: ; preds = %2, %8
%16 = phi i8* [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), %2 ], [ %10, %8 ]
%17 = tail call i32 @WSQ_Init(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
%18 = tail call i32 @WSQ_SetQueryName(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%19 = tail call i32 (...) @WSQ_Pause()
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str.12, i64 0, i64 0))
%21 = tail call i32 @WSQ_BeginTransaction(i32 1001)
%22 = tail call i32 @WSQ_BeginSubgraph(i32 101)
%23 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i8* %16)
%24 = call i32 @WSQ_AddOp(i32 1, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* %4)
%25 = call i32 @WSQ_AddOp(i32 2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.11, i64 0, i64 0))
%26 = call i32 (...) @WSQ_EndSubgraph()
%27 = call i32 (...) @WSQ_EndTransaction()
ret i32 0
}