#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*/ WSQ_Shutdown();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ system(char *);
int main(int argc, char *argv[]) {
  printf("Proc2 starting.\n");
  char strargs[2048];
  sprintf(strargs,
          "localhost | %d | string SYM, float TIME, float PRICE, int VOLUME",
          5002);
  WSQ_Init("");
  WSQ_SetQueryName("proc2query");
  WSQ_Pause();
  printf("PAUSING WSQ engine, run compiled query manually...\n");
  WSQ_BeginTransaction(1001);
  WSQ_BeginSubgraph(101);
  WSQ_AddOp(100, "RandomSource", "", "100", "1000 |foobar.schema");
  WSQ_AddOp(101, "ConnectRemoteIn", "", "101", strargs);
  WSQ_AddOp(102, "MergeMonotonic", "100 101", "102", "TIME");
  WSQ_AddOp(103, "Printer", "102", "", "NETSTRM: ");
  WSQ_EndSubgraph();
  int pid = WSQ_EndTransaction();
  if (pid == 0) {
    printf("pid is 000000000000\n");
    char cmd[128] =
        "WSQ_OPTLVL=3 WSQ_MAXSPEED=1 WSQ_VERBOSE=3 ./proc2query.exe";
    system(cmd);
  }
  WSQ_Shutdown();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x8a0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe10(%rip),%rdi
call   1050 <printf@plt>
lea    -0x810(%rbp),%rdi
lea    0xe0e(%rip),%rsi
mov    $0x138a,%edx
call   10e0 <sprintf@plt>
lea    0xe7c(%rip),%rdi
call   1070 <WSQ_Init@plt>
lea    0xe32(%rip),%rdi
call   10a0 <WSQ_SetQueryName@plt>
mov    $0x0,%al
call   10f0 <WSQ_Pause@plt>
lea    0xe2a(%rip),%rdi
call   1050 <printf@plt>
mov    $0x3e9,%edi
call   1090 <WSQ_BeginTransaction@plt>
mov    $0x65,%edi
call   10c0 <WSQ_BeginSubgraph@plt>
mov    $0x64,%edi
lea    0xe39(%rip),%rsi
lea    0xe31(%rip),%rdx
lea    0xe38(%rip),%rcx
lea    0xe35(%rip),%r8
call   10b0 <WSQ_AddOp@plt>
lea    -0x810(%rbp),%r8
mov    $0x65,%edi
lea    0xe31(%rip),%rsi
lea    0xe04(%rip),%rdx
lea    0xe46(%rip),%rcx
call   10b0 <WSQ_AddOp@plt>
mov    $0x66,%edi
lea    0xe22(%rip),%rsi
lea    0xe2a(%rip),%rdx
lea    0xe2b(%rip),%rcx
lea    0xe28(%rip),%r8
call   10b0 <WSQ_AddOp@plt>
mov    $0x67,%edi
lea    0xe1c(%rip),%rsi
lea    0xe0c(%rip),%rdx
lea    0xdb8(%rip),%rcx
lea    0xe0f(%rip),%r8
call   10b0 <WSQ_AddOp@plt>
mov    $0x0,%al
call   1060 <WSQ_EndSubgraph@plt>
mov    $0x0,%al
call   10d0 <WSQ_EndTransaction@plt>
mov    %eax,-0x814(%rbp)
cmpl   $0x0,-0x814(%rbp)
jne    1335 <main+0x165>
lea    0xdec(%rip),%rdi
call   1050 <printf@plt>
lea    -0x8a0(%rbp),%rdi
lea    0xdf1(%rip),%rsi
mov    $0x80,%edx
call   1080 <memcpy@plt>
lea    -0x8a0(%rbp),%rdi
call   1040 <system@plt>
mov    $0x0,%al
call   1030 <WSQ_Shutdown@plt>
xor    %eax,%eax
add    $0x8a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x880,%rsp
lea    0xee0(%rip),%rdi
call   1030 <puts@plt>
lea    0xe21(%rip),%rsi
lea    0x80(%rsp),%r14
mov    %r14,%rdi
mov    $0x138a,%edx
call   10d0 <sprintf@plt>
lea    0xeb7(%rip),%r15
mov    %r15,%rdi
call   1070 <WSQ_Init@plt>
lea    0xe37(%rip),%rdi
call   1090 <WSQ_SetQueryName@plt>
xor    %eax,%eax
call   10e0 <WSQ_Pause@plt>
lea    0xea6(%rip),%rdi
call   1030 <puts@plt>
mov    $0x3e9,%edi
call   1080 <WSQ_BeginTransaction@plt>
mov    $0x65,%edi
call   10b0 <WSQ_BeginSubgraph@plt>
lea    0xe0f(%rip),%rsi
lea    0xe15(%rip),%rcx
lea    0xe12(%rip),%r8
mov    $0x64,%edi
mov    %r15,%rdx
call   10a0 <WSQ_AddOp@plt>
lea    0xe12(%rip),%rsi
lea    0xe2e(%rip),%rcx
mov    $0x65,%edi
mov    %r15,%rdx
mov    %r14,%r8
call   10a0 <WSQ_AddOp@plt>
lea    0xe04(%rip),%rsi
lea    0xe0c(%rip),%rdx
lea    0xe0d(%rip),%rbx
lea    0xe0a(%rip),%r8
mov    $0x66,%edi
mov    %rbx,%rcx
call   10a0 <WSQ_AddOp@plt>
lea    0xdfb(%rip),%rsi
lea    0xdfc(%rip),%r8
mov    $0x67,%edi
mov    %rbx,%rdx
mov    %r15,%rcx
call   10a0 <WSQ_AddOp@plt>
xor    %eax,%eax
call   1060 <WSQ_EndSubgraph@plt>
xor    %eax,%eax
call   10c0 <WSQ_EndTransaction@plt>
test   %eax,%eax
jne    1342 <main+0x182>
lea    0xe20(%rip),%rdi
call   1030 <puts@plt>
movaps 0xe9e(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xe82(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xe66(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xe4a(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xe2e(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xe12(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xdf6(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xdda(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
call   1050 <system@plt>
xor    %eax,%eax
call   1040 <WSQ_Shutdown@plt>
xor    %eax,%eax
add    $0x880,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [17 x i8] c"Proc2 starting.\0A\00"
@.str.1 = [65 x i8] c"localhost | %d | string SYM, float TIME, float PRICE, int VOLUME\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [11 x i8] c"proc2query\00"
@.str.4 = [52 x i8] c"PAUSING WSQ engine, run compiled query manually...\0A\00"
@.str.5 = [13 x i8] c"RandomSource\00"
@.str.6 = [4 x i8] c"100\00"
@.str.7 = [20 x i8] c"1000 |foobar.schema\00"
@.str.8 = [16 x i8] c"ConnectRemoteIn\00"
@.str.9 = [4 x i8] c"101\00"
@.str.10 = [15 x i8] c"MergeMonotonic\00"
@.str.11 = [8 x i8] c"100 101\00"
@.str.12 = [4 x i8] c"102\00"
@.str.13 = [5 x i8] c"TIME\00"
@.str.14 = [8 x i8] c"Printer\00"
@.str.15 = [10 x i8] c"NETSTRM: \00"
@.str.16 = [21 x i8] c"pid is 000000000000\0A\00"
@__const.main.cmd = [128 x i8] c"WSQ_OPTLVL=3 WSQ_MAXSPEED=1 WSQ_VERBOSE=3 ./proc2query.exe\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [2048 x i8]
%7 = alloca i32
%8 = alloca [128 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%11 = call i32 @sprintf(i8* %10, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.1, i64 0, i64 0), i32 5002)
%12 = call i32 @WSQ_Init(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @WSQ_SetQueryName(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 (...) @WSQ_Pause()
%15 = call i32 @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.4, i64 0, i64 0))
%16 = call i32 @WSQ_BeginTransaction(i32 1001)
%17 = call i32 @WSQ_BeginSubgraph(i32 101)
%18 = call i32 @WSQ_AddOp(i32 100, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
%19 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%20 = call i32 @WSQ_AddOp(i32 101, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* %19)
%21 = call i32 @WSQ_AddOp(i32 102, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0))
%22 = call i32 @WSQ_AddOp(i32 103, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i64 0, i64 0))
%23 = call i32 (...) @WSQ_EndSubgraph()
%24 = call i32 (...) @WSQ_EndTransaction()
store i32 %24, i32* %7
%25 = load i32, i32* %7
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %32
27: ; preds = %2
%28 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.16, i64 0, i64 0))
%29 = bitcast [128 x i8]* %8 to i8*
%30 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%31 = call i32 @system(i8* %30)
br label %32
32: ; preds = %27, %2
%33 = call i32 (...) @WSQ_Shutdown()
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [65 x i8] c"localhost | %d | string SYM, float TIME, float PRICE, int VOLUME\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [11 x i8] c"proc2query\00"
@.str.5 = [13 x i8] c"RandomSource\00"
@.str.6 = [4 x i8] c"100\00"
@.str.7 = [20 x i8] c"1000 |foobar.schema\00"
@.str.8 = [16 x i8] c"ConnectRemoteIn\00"
@.str.9 = [4 x i8] c"101\00"
@.str.10 = [15 x i8] c"MergeMonotonic\00"
@.str.11 = [8 x i8] c"100 101\00"
@.str.12 = [4 x i8] c"102\00"
@.str.13 = [5 x i8] c"TIME\00"
@.str.14 = [8 x i8] c"Printer\00"
@.str.15 = [10 x i8] c"NETSTRM: \00"
@__const.main.cmd = [128 x i8] c"WSQ_OPTLVL=3 WSQ_MAXSPEED=1 WSQ_VERBOSE=3 ./proc2query.exe\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@str = [16 x i8] c"Proc2 starting.\00"
@str.17 = [51 x i8] c"PAUSING WSQ engine, run compiled query manually...\00"
@str.18 = [20 x i8] c"pid is 000000000000\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [2048 x i8]
%4 = alloca [128 x i8]
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%6 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 0
%7 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @.str.1, i64 0, i64 0), i32 5002)
%8 = tail call i32 @WSQ_Init(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%9 = tail call i32 @WSQ_SetQueryName(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%10 = tail call i32 (...) @WSQ_Pause()
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str.17, i64 0, i64 0))
%12 = tail call i32 @WSQ_BeginTransaction(i32 1001)
%13 = tail call i32 @WSQ_BeginSubgraph(i32 101)
%14 = tail call i32 @WSQ_AddOp(i32 100, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
%15 = call i32 @WSQ_AddOp(i32 101, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* %6)
%16 = call i32 @WSQ_AddOp(i32 102, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0))
%17 = call i32 @WSQ_AddOp(i32 103, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i64 0, i64 0))
%18 = call i32 (...) @WSQ_EndSubgraph()
%19 = call i32 (...) @WSQ_EndTransaction()
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %2
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.18, i64 0, i64 0))
%23 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%24 = call i32 @system(i8* %23)
br label %25
25: ; preds = %21, %2
%26 = call i32 (...) @WSQ_Shutdown()
ret i32 0
}