// File: /workspace/github_cpp_makefile_star2_O3/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 0x416a
movl %eax, %ebx
leaq 0x3185(%rip), %rdi      # 0x737f
leaq 0x3189(%rip), %rdx      # 0x738a
movl $0x1c200, %esi          # imm = 0x1C200
callq 0x5a07
movq %rax, %r14
xorl %edi, %edi
testq %rax, %rax
setne %dil
leaq 0x3170(%rip), %rsi      # 0x738e
leaq 0x373a(%rip), %rcx      # 0x795f
leaq 0x3182(%rip), %r8       # 0x73ae
movl $0x50, %edx
xorl %eax, %eax
callq 0x28df
testl %eax, %eax
je 0x4468
leaq 0x3172(%rip), %rdi      # 0x73b9
leaq 0x313c(%rip), %rdx      # 0x738a
movl $0x1c200, %esi          # imm = 0x1C200
callq 0x5a07
movq %rax, %r15
xorl %edi, %edi
testq %rax, %rax
setne %dil
leaq 0x3123(%rip), %rsi      # 0x738e
leaq 0x36ed(%rip), %rcx      # 0x795f
leaq 0x314b(%rip), %r8       # 0x73c4
movl $0x52, %edx
xorl %eax, %eax
callq 0x28df
testl %eax, %eax
je 0x4468
leaq 0x313b(%rip), %rsi      # 0x73cf
movl $0x3, %edx
movq %r14, %rdi
callq 0x58f7
xorl %edi, %edi
cmpq $0x3, %rax
sete %dil
leaq 0x30dc(%rip), %rsi      # 0x738e
leaq 0x36a6(%rip), %rcx      # 0x795f
leaq 0x3113(%rip), %r8       # 0x73d3
movl $0x54, %edx
xorl %eax, %eax
callq 0x28df
testl %eax, %eax
je 0x4468
movl $0x3e8, %edi            # imm = 0x3E8
callq 0x2410
leaq 0x6(%rsp), %rsi
movl $0xa, %edx
movq %r15, %rdi
callq 0x5780
xorl %edi, %edi
cmpq $0x3, %rax
sete %dil
leaq 0x308d(%rip), %rsi      # 0x738e
leaq 0x3657(%rip), %rcx      # 0x795f
leaq 0x30e9(%rip), %r8       # 0x73f8
movl $0x56, %edx
xorl %eax, %eax
callq 0x28df
testl %eax, %eax
je 0x4468
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 0x3049(%rip), %rsi      # 0x738e
leaq 0x3613(%rip), %rcx      # 0x795f
leaq 0x30d7(%rip), %r8       # 0x742a
movl $0x57, %edx
xorl %eax, %eax
callq 0x28df
testl %eax, %eax
je 0x4468
leaq 0x30da(%rip), %rsi      # 0x7448
movl $0x5, %edx
movq %r15, %rdi
callq 0x58f7
xorl %edi, %edi
cmpq $0x5, %rax
sete %dil
leaq 0x3002(%rip), %rsi      # 0x738e
leaq 0x35cc(%rip), %rcx      # 0x795f
leaq 0x30b4(%rip), %r8       # 0x744e
movl $0x59, %edx
xorl %eax, %eax
callq 0x28df
testl %eax, %eax
je 0x4468
movl $0x3e8, %edi            # imm = 0x3E8
callq 0x2410
leaq 0x6(%rsp), %rsi
movl $0xa, %edx
movq %r14, %rdi
callq 0x5780
xorl %edi, %edi
cmpq $0x5, %rax
sete %dil
leaq 0x2fb3(%rip), %rsi      # 0x738e
leaq 0x357d(%rip), %rcx      # 0x795f
leaq 0x308c(%rip), %r8       # 0x7475
movl $0x5b, %edx
xorl %eax, %eax
callq 0x28df
testl %eax, %eax
je 0x4468
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 0x2f75(%rip), %rsi      # 0x738e
leaq 0x353f(%rip), %rcx      # 0x795f
leaq 0x3080(%rip), %r8       # 0x74a7
movl $0x5c, %edx
xorl %eax, %eax
callq 0x28df
testl %eax, %eax
je 0x4468
movq %r14, %rdi
callq 0x59cf
movq %r15, %rdi
callq 0x59cf
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 0x31c2