#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*/ do_crash_test(char const *, int *);
int /*<<< orphan*/ do_writer_crash_test(char const *, int *);
scalar_t__ tdb_system_name(int);
int /*<<< orphan*/ testPrintError(char *);
int /*<<< orphan*/ test_api(char const *, int *);
int /*<<< orphan*/ test_data_1(scalar_t__, char const *, int *);
int /*<<< orphan*/ test_data_2(scalar_t__, char const *, int *);
int /*<<< orphan*/ test_data_3(scalar_t__, char const *, int *);
int /*<<< orphan*/ test_data_4(scalar_t__, char const *, int *);
int /*<<< orphan*/ test_mc(scalar_t__, char const *, int *);
int /*<<< orphan*/ test_mt(scalar_t__, char const *, int *);
int /*<<< orphan*/ test_oom(char const *, int *);
int /*<<< orphan*/ test_rollback(scalar_t__, char const *, int *);
int do_test(int nArg, char **azArg) {
  int j;
  int rc;
  int nFail = 0;
  const char *zPattern = 0;
  if (nArg > 1) {
    testPrintError("Usage: test ?PATTERN?\n");
    return 1;
  }
  if (nArg == 1) {
    zPattern = azArg[0];
  }
  for (j = 0; tdb_system_name(j); j++) {
    rc = 0;
    test_data_1(tdb_system_name(j), zPattern, &rc);
    test_data_2(tdb_system_name(j), zPattern, &rc);
    test_data_3(tdb_system_name(j), zPattern, &rc);
    test_data_4(tdb_system_name(j), zPattern, &rc);
    test_rollback(tdb_system_name(j), zPattern, &rc);
    test_mc(tdb_system_name(j), zPattern, &rc);
    test_mt(tdb_system_name(j), zPattern, &rc);
    if (rc)
      nFail++;
  }
  rc = 0;
  test_oom(zPattern, &rc);
  if (rc)
    nFail++;
  rc = 0;
  test_api(zPattern, &rc);
  if (rc)
    nFail++;
  rc = 0;
  do_crash_test(zPattern, &rc);
  if (rc)
    nFail++;
  rc = 0;
  do_writer_crash_test(zPattern, &rc);
  if (rc)
    nFail++;
  return (nFail != 0);
}


x86 assembly (clang, -O0):
<do_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1210 <do_test+0x40>
lea    0xe01(%rip),%rdi
call   1080 <testPrintError@plt>
movl   $0x1,-0x4(%rbp)
jmp    13be <do_test+0x1ee>
cmpl   $0x1,-0x8(%rbp)
jne    1225 <do_test+0x55>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   10d0 <tdb_system_name@plt>
cmp    $0x0,%rax
je     1313 <do_test+0x143>
movl   $0x0,-0x18(%rbp)
mov    -0x14(%rbp),%edi
call   10d0 <tdb_system_name@plt>
mov    %rax,%rdi
mov    -0x28(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   10e0 <test_data_1@plt>
mov    -0x14(%rbp),%edi
call   10d0 <tdb_system_name@plt>
mov    %rax,%rdi
mov    -0x28(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   10b0 <test_data_2@plt>
mov    -0x14(%rbp),%edi
call   10d0 <tdb_system_name@plt>
mov    %rax,%rdi
mov    -0x28(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   10c0 <test_data_3@plt>
mov    -0x14(%rbp),%edi
call   10d0 <tdb_system_name@plt>
mov    %rax,%rdi
mov    -0x28(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1070 <test_data_4@plt>
mov    -0x14(%rbp),%edi
call   10d0 <tdb_system_name@plt>
mov    %rax,%rdi
mov    -0x28(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1060 <test_rollback@plt>
mov    -0x14(%rbp),%edi
call   10d0 <tdb_system_name@plt>
mov    %rax,%rdi
mov    -0x28(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1090 <test_mc@plt>
mov    -0x14(%rbp),%edi
call   10d0 <tdb_system_name@plt>
mov    %rax,%rdi
mov    -0x28(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   10f0 <test_mt@plt>
cmpl   $0x0,-0x18(%rbp)
je     1300 <do_test+0x130>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1305 <do_test+0x135>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    122c <do_test+0x5c>
movl   $0x0,-0x18(%rbp)
mov    -0x28(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <test_oom@plt>
cmpl   $0x0,-0x18(%rbp)
je     133a <do_test+0x16a>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x28(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   10a0 <test_api@plt>
cmpl   $0x0,-0x18(%rbp)
je     1361 <do_test+0x191>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x28(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <do_crash_test@plt>
cmpl   $0x0,-0x18(%rbp)
je     1388 <do_test+0x1b8>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x28(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <do_writer_crash_test@plt>
cmpl   $0x0,-0x18(%rbp)
je     13af <do_test+0x1df>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_test>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x2,%edi
jl     11f2 <do_test+0x22>
lea    0xe1d(%rip),%rdi
call   1080 <testPrintError@plt>
mov    $0x1,%eax
jmp    1353 <do_test+0x183>
xor    %r15d,%r15d
cmp    $0x1,%edi
jne    11ff <do_test+0x2f>
mov    (%rsi),%rbx
jmp    1201 <do_test+0x31>
xor    %ebx,%ebx
xor    %edi,%edi
call   10d0 <tdb_system_name@plt>
test   %rax,%rax
je     12d7 <do_test+0x107>
xor    %r15d,%r15d
lea    0x4(%rsp),%r14
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
movl   $0x0,0x4(%rsp)
mov    %ebp,%edi
call   10d0 <tdb_system_name@plt>
mov    %rax,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   10e0 <test_data_1@plt>
mov    %ebp,%edi
call   10d0 <tdb_system_name@plt>
mov    %rax,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   10b0 <test_data_2@plt>
mov    %ebp,%edi
call   10d0 <tdb_system_name@plt>
mov    %rax,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   10c0 <test_data_3@plt>
mov    %ebp,%edi
call   10d0 <tdb_system_name@plt>
mov    %rax,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1070 <test_data_4@plt>
mov    %ebp,%edi
call   10d0 <tdb_system_name@plt>
mov    %rax,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1060 <test_rollback@plt>
mov    %ebp,%edi
call   10d0 <tdb_system_name@plt>
mov    %rax,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1090 <test_mc@plt>
mov    %ebp,%edi
call   10d0 <tdb_system_name@plt>
mov    %rax,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   10f0 <test_mt@plt>
cmpl   $0x1,0x4(%rsp)
sbb    $0xffffffff,%r15d
add    $0x1,%ebp
mov    %ebp,%edi
call   10d0 <tdb_system_name@plt>
test   %rax,%rax
jne    1220 <do_test+0x50>
movl   $0x0,0x4(%rsp)
lea    0x4(%rsp),%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1030 <test_oom@plt>
cmpl   $0x1,0x4(%rsp)
sbb    $0xffffffff,%r15d
movl   $0x0,0x4(%rsp)
mov    %rbx,%rdi
mov    %rbp,%rsi
call   10a0 <test_api@plt>
cmpl   $0x1,0x4(%rsp)
sbb    $0xffffffff,%r15d
movl   $0x0,0x4(%rsp)
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1050 <do_crash_test@plt>
cmpl   $0x1,0x4(%rsp)
sbb    $0xffffffff,%r15d
movl   $0x0,0x4(%rsp)
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1040 <do_writer_crash_test@plt>
xor    %eax,%eax
cmp    0x4(%rsp),%eax
sbb    %ecx,%ecx
xor    %eax,%eax
cmp    %ecx,%r15d
setne  %al
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Usage: test ?PATTERN?\0A\00"
define i32 @do_test(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
store i8* null, i8** %9
%10 = load i32, i32* %4
%11 = icmp sgt i32 %10, 1
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 @testPrintError(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %100
14: ; preds = %2
%15 = load i32, i32* %4
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %21
17: ; preds = %14
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
store i8* %20, i8** %9
br label %21
21: ; preds = %17, %14
store i32 0, i32* %6
br label %22
22: ; preds = %61, %21
%23 = load i32, i32* %6
%24 = call i64 @tdb_system_name(i32 %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %64
26: ; preds = %22
store i32 0, i32* %7
%27 = load i32, i32* %6
%28 = call i64 @tdb_system_name(i32 %27)
%29 = load i8*, i8** %9
%30 = call i32 @test_data_1(i64 %28, i8* %29, i32* %7)
%31 = load i32, i32* %6
%32 = call i64 @tdb_system_name(i32 %31)
%33 = load i8*, i8** %9
%34 = call i32 @test_data_2(i64 %32, i8* %33, i32* %7)
%35 = load i32, i32* %6
%36 = call i64 @tdb_system_name(i32 %35)
%37 = load i8*, i8** %9
%38 = call i32 @test_data_3(i64 %36, i8* %37, i32* %7)
%39 = load i32, i32* %6
%40 = call i64 @tdb_system_name(i32 %39)
%41 = load i8*, i8** %9
%42 = call i32 @test_data_4(i64 %40, i8* %41, i32* %7)
%43 = load i32, i32* %6
%44 = call i64 @tdb_system_name(i32 %43)
%45 = load i8*, i8** %9
%46 = call i32 @test_rollback(i64 %44, i8* %45, i32* %7)
%47 = load i32, i32* %6
%48 = call i64 @tdb_system_name(i32 %47)
%49 = load i8*, i8** %9
%50 = call i32 @test_mc(i64 %48, i8* %49, i32* %7)
%51 = load i32, i32* %6
%52 = call i64 @tdb_system_name(i32 %51)
%53 = load i8*, i8** %9
%54 = call i32 @test_mt(i64 %52, i8* %53, i32* %7)
%55 = load i32, i32* %7
%56 = icmp ne i32 %55, 0
br i1 %56, label %57, label %60
57: ; preds = %26
%58 = load i32, i32* %8
%59 = add nsw i32 %58, 1
store i32 %59, i32* %8
br label %60
60: ; preds = %57, %26
br label %61
61: ; preds = %60
%62 = load i32, i32* %6
%63 = add nsw i32 %62, 1
store i32 %63, i32* %6
br label %22
64: ; preds = %22
store i32 0, i32* %7
%65 = load i8*, i8** %9
%66 = call i32 @test_oom(i8* %65, i32* %7)
%67 = load i32, i32* %7
%68 = icmp ne i32 %67, 0
br i1 %68, label %69, label %72
69: ; preds = %64
%70 = load i32, i32* %8
%71 = add nsw i32 %70, 1
store i32 %71, i32* %8
br label %72
72: ; preds = %69, %64
store i32 0, i32* %7
%73 = load i8*, i8** %9
%74 = call i32 @test_api(i8* %73, i32* %7)
%75 = load i32, i32* %7
%76 = icmp ne i32 %75, 0
br i1 %76, label %77, label %80
77: ; preds = %72
%78 = load i32, i32* %8
%79 = add nsw i32 %78, 1
store i32 %79, i32* %8
br label %80
80: ; preds = %77, %72
store i32 0, i32* %7
%81 = load i8*, i8** %9
%82 = call i32 @do_crash_test(i8* %81, i32* %7)
%83 = load i32, i32* %7
%84 = icmp ne i32 %83, 0
br i1 %84, label %85, label %88
85: ; preds = %80
%86 = load i32, i32* %8
%87 = add nsw i32 %86, 1
store i32 %87, i32* %8
br label %88
88: ; preds = %85, %80
store i32 0, i32* %7
%89 = load i8*, i8** %9
%90 = call i32 @do_writer_crash_test(i8* %89, i32* %7)
%91 = load i32, i32* %7
%92 = icmp ne i32 %91, 0
br i1 %92, label %93, label %96
93: ; preds = %88
%94 = load i32, i32* %8
%95 = add nsw i32 %94, 1
store i32 %95, i32* %8
br label %96
96: ; preds = %93, %88
%97 = load i32, i32* %8
%98 = icmp ne i32 %97, 0
%99 = zext i1 %98 to i32
store i32 %99, i32* %3
br label %100
100: ; preds = %96, %12
%101 = load i32, i32* %3
ret i32 %101
}

LLVM IR (-O2):
@.str = [23 x i8] c"Usage: test ?PATTERN?\0A\00"
define i32 @do_test(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @testPrintError(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %63
8: ; preds = %2
%9 = icmp eq i32 %0, 1
br i1 %9, label %10, label %12
10: ; preds = %8
%11 = load i8*, i8** %1
br label %12
12: ; preds = %10, %8
%13 = phi i8* [ %11, %10 ], [ null, %8 ]
%14 = call i64 @tdb_system_name(i32 0)
%15 = icmp eq i64 %14, 0
br i1 %15, label %40, label %16
16: ; preds = %12, %16
%17 = phi i32 [ %36, %16 ], [ 0, %12 ]
%18 = phi i32 [ %37, %16 ], [ 0, %12 ]
store i32 0, i32* %3
%19 = call i64 @tdb_system_name(i32 %18)
%20 = call i32 @test_data_1(i64 %19, i8* %13, i32* %3)
%21 = call i64 @tdb_system_name(i32 %18)
%22 = call i32 @test_data_2(i64 %21, i8* %13, i32* %3)
%23 = call i64 @tdb_system_name(i32 %18)
%24 = call i32 @test_data_3(i64 %23, i8* %13, i32* %3)
%25 = call i64 @tdb_system_name(i32 %18)
%26 = call i32 @test_data_4(i64 %25, i8* %13, i32* %3)
%27 = call i64 @tdb_system_name(i32 %18)
%28 = call i32 @test_rollback(i64 %27, i8* %13, i32* %3)
%29 = call i64 @tdb_system_name(i32 %18)
%30 = call i32 @test_mc(i64 %29, i8* %13, i32* %3)
%31 = call i64 @tdb_system_name(i32 %18)
%32 = call i32 @test_mt(i64 %31, i8* %13, i32* %3)
%33 = load i32, i32* %3
%34 = icmp ne i32 %33, 0
%35 = zext i1 %34 to i32
%36 = add nuw nsw i32 %17, %35
%37 = add nuw nsw i32 %18, 1
%38 = call i64 @tdb_system_name(i32 %37)
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %16
40: ; preds = %16, %12
%41 = phi i32 [ 0, %12 ], [ %36, %16 ]
store i32 0, i32* %3
%42 = call i32 @test_oom(i8* %13, i32* %3)
%43 = load i32, i32* %3
%44 = icmp ne i32 %43, 0
%45 = zext i1 %44 to i32
%46 = add nuw nsw i32 %41, %45
store i32 0, i32* %3
%47 = call i32 @test_api(i8* %13, i32* %3)
%48 = load i32, i32* %3
%49 = icmp ne i32 %48, 0
%50 = zext i1 %49 to i32
%51 = add nuw nsw i32 %46, %50
store i32 0, i32* %3
%52 = call i32 @do_crash_test(i8* %13, i32* %3)
%53 = load i32, i32* %3
%54 = icmp ne i32 %53, 0
%55 = zext i1 %54 to i32
%56 = add nuw nsw i32 %51, %55
store i32 0, i32* %3
%57 = call i32 @do_writer_crash_test(i8* %13, i32* %3)
%58 = load i32, i32* %3
%59 = icmp ne i32 %58, 0
%60 = sext i1 %59 to i32
%61 = icmp ne i32 %56, %60
%62 = zext i1 %61 to i32
br label %63
63: ; preds = %40, %6
%64 = phi i32 [ 1, %6 ], [ %62, %40 ]
ret i32 %64
}