#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 scalar_t__ time_t;

/* 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_SetQueryName(char *);
int /*<<< orphan*/ WSQ_Shutdown();
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ time(int /*<<< orphan*/ *);
int /*<<< orphan*/ waitpid(int, int *, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  WSQ_Init("10_MergeTest.out");
  WSQ_SetQueryName("generated_query_10");
  WSQ_BeginTransaction(99);
  WSQ_BeginSubgraph(11);
  WSQ_AddOp(1, "ASCIIFileSource", "", "100", "-1 |foobar.schema|TAQ.100000");
  WSQ_AddOp(2, "ASCIIFileSource", "", "200", "-1 |foobar.schema|TAQ.100000");
  WSQ_AddOp(3, "MergeMonotonic", "100 200", "300", "TIMESTAMP");
  WSQ_AddOp(6, "Printer", "300", "", "Merged");
  WSQ_EndSubgraph();
  int pid = WSQ_EndTransaction();
  int status = 0;
  printf("\n ******* Waiting on PID %d...\n", pid);
  time_t start = time(NULL);
  waitpid(pid, &status, 0);
  time_t end = time(NULL);
  printf(
      "\n ******* PID %d terminated (after %ld seconds), now shutting down.\n",
      pid, (end - start));
  WSQ_Shutdown();
  printf("Shutdown apparently successful.\n");
  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)
lea    0xe33(%rip),%rdi
call   1060 <WSQ_Init@plt>
lea    0xe38(%rip),%rdi
call   1090 <WSQ_SetQueryName@plt>
mov    $0x63,%edi
call   1080 <WSQ_BeginTransaction@plt>
mov    $0xb,%edi
call   10c0 <WSQ_BeginSubgraph@plt>
mov    $0x1,%edi
lea    0xe26(%rip),%rsi
lea    0xea3(%rip),%rdx
lea    0xe28(%rip),%rcx
lea    0xe25(%rip),%r8
call   10a0 <WSQ_AddOp@plt>
mov    $0x2,%edi
lea    0xe00(%rip),%rsi
lea    0xe7d(%rip),%rdx
lea    0xe36(%rip),%rcx
lea    0xdff(%rip),%r8
call   10a0 <WSQ_AddOp@plt>
mov    $0x3,%edi
lea    0xe0b(%rip),%rsi
lea    0xe13(%rip),%rdx
lea    0xe14(%rip),%rcx
lea    0xe11(%rip),%r8
call   10a0 <WSQ_AddOp@plt>
mov    $0x6,%edi
lea    0xe0a(%rip),%rsi
lea    0xdf5(%rip),%rdx
lea    0xe2a(%rip),%rcx
lea    0xdfd(%rip),%r8
call   10a0 <WSQ_AddOp@plt>
mov    $0x0,%al
call   1050 <WSQ_EndSubgraph@plt>
mov    $0x0,%al
call   10d0 <WSQ_EndTransaction@plt>
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x14(%rbp),%esi
lea    0xddd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x18(%rbp),%rsi
xor    %edx,%edx
call   10b0 <waitpid@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x28(%rbp),%rdx
sub    -0x20(%rbp),%rdx
lea    0xdbc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <WSQ_Shutdown@plt>
lea    0xdec(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xe30(%rip),%rdi
call   1070 <WSQ_Init@plt>
lea    0xe35(%rip),%rdi
call   10a0 <WSQ_SetQueryName@plt>
mov    $0x63,%edi
call   1090 <WSQ_BeginTransaction@plt>
mov    $0xb,%edi
call   10d0 <WSQ_BeginSubgraph@plt>
lea    0xe28(%rip),%rbx
lea    0xea5(%rip),%r14
lea    0xe2a(%rip),%rcx
lea    0xe27(%rip),%r15
mov    $0x1,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %r15,%r8
call   10b0 <WSQ_AddOp@plt>
lea    0xe3d(%rip),%rcx
mov    $0x2,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %r15,%r8
call   10b0 <WSQ_AddOp@plt>
lea    0xe10(%rip),%rsi
lea    0xe18(%rip),%rdx
lea    0xe19(%rip),%rbx
lea    0xe16(%rip),%r8
mov    $0x3,%edi
mov    %rbx,%rcx
call   10b0 <WSQ_AddOp@plt>
lea    0xe0c(%rip),%rsi
lea    0xe0d(%rip),%r8
mov    $0x6,%edi
mov    %rbx,%rdx
mov    %r14,%rcx
call   10b0 <WSQ_AddOp@plt>
xor    %eax,%eax
call   1060 <WSQ_EndSubgraph@plt>
xor    %eax,%eax
call   10e0 <WSQ_EndTransaction@plt>
mov    %eax,%ebx
movl   $0x0,0xc(%rsp)
lea    0xde5(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %edi,%edi
call   1080 <time@plt>
mov    %rax,%r14
lea    0xc(%rsp),%rsi
mov    %ebx,%edi
xor    %edx,%edx
call   10c0 <waitpid@plt>
xor    %edi,%edi
call   1080 <time@plt>
sub    %r14,%rax
lea    0xdd3(%rip),%rdi
mov    %ebx,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <WSQ_Shutdown@plt>
lea    0xdfe(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [17 x i8] c"10_MergeTest.out\00"
@.str.1 = [19 x i8] c"generated_query_10\00"
@.str.2 = [16 x i8] c"ASCIIFileSource\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [4 x i8] c"100\00"
@.str.5 = [29 x i8] c"-1 |foobar.schema|TAQ.100000\00"
@.str.6 = [4 x i8] c"200\00"
@.str.7 = [15 x i8] c"MergeMonotonic\00"
@.str.8 = [8 x i8] c"100 200\00"
@.str.9 = [4 x i8] c"300\00"
@.str.10 = [10 x i8] c"TIMESTAMP\00"
@.str.11 = [8 x i8] c"Printer\00"
@.str.12 = [7 x i8] c"Merged\00"
@.str.13 = [32 x i8] c"\0A ******* Waiting on PID %d...\0A\00"
@.str.14 = [69 x i8] c"\0A ******* PID %d terminated (after %ld seconds), now shutting down.\0A\00"
@.str.15 = [33 x i8] c"Shutdown apparently successful.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i64
%9 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32 @WSQ_Init(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @WSQ_SetQueryName(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @WSQ_BeginTransaction(i32 99)
%13 = call i32 @WSQ_BeginSubgraph(i32 11)
%14 = call i32 @WSQ_AddOp(i32 1, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, 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.4, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
%15 = call i32 @WSQ_AddOp(i32 2, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, 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.6, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
%16 = call i32 @WSQ_AddOp(i32 3, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0))
%17 = call i32 @WSQ_AddOp(i32 6, 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.9, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0))
%18 = call i32 (...) @WSQ_EndSubgraph()
%19 = call i32 (...) @WSQ_EndTransaction()
store i32 %19, i32* %6
store i32 0, i32* %7
%20 = load i32, i32* %6
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.13, i64 0, i64 0), i32 %20)
%22 = call i64 @time(i32* null)
store i64 %22, i64* %8
%23 = load i32, i32* %6
%24 = call i32 @waitpid(i32 %23, i32* %7, i32 0)
%25 = call i64 @time(i32* null)
store i64 %25, i64* %9
%26 = load i32, i32* %6
%27 = load i64, i64* %9
%28 = load i64, i64* %8
%29 = sub nsw i64 %27, %28
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.14, i64 0, i64 0), i32 %26, i64 %29)
%31 = call i32 (...) @WSQ_Shutdown()
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.15, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"10_MergeTest.out\00"
@.str.1 = [19 x i8] c"generated_query_10\00"
@.str.2 = [16 x i8] c"ASCIIFileSource\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [4 x i8] c"100\00"
@.str.5 = [29 x i8] c"-1 |foobar.schema|TAQ.100000\00"
@.str.6 = [4 x i8] c"200\00"
@.str.7 = [15 x i8] c"MergeMonotonic\00"
@.str.8 = [8 x i8] c"100 200\00"
@.str.9 = [4 x i8] c"300\00"
@.str.10 = [10 x i8] c"TIMESTAMP\00"
@.str.11 = [8 x i8] c"Printer\00"
@.str.12 = [7 x i8] c"Merged\00"
@.str.13 = [32 x i8] c"\0A ******* Waiting on PID %d...\0A\00"
@.str.14 = [69 x i8] c"\0A ******* PID %d terminated (after %ld seconds), now shutting down.\0A\00"
@str = [32 x i8] c"Shutdown apparently successful.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = tail call i32 @WSQ_Init(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @WSQ_SetQueryName(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 @WSQ_BeginTransaction(i32 99)
%7 = tail call i32 @WSQ_BeginSubgraph(i32 11)
%8 = tail call i32 @WSQ_AddOp(i32 1, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, 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.4, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
%9 = tail call i32 @WSQ_AddOp(i32 2, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, 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.6, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
%10 = tail call i32 @WSQ_AddOp(i32 3, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0))
%11 = tail call i32 @WSQ_AddOp(i32 6, 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.9, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0))
%12 = tail call i32 (...) @WSQ_EndSubgraph()
%13 = tail call i32 (...) @WSQ_EndTransaction()
%14 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.13, i64 0, i64 0), i32 %13)
%16 = tail call i64 @time(i32* null)
%17 = call i32 @waitpid(i32 %13, i32* %3, i32 0)
%18 = call i64 @time(i32* null)
%19 = sub nsw i64 %18, %16
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @.str.14, i64 0, i64 0), i32 %13, i64 %19)
%21 = call i32 (...) @WSQ_Shutdown()
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
ret i32 0
}