// File: /workspace/github_cpp_makefile_star2_O1/AndreRenaud[P]simple_uart/simple_uart_test.c
// Function: test_loopback
void test_loopback(void)
{
    struct simple_uart *u1, *u2;
    char buffer[10];
    pid_t pid;

    pid = setup_loopback();

    u1 = simple_uart_open(UART_LOOPBACK_1, 115200, "8N1");
    TEST_ASSERT(u1 != NULL);
    u2 = simple_uart_open(UART_LOOPBACK_2, 115200, "8N1");
    TEST_ASSERT(u2 != NULL);

    TEST_ASSERT(simple_uart_write(u1, "foo", 3) == 3);
    usleep(1000);
    TEST_ASSERT(simple_uart_read(u2, buffer, sizeof(buffer)) == 3);
    TEST_ASSERT(memcmp(buffer, "foo", 3) == 0);

    TEST_ASSERT(simple_uart_write(u2, "fnord", 5) == 5);
    usleep(1000);
    TEST_ASSERT(simple_uart_read(u1, buffer, sizeof(buffer)) == 5);
    TEST_ASSERT(memcmp(buffer, "fnord", 5) == 0);

    simple_uart_close(u1);
    simple_uart_close(u2);
    shutdown_loopback(pid);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
callq 0x4256
movl %eax, %ebx
leaq 0x3065(%rip), %rdi      # 0x7347
leaq 0x3069(%rip), %rdx      # 0x7352
movl $0x1c200, %esi          # imm = 0x1C200
callq 0x5b0d
movq %rax, %r14
xorl %edi, %edi
testq %rax, %rax
setne %dil
leaq 0x3050(%rip), %rsi      # 0x7356
leaq 0x361d(%rip), %rcx      # 0x792a
leaq 0x3062(%rip), %r8       # 0x7376
movl $0x50, %edx
xorl %eax, %eax
callq 0x28d6
testl %eax, %eax
je 0x4550
leaq 0x3052(%rip), %rdi      # 0x7381
leaq 0x301c(%rip), %rdx      # 0x7352
movl $0x1c200, %esi          # imm = 0x1C200
callq 0x5b0d
movq %rax, %r15
xorl %edi, %edi
testq %rax, %rax
setne %dil
leaq 0x3003(%rip), %rsi      # 0x7356
leaq 0x35d0(%rip), %rcx      # 0x792a
leaq 0x302b(%rip), %r8       # 0x738c
movl $0x52, %edx
xorl %eax, %eax
callq 0x28d6
testl %eax, %eax
je 0x4550
leaq 0x301b(%rip), %rsi      # 0x7397
movl $0x3, %edx
movq %r14, %rdi
callq 0x59df
xorl %edi, %edi
cmpq $0x3, %rax
sete %dil
leaq 0x2fbc(%rip), %rsi      # 0x7356
leaq 0x3589(%rip), %rcx      # 0x792a
leaq 0x2ff3(%rip), %r8       # 0x739b
movl $0x54, %edx
xorl %eax, %eax
callq 0x28d6
testl %eax, %eax
je 0x4550
movl $0x3e8, %edi            # imm = 0x3E8
callq 0x2410
leaq 0x6(%rsp), %rsi
movl $0xa, %edx
movq %r15, %rdi
callq 0x5868
xorl %edi, %edi
cmpq $0x3, %rax
sete %dil
leaq 0x2f6d(%rip), %rsi      # 0x7356
leaq 0x353a(%rip), %rcx      # 0x792a
leaq 0x2fc9(%rip), %r8       # 0x73c0
movl $0x56, %edx
xorl %eax, %eax
callq 0x28d6
testl %eax, %eax
je 0x4550
movzwl 0x6(%rsp), %eax
xorl $0x6f66, %eax           # imm = 0x6F66
movzbl 0x8(%rsp), %ecx
xorl $0x6f, %ecx
xorl %edi, %edi
orw %ax, %cx
sete %dil
leaq 0x2f29(%rip), %rsi      # 0x7356
leaq 0x34f6(%rip), %rcx      # 0x792a
leaq 0x2fb7(%rip), %r8       # 0x73f2
movl $0x57, %edx
xorl %eax, %eax
callq 0x28d6
testl %eax, %eax
je 0x4550
leaq 0x2fba(%rip), %rsi      # 0x7410
movl $0x5, %edx
movq %r15, %rdi
callq 0x59df
xorl %edi, %edi
cmpq $0x5, %rax
sete %dil
leaq 0x2ee2(%rip), %rsi      # 0x7356
leaq 0x34af(%rip), %rcx      # 0x792a
leaq 0x2f94(%rip), %r8       # 0x7416
movl $0x59, %edx
xorl %eax, %eax
callq 0x28d6
testl %eax, %eax
je 0x4550
movl $0x3e8, %edi            # imm = 0x3E8
callq 0x2410
leaq 0x6(%rsp), %rsi
movl $0xa, %edx
movq %r14, %rdi
callq 0x5868
xorl %edi, %edi
cmpq $0x5, %rax
sete %dil
leaq 0x2e93(%rip), %rsi      # 0x7356
leaq 0x3460(%rip), %rcx      # 0x792a
leaq 0x2f6c(%rip), %r8       # 0x743d
movl $0x5b, %edx
xorl %eax, %eax
callq 0x28d6
testl %eax, %eax
je 0x4550
movl $0x726f6e66, %eax       # imm = 0x726F6E66
xorl 0x6(%rsp), %eax
movzbl 0xa(%rsp), %ecx
xorl $0x64, %ecx
xorl %edi, %edi
orl %eax, %ecx
sete %dil
leaq 0x2e55(%rip), %rsi      # 0x7356
leaq 0x3422(%rip), %rcx      # 0x792a
leaq 0x2f60(%rip), %r8       # 0x746f
movl $0x5c, %edx
xorl %eax, %eax
callq 0x28d6
testl %eax, %eax
je 0x4550
movq %r14, %rdi
callq 0x5ad5
movq %r15, %rdi
callq 0x5ad5
movl %ebx, %edi
movl $0x1, %esi
callq 0x2270
movl %ebx, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x22f0
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
callq 0x31a2