#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 int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ jv_test();
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ run_jq_tests(int /*<<< orphan*/ *);
int /*<<< orphan*/ *stdin;
int jq_testsuite(int argc, char *argv[]) {
  FILE *testdata = stdin;
  jv_test();
  if (argc > 2) {
    testdata = fopen(argv[2], "r");
    if (!testdata) {
      perror("fopen");
      exit(1);
    }
  }
  run_jq_tests(testdata);
  return 0;
}


x86 assembly (clang, -O0):
<jq_testsuite>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e82(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1030 <jv_test@plt>
cmpl   $0x2,-0x4(%rbp)
jle    11bc <jq_testsuite+0x6c>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe73(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11b7 <jq_testsuite+0x67>
lea    0xe5a(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
jmp    11bc <jq_testsuite+0x6c>
mov    -0x18(%rbp),%rdi
call   1040 <run_jq_tests@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<jq_testsuite>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebp
mov    0x2e88(%rip),%rax
mov    (%rax),%rbx
xor    %eax,%eax
call   1030 <jv_test@plt>
cmp    $0x3,%ebp
jl     1187 <jq_testsuite+0x37>
mov    0x10(%r14),%rdi
lea    0xe86(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1196 <jq_testsuite+0x46>
mov    %rbx,%rdi
call   1040 <run_jq_tests@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe65(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stdin = global i32* null
@.str = [2 x i8] c"r\00"
@.str.1 = [6 x i8] c"fopen\00"
define i32 @jq_testsuite(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32*
store i32 %0, i32* %3
store i8** %1, i8*** %4
%6 = load i32*, i32** @stdin
store i32* %6, i32** %5
%7 = call i32 (...) @jv_test()
%8 = load i32, i32* %3
%9 = icmp sgt i32 %8, 2
br i1 %9, label %10, label %21
10: ; preds = %2
%11 = load i8**, i8*** %4
%12 = getelementptr inbounds i8*, i8** %11, i64 2
%13 = load i8*, i8** %12
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %14, i32** %5
%15 = load i32*, i32** %5
%16 = icmp ne i32* %15, null
br i1 %16, label %20, label %17
17: ; preds = %10
%18 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %10
br label %21
21: ; preds = %20, %2
%22 = load i32*, i32** %5
%23 = call i32 @run_jq_tests(i32* %22)
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32* null
@.str = [2 x i8] c"r\00"
@.str.1 = [6 x i8] c"fopen\00"
define i32 @jq_testsuite(i32 %0, i8** nocapture %1) {
%3 = load i32*, i32** @stdin
%4 = tail call i32 (...) @jv_test()
%5 = icmp sgt i32 %0, 2
br i1 %5, label %6, label %14
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 2
%8 = load i8*, i8** %7
%9 = tail call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %6, %2
%15 = phi i32* [ %9, %6 ], [ %3, %2 ]
%16 = tail call i32 @run_jq_tests(i32* %15)
ret i32 0
}