// File: /workspace/github_c_makefile_star2_O3/yangtau[P]hedgehog/src/test/string_test.c
// Function: test_strbuf
void test_strbuf() {
    hg_strtable_init();

    struct hg_strbuf buf;

    {
        //  empty string
        hg_strbuf_init(&buf);

        test_assert(buf.len == 0);
        test_assert(!buf._moved);

        const char* t = hg_strbuf_to_str(&buf);
        test_assert(strcmp("", t) == 0);
        test_assert(buf._moved);

        hg_strbuf_free(&buf);
    }

    {
        hg_strbuf_init(&buf);
#define spaces "        "
        hg_strbuf_append(&buf, spaces);
        hg_strbuf_append(&buf, spaces);
        hg_strbuf_append(&buf, spaces);
        hg_strbuf_append(&buf, spaces);

        test_assert(buf.len == 4 * strlen(spaces));
        const char* t = hg_strbuf_to_str(&buf);
        test_assert(strcmp(spaces spaces spaces spaces, t) == 0);

#undef spaces
        hg_strbuf_free(&buf);
    }

    {
        hg_strbuf_init(&buf);
        test_assert(buf.len == 0);

        test_assert(hg_strbuf_append(&buf, "hello, %s", "world"));
        test_assert(buf.len == strlen("hello, world"));

        test_assert(hg_strbuf_append(&buf, "hello, %s", "world"));
        test_assert(buf.len == strlen("hello, worldhello, world"));

        test_assert(hg_strbuf_append(&buf, "hello, %s", "world"));
        test_assert(buf.len == strlen("hello, worldhello, worldhello, world"));

        test_assert(hg_strbuf_append(&buf, " a=%d+%d,b=%c", 10, 20, 'c'));
        test_assert(buf.len == strlen("hello, worldhello, worldhello, world a=10+20,b=c"));

        test_assert(hg_strbuf_append(&buf, ""));
        test_assert(buf.len == strlen("hello, worldhello, worldhello, world a=10+20,b=c"));

        test_assert(hg_strbuf_append(&buf, "  "));
        test_assert(buf.len == strlen("hello, worldhello, worldhello, world a=10+20,b=c  "));

        const char* t = hg_strbuf_to_str(&buf);
        test_assert(strcmp("hello, worldhello, worldhello, world a=10+20,b=c  ", t) == 0);
        test_assert(buf._moved);

        hg_strbuf_free(&buf);
    }

    hg_strtable_free();
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x28, %rsp
xorl %eax, %eax
callq 0x163c
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x1756
cmpq $0x0, (%rbx)
jne 0x1bc0
cmpb $0x1, 0x20(%rsp)
je 0x1bca
leaq 0x8(%rsp), %rdi
callq 0x193a
cmpb $0x0, (%rax)
jne 0x1bd4
cmpb $0x0, 0x20(%rsp)
je 0x1bde
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x177d
movq %rbx, %rdi
callq 0x1756
leaq 0x79c(%rip), %r14       # 0x218a
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x17b2
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x17b2
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x17b2
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x17b2
cmpq $0x20, (%rbx)
jne 0x1be8
leaq 0x8(%rsp), %rdi
callq 0x193a
leaq 0x735(%rip), %rdi       # 0x2172
movq %rax, %rsi
callq 0x1090
testl %eax, %eax
jne 0x1bf2
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x177d
movq %rbx, %rdi
callq 0x1756
cmpq $0x0, (%rbx)
jne 0x1bfc
leaq 0x74c(%rip), %rsi       # 0x21bf
leaq 0x74f(%rip), %rdx       # 0x21c9
leaq 0x8(%rsp), %rdi
xorl %eax, %eax
callq 0x17b2
testb %al, %al
je 0x1c06
cmpq $0xc, 0x8(%rsp)
jne 0x1c10
leaq 0x71e(%rip), %rsi       # 0x21bf
leaq 0x721(%rip), %rdx       # 0x21c9
leaq 0x8(%rsp), %rdi
xorl %eax, %eax
callq 0x17b2
testb %al, %al
je 0x1c1a
cmpq $0x18, 0x8(%rsp)
jne 0x1c24
leaq 0x6f0(%rip), %rsi       # 0x21bf
leaq 0x6f3(%rip), %rdx       # 0x21c9
leaq 0x8(%rsp), %rdi
xorl %eax, %eax
callq 0x17b2
testb %al, %al
je 0x1c2e
cmpq $0x24, 0x8(%rsp)
jne 0x1c38
leaq 0x789(%rip), %rsi       # 0x2286
leaq 0x8(%rsp), %rdi
movl $0xa, %edx
movl $0x14, %ecx
movl $0x63, %r8d
xorl %eax, %eax
callq 0x17b2
testb %al, %al
je 0x1c42
cmpq $0x30, 0x8(%rsp)
jne 0x1c4c
leaq 0x5d9(%rip), %rsi       # 0x210d
leaq 0x8(%rsp), %rdi
xorl %eax, %eax
callq 0x17b2
testb %al, %al
je 0x1c56
cmpq $0x30, 0x8(%rsp)
jne 0x1c60
leaq 0x635(%rip), %rsi       # 0x2190
leaq 0x8(%rsp), %rdi
xorl %eax, %eax
callq 0x17b2
testb %al, %al
je 0x1c6a
cmpq $0x32, 0x8(%rsp)
jne 0x1c74
leaq 0x8(%rsp), %rdi
callq 0x193a
leaq 0x803(%rip), %rdi       # 0x238f
movq %rax, %rsi
callq 0x1090
testl %eax, %eax
jne 0x1c7e
cmpb $0x0, 0x20(%rsp)
je 0x1c88
leaq 0x8(%rsp), %rdi
callq 0x177d
xorl %eax, %eax
callq 0x1666
addq $0x28, %rsp
popq %rbx
popq %r14
retq
callq 0x10e0
jmp 0x19a9
callq 0x1116
jmp 0x19b4
callq 0x114c
jmp 0x19c7
callq 0x1182
jmp 0x19d2
callq 0x11b8
jmp 0x1a2c
callq 0x11ee
jmp 0x1a4d
callq 0x1224
jmp 0x1a6c
callq 0x125a
jmp 0x1a8e
callq 0x1290
jmp 0x1a9a
callq 0x12c6
jmp 0x1abc
callq 0x12fc
jmp 0x1ac8
callq 0x1332
jmp 0x1aea
callq 0x1368
jmp 0x1af6
callq 0x139e
jmp 0x1b21
callq 0x13d4
jmp 0x1b2d
callq 0x140a
jmp 0x1b48
callq 0x1440
jmp 0x1b54
callq 0x1476
jmp 0x1b6f
callq 0x14ac
jmp 0x1b7b
callq 0x14e2
jmp 0x1b9c
callq 0x1518
jmp 0x1ba7