// File: shancheng[P]shancheng/db/sqlite_busyhandler_test.cpp
// Function: (anonymous namespace)::Job::ReadTenRecords()
bool ReadTenRecords() {
    bool result = true;
    sqlite3_stmt* stmt = NULL;
    while (true) {
      int status = sqlite3_prepare(db_, "SELECT value FROM test", -1, &stmt, NULL);
      if (status == SQLITE_OK) {
        break;
      } else if (status == SQLITE_BUSY) {
        ++total_busycount;
        if (option.debug) {
          cerr << "Thread " << threadindex_ << ": failed to prepare read statement (" << sqlite3_errmsg(db_) << ")\n";
        }
        sleep(1);
      } else {
        cerr << "Thread " << threadindex_ << ": failed to prepare read statement (" << sqlite3_errmsg(db_) << ")\n";
        result = false;
        goto cleanup;
      }
    }
    for (size_t i = 0; i < 10; ++i) {
      int status = sqlite3_step(stmt);
      if (status == SQLITE_ROW) {
        ProcessRecord(stmt);
        usleep(5000); // Sleep to increase the lock time
      } else if (status == SQLITE_DONE) {
        break;
      } else if (status == SQLITE_BUSY) {
        ++total_busycount;
        if (option.debug) {
          cerr << "Thread " << threadindex_ << ": failed to read data (" << sqlite3_errmsg(db_) << ")\n";
        }
        usleep(50000);
        --i; // Don't increase i
      } else {
        cerr << "Thread " << threadindex_ << ": failed to read data (" << sqlite3_errmsg(db_) << ")\n";
        result = false;
        break;
      }
    }

  cleanup:
    sqlite3_finalize(stmt);
    return result;
  }

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x50(%rsp)
movq 0x50(%rsp), %rax
movq %rax, 0x20(%rsp)
movb $0x1, 0x4f(%rsp)
movq $0x0, 0x40(%rsp)
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rdi
leaq 0x15a5b(%rip), %rsi     # 0x2091c
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
leaq 0x40(%rsp), %rcx
xorl %eax, %eax
movl %eax, %r8d
callq 0x9570
movl %eax, 0x3c(%rsp)
cmpl $0x0, 0x3c(%rsp)
jne 0xaee5
jmp 0xafed
cmpl $0x5, 0x3c(%rsp)
jne 0xaf78
movl 0x2460e(%rip), %eax     # 0x2f504
addl $0x1, %eax
movl %eax, 0x24605(%rip)     # 0x2f504
testb $0x1, 0x245da(%rip)     # 0x2f4e0
je 0xaf6c
movq 0x240e1(%rip), %rdi     # 0x2eff0
leaq 0x15a1d(%rip), %rsi     # 0x20933
callq 0x9460
movq %rax, %rdi
movq 0x20(%rsp), %rax
movq (%rax), %rsi
callq 0x90e0
movq %rax, %rdi
leaq 0x15a06(%rip), %rsi     # 0x2093b
callq 0x9460
movq %rax, %rcx
movq 0x20(%rsp), %rax
movq %rcx, 0x18(%rsp)
movq 0x8(%rax), %rdi
callq 0x9450
movq 0x18(%rsp), %rdi
movq %rax, %rsi
callq 0x9460
movq %rax, %rdi
leaq 0x1517e(%rip), %rsi     # 0x200e5
callq 0x9460
movl $0x1, %edi
callq 0x9360
jmp 0xafe6
movq 0x24071(%rip), %rdi     # 0x2eff0
leaq 0x159ad(%rip), %rsi     # 0x20933
callq 0x9460
movq %rax, %rdi
movq 0x20(%rsp), %rax
movq (%rax), %rsi
callq 0x90e0
movq %rax, %rdi
leaq 0x15996(%rip), %rsi     # 0x2093b
callq 0x9460
movq %rax, %rcx
movq 0x20(%rsp), %rax
movq %rcx, 0x10(%rsp)
movq 0x8(%rax), %rdi
callq 0x9450
movq 0x10(%rsp), %rdi
movq %rax, %rsi
callq 0x9460
movq %rax, %rdi
leaq 0x1510e(%rip), %rsi     # 0x200e5
callq 0x9460
movb $0x0, 0x4f(%rsp)
jmp 0xb166
jmp 0xafe8
jmp 0xaeb1
movq $0x0, 0x30(%rsp)
cmpq $0xa, 0x30(%rsp)
jae 0xb164
movq 0x40(%rsp), %rdi
callq 0x96a0
movl %eax, 0x2c(%rsp)
cmpl $0x64, 0x2c(%rsp)
jne 0xb035
movq 0x20(%rsp), %rdi
movq 0x40(%rsp), %rsi
callq 0xb2b0
movl $0x1388, %edi           # imm = 0x1388
callq 0x96d0
jmp 0xb14f
cmpl $0x65, 0x2c(%rsp)
jne 0xb041
jmp 0xb164
cmpl $0x5, 0x2c(%rsp)
jne 0xb0e2
movl 0x244b2(%rip), %eax     # 0x2f504
addl $0x1, %eax
movl %eax, 0x244a9(%rip)     # 0x2f504
testb $0x1, 0x2447e(%rip)     # 0x2f4e0
je 0xb0c8
movq 0x23f85(%rip), %rdi     # 0x2eff0
leaq 0x158c1(%rip), %rsi     # 0x20933
callq 0x9460
movq %rax, %rdi
movq 0x20(%rsp), %rax
movq (%rax), %rsi
callq 0x90e0
movq %rax, %rdi
leaq 0x158cf(%rip), %rsi     # 0x20960
callq 0x9460
movq %rax, %rcx
movq 0x20(%rsp), %rax
movq %rcx, 0x8(%rsp)
movq 0x8(%rax), %rdi
callq 0x9450
movq 0x8(%rsp), %rdi
movq %rax, %rsi
callq 0x9460
movq %rax, %rdi
leaq 0x15022(%rip), %rsi     # 0x200e5
callq 0x9460
movl $0xc350, %edi           # imm = 0xC350
callq 0x96d0
movq 0x30(%rsp), %rax
addq $-0x1, %rax
movq %rax, 0x30(%rsp)
jmp 0xb14b
movq 0x23f07(%rip), %rdi     # 0x2eff0
leaq 0x15843(%rip), %rsi     # 0x20933
callq 0x9460
movq %rax, %rdi
movq 0x20(%rsp), %rax
movq (%rax), %rsi
callq 0x90e0
movq %rax, %rdi
leaq 0x15851(%rip), %rsi     # 0x20960
callq 0x9460
movq %rax, %rcx
movq 0x20(%rsp), %rax
movq %rcx, (%rsp)
movq 0x8(%rax), %rdi
callq 0x9450
movq (%rsp), %rdi
movq %rax, %rsi
callq 0x9460
movq %rax, %rdi
leaq 0x14fa6(%rip), %rsi     # 0x200e5
callq 0x9460
movb $0x0, 0x4f(%rsp)
jmp 0xb164
jmp 0xb14d
jmp 0xb14f
jmp 0xb151
movq 0x30(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x30(%rsp)
jmp 0xaff6
jmp 0xb166
movq 0x40(%rsp), %rdi
callq 0x97a0
movb 0x4f(%rsp), %al
andb $0x1, %al
addq $0x58, %rsp
retq
nopl (%rax,%rax)