#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 /*<<< orphan*/ WSQ_EndTransaction();
int /*<<< orphan*/ WSQ_Init(char *);
int /*<<< orphan*/ WSQ_Pause();
int /*<<< orphan*/ WSQ_SetQueryName(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, int);
int main(int argc, char *argv[]) {
  char strargs[2048];
  char *machine = "localhost";
  sprintf(
      strargs,
      "%s | %d | bigint TIMESTAMP, string SYMBOL, bigint EXCHTIMESTAMP, bigint "
      "RECEIVEDTIME, double BID, double BIDSIZE, double ASK, double ASKSIZE ",
      machine, 5002);
  WSQ_Init("");
  WSQ_SetQueryName("generated_query_2B");
  WSQ_Pause();
  printf("PAUSING WSQ engine, run compiled query manually...\n");
  WSQ_BeginTransaction(1001);
  WSQ_BeginSubgraph(101);
  WSQ_AddOp(20, "ConnectRemoteIn", "", "100", strargs);
  WSQ_AddOp(2, "UDF", "100", "200", "output_timer.ws | output_timer | 1.0 ");
  WSQ_AddOp(3, "Printer", "200", "", " Should never see this.. ");
  WSQ_EndSubgraph();
  WSQ_EndTransaction();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe40(%rip),%rax
mov    %rax,-0x818(%rbp)
lea    -0x810(%rbp),%rdi
mov    -0x818(%rbp),%rdx
lea    0xe2e(%rip),%rsi
mov    $0x138a,%ecx
call   10b0 <sprintf@plt>
lea    0xef1(%rip),%rdi
call   1050 <WSQ_Init@plt>
lea    0xe9f(%rip),%rdi
call   1070 <WSQ_SetQueryName@plt>
mov    $0x0,%al
call   10c0 <WSQ_Pause@plt>
lea    0xe9f(%rip),%rdi
call   1030 <printf@plt>
mov    $0x3e9,%edi
call   1060 <WSQ_BeginTransaction@plt>
mov    $0x65,%edi
call   1090 <WSQ_BeginSubgraph@plt>
lea    -0x810(%rbp),%r8
mov    $0x14,%edi
lea    0xea7(%rip),%rsi
lea    0xe9f(%rip),%rdx
lea    0xea9(%rip),%rcx
call   1080 <WSQ_AddOp@plt>
mov    $0x2,%edi
lea    0xe9c(%rip),%rsi
lea    0xe91(%rip),%rdx
lea    0xe92(%rip),%rcx
lea    0xe8f(%rip),%r8
call   1080 <WSQ_AddOp@plt>
mov    $0x3,%edi
lea    0xea4(%rip),%rsi
lea    0xe73(%rip),%rdx
lea    0xe53(%rip),%rcx
lea    0xe97(%rip),%r8
call   1080 <WSQ_AddOp@plt>
mov    $0x0,%al
call   1040 <WSQ_EndSubgraph@plt>
mov    $0x0,%al
call   10a0 <WSQ_EndTransaction@plt>
xor    %eax,%eax
add    $0x820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x800,%rsp
lea    0xe57(%rip),%rsi
lea    0xe46(%rip),%rdx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x138a,%ecx
call   10b0 <sprintf@plt>
lea    0xf3d(%rip),%r15
mov    %r15,%rdi
call   1050 <WSQ_Init@plt>
lea    0xeb8(%rip),%rdi
call   1070 <WSQ_SetQueryName@plt>
xor    %eax,%eax
call   10c0 <WSQ_Pause@plt>
lea    0xf1c(%rip),%rdi
call   1030 <puts@plt>
mov    $0x3e9,%edi
call   1060 <WSQ_BeginTransaction@plt>
mov    $0x65,%edi
call   1090 <WSQ_BeginSubgraph@plt>
lea    0xe98(%rip),%rsi
lea    0xea1(%rip),%rbx
mov    $0x14,%edi
mov    %r15,%rdx
mov    %rbx,%rcx
mov    %r14,%r8
call   1080 <WSQ_AddOp@plt>
lea    0xe8b(%rip),%rsi
lea    0xe88(%rip),%r14
lea    0xe85(%rip),%r8
mov    $0x2,%edi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1080 <WSQ_AddOp@plt>
lea    0xe94(%rip),%rsi
lea    0xe95(%rip),%r8
mov    $0x3,%edi
mov    %r14,%rdx
mov    %r15,%rcx
call   1080 <WSQ_AddOp@plt>
xor    %eax,%eax
call   1040 <WSQ_EndSubgraph@plt>
xor    %eax,%eax
call   10a0 <WSQ_EndTransaction@plt>
xor    %eax,%eax
add    $0x800,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [10 x i8] c"localhost\00"
@.str.1 = [142 x i8] c"%s | %d | bigint TIMESTAMP, string SYMBOL, bigint EXCHTIMESTAMP, bigint RECEIVEDTIME, double BID, double BIDSIZE, double ASK, double ASKSIZE \00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [19 x i8] c"generated_query_2B\00"
@.str.4 = [52 x i8] c"PAUSING WSQ engine, run compiled query manually...\0A\00"
@.str.5 = [16 x i8] c"ConnectRemoteIn\00"
@.str.6 = [4 x i8] c"100\00"
@.str.7 = [4 x i8] c"UDF\00"
@.str.8 = [4 x i8] c"200\00"
@.str.9 = [38 x i8] c"output_timer.ws | output_timer | 1.0 \00"
@.str.10 = [8 x i8] c"Printer\00"
@.str.11 = [26 x i8] c" Should never see this.. \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [2048 x i8]
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %7
%8 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%9 = load i8*, i8** %7
%10 = call i32 @sprintf(i8* %8, i8* getelementptr inbounds ([142 x i8], [142 x i8]* @.str.1, i64 0, i64 0), i8* %9, i32 5002)
%11 = call i32 @WSQ_Init(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @WSQ_SetQueryName(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 (...) @WSQ_Pause()
%14 = call i32 @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.4, i64 0, i64 0))
%15 = call i32 @WSQ_BeginTransaction(i32 1001)
%16 = call i32 @WSQ_BeginSubgraph(i32 101)
%17 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%18 = call i32 @WSQ_AddOp(i32 20, i8* getelementptr inbounds ([16 x i8], [16 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* %17)
%19 = call i32 @WSQ_AddOp(i32 2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.9, i64 0, i64 0))
%20 = call i32 @WSQ_AddOp(i32 3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 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 ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0))
%21 = call i32 (...) @WSQ_EndSubgraph()
%22 = call i32 (...) @WSQ_EndTransaction()
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"localhost\00"
@.str.1 = [142 x i8] c"%s | %d | bigint TIMESTAMP, string SYMBOL, bigint EXCHTIMESTAMP, bigint RECEIVEDTIME, double BID, double BIDSIZE, double ASK, double ASKSIZE \00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [19 x i8] c"generated_query_2B\00"
@.str.5 = [16 x i8] c"ConnectRemoteIn\00"
@.str.6 = [4 x i8] c"100\00"
@.str.7 = [4 x i8] c"UDF\00"
@.str.8 = [4 x i8] c"200\00"
@.str.9 = [38 x i8] c"output_timer.ws | output_timer | 1.0 \00"
@.str.10 = [8 x i8] c"Printer\00"
@.str.11 = [26 x i8] c" Should never see this.. \00"
@str = [51 x i8] c"PAUSING WSQ engine, run compiled query manually...\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [2048 x i8]
%4 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 0
%5 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([142 x i8], [142 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 5002)
%6 = tail call i32 @WSQ_Init(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%7 = tail call i32 @WSQ_SetQueryName(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%8 = tail call i32 (...) @WSQ_Pause()
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str, i64 0, i64 0))
%10 = tail call i32 @WSQ_BeginTransaction(i32 1001)
%11 = tail call i32 @WSQ_BeginSubgraph(i32 101)
%12 = call i32 @WSQ_AddOp(i32 20, i8* getelementptr inbounds ([16 x i8], [16 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* %4)
%13 = call i32 @WSQ_AddOp(i32 2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.9, i64 0, i64 0))
%14 = call i32 @WSQ_AddOp(i32 3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 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 ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0))
%15 = call i32 (...) @WSQ_EndSubgraph()
%16 = call i32 (...) @WSQ_EndTransaction()
ret i32 0
}