// File: /workspace/github_cpp_makefile_star2_O2/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 0x3e43
movl %eax, %ebx
leaq 0x345f(%rip), %rdi      # 0x7347
leaq 0x3463(%rip), %rdx      # 0x7352
movl $0x1c200, %esi          # imm = 0x1C200
callq 0x54e4
movq %rax, %r14
xorl %edi, %edi
testq %rax, %rax
setne %dil
leaq 0x344a(%rip), %rsi      # 0x7356
leaq 0x3a14(%rip), %rcx      # 0x7927
leaq 0x345c(%rip), %r8       # 0x7376
pushq $0x50
popq %rdx
xorl %eax, %eax
callq 0x269a
testl %eax, %eax
je 0x4132
leaq 0x344e(%rip), %rdi      # 0x7381
leaq 0x3418(%rip), %rdx      # 0x7352
movl $0x1c200, %esi          # imm = 0x1C200
callq 0x54e4
movq %rax, %r15
xorl %edi, %edi
testq %rax, %rax
setne %dil
leaq 0x33ff(%rip), %rsi      # 0x7356
leaq 0x39c9(%rip), %rcx      # 0x7927
leaq 0x3427(%rip), %r8       # 0x738c
pushq $0x52
popq %rdx
xorl %eax, %eax
callq 0x269a
testl %eax, %eax
je 0x4132
leaq 0x3419(%rip), %rsi      # 0x7397
pushq $0x3
popq %rdx
movq %r14, %rdi
callq 0x53e0
xorl %edi, %edi
cmpq $0x3, %rax
sete %dil
leaq 0x33bc(%rip), %rsi      # 0x7356
leaq 0x3986(%rip), %rcx      # 0x7927
leaq 0x33f3(%rip), %r8       # 0x739b
pushq $0x54
popq %rdx
xorl %eax, %eax
callq 0x269a
testl %eax, %eax
je 0x4132
movl $0x3e8, %edi            # imm = 0x3E8
callq 0x2410
leaq 0x6(%rsp), %rsi
pushq $0xa
popq %rdx
movq %r15, %rdi
callq 0x52a4
xorl %edi, %edi
cmpq $0x3, %rax
sete %dil
leaq 0x3371(%rip), %rsi      # 0x7356
leaq 0x393b(%rip), %rcx      # 0x7927
leaq 0x33cd(%rip), %r8       # 0x73c0
pushq $0x56
popq %rdx
xorl %eax, %eax
callq 0x269a
testl %eax, %eax
je 0x4132
leaq 0x338b(%rip), %rsi      # 0x7397
leaq 0x6(%rsp), %rdi
pushq $0x3
popq %rdx
callq 0x22c0
xorl %edi, %edi
testl %eax, %eax
sete %dil
leaq 0x332e(%rip), %rsi      # 0x7356
leaq 0x38f8(%rip), %rcx      # 0x7927
leaq 0x33bc(%rip), %r8       # 0x73f2
pushq $0x57
popq %rdx
xorl %eax, %eax
callq 0x269a
testl %eax, %eax
je 0x4132
leaq 0x33c1(%rip), %rsi      # 0x7410
pushq $0x5
popq %rdx
movq %r15, %rdi
callq 0x53e0
xorl %edi, %edi
cmpq $0x5, %rax
sete %dil
leaq 0x32eb(%rip), %rsi      # 0x7356
leaq 0x38b5(%rip), %rcx      # 0x7927
leaq 0x339d(%rip), %r8       # 0x7416
pushq $0x59
popq %rdx
xorl %eax, %eax
callq 0x269a
testl %eax, %eax
je 0x4132
movl $0x3e8, %edi            # imm = 0x3E8
callq 0x2410
leaq 0x6(%rsp), %rsi
pushq $0xa
popq %rdx
movq %r14, %rdi
callq 0x52a4
xorl %edi, %edi
cmpq $0x5, %rax
sete %dil
leaq 0x32a0(%rip), %rsi      # 0x7356
leaq 0x386a(%rip), %rcx      # 0x7927
leaq 0x3379(%rip), %r8       # 0x743d
pushq $0x5b
popq %rdx
xorl %eax, %eax
callq 0x269a
testl %eax, %eax
je 0x4132
leaq 0x3337(%rip), %rsi      # 0x7410
leaq 0x6(%rsp), %rdi
pushq $0x5
popq %rdx
callq 0x22c0
xorl %edi, %edi
testl %eax, %eax
sete %dil
leaq 0x3261(%rip), %rsi      # 0x7356
leaq 0x382b(%rip), %rcx      # 0x7927
leaq 0x336c(%rip), %r8       # 0x746f
pushq $0x5c
popq %rdx
xorl %eax, %eax
callq 0x269a
testl %eax, %eax
je 0x4132
movq %r14, %rdi
callq 0x54b1
movq %r15, %rdi
callq 0x54b1
movl %ebx, %edi
callq 0x3eba
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
callq 0x2f01