// File: /workspace/github_c_makefile_star2_O2/ieyasu[P]funit/build_rule.c
// Function: parse_build_rule
void *parse_build_rule(char *build)
{
    struct BRFragments *f = NEW0(struct BRFragments);
    struct StringBuffer sb;
    sb_init(&sb, 128);

    // parse one character at a time, handling special forms as they appear
    size_t i = 0;
    while (build[i] != '\0') {
        switch (build[i]) {
        case '$':
            if (build[i + 1] != '{') goto just_copy;
            i = parse_env_var(&sb, build, i);
            break;
        case '{':
            if (build[i + 1] != '{') goto just_copy;
            i = parse_internal_var(f, &sb, build, i);
            break;
        case '\\':
            switch (build[i + 1]) {
            case '$':
            case '{':
            case '}':
            case '\\':
                i++; // skip the escaping backslash
                goto just_copy;
            default:
                break; // unknown sequence - no escape - fall through
            }
            // FALL THROUGH
        default:
 just_copy:
            sb_add_char(&sb, build[i++]);
            break;
        }
    }

    if (sb.len > 0) { // one last string to add
        close_string_fragment(f, &sb);
    }

    sb_free(&sb);

    return f;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %r14
pushq $0x1
popq %rdi
pushq $0x18
popq %rsi
callq 0x2170
movq %rax, 0x8(%rsp)
leaq 0x10(%rsp), %r15
movl $0x80, %esi
movq %r15, %rdi
callq 0x6518
xorl %r13d, %r13d
leaq (%r14,%r13), %rbx
movzbl (%r14,%r13), %eax
cmpl $0x24, %eax
je 0x29c4
cmpl $0x5c, %eax
je 0x2993
cmpl $0x7b, %eax
je 0x2a36
testl %eax, %eax
jne 0x2b0e
jmp 0x2b8d
movb 0x1(%r14,%r13), %al
movzbl %al, %ecx
leal -0x5c(%rcx), %edx
cmpl $0x21, %edx
ja 0x29b3
movabsq $0x280000001, %rsi      # imm = 0x280000001
btq %rdx, %rsi
jb 0x29bc
cmpl $0x24, %ecx
jne 0x2b0c
incq %r13
jmp 0x2b0e
movb $0x24, %al
cmpb $0x7b, 0x1(%rbx)
jne 0x2b0e
leaq 0x2(%rbx), %r12
movq %r12, %rdi
leaq 0x49a3(%rip), %rsi      # 0x7381
callq 0x2150
cmpb $0x7d, 0x2(%rbx,%rax)
leaq 0x4999(%rip), %rsi      # 0x7388
jne 0x2b4b
movq %rax, %rbp
leaq 0x4a04(%rip), %rsi      # 0x7403
testq %rax, %rax
je 0x2b4b
movb $0x0, (%r12,%rbp)
movq %r12, %rdi
callq 0x2030
movb $0x7d, (%r12,%rbp)
testq %rax, %rax
je 0x2a2a
movq %r15, %rdi
movq %rax, %rsi
callq 0x65dc
addq %rbp, %r13
addq $0x3, %r13
jmp 0x296a
movb $0x7b, %al
cmpb $0x7b, 0x1(%rbx)
jne 0x2b0e
leaq 0x2(%rbx), %rbp
pushq $0x2
popq %r12
movzbl (%rbx,%r12), %eax
testl %eax, %eax
je 0x2a5d
cmpl $0x7d, %eax
je 0x2a5d
incq %r12
jmp 0x2a4a
cmpq $0x2, %r12
jne 0x2a6f
leaq 0x4a2b(%rip), %rdi      # 0x7495
jmp 0x2b28
cmpb $0x7d, %al
jne 0x2b21
cmpb $0x7d, 0x1(%rbx,%r12)
jne 0x2b21
movb $0x0, (%rbx,%r12)
xorl %ecx, %ecx
leaq 0x10(%rcx), %r15
cmpq $0xa0, %r15
je 0x2b72
leaq 0x92ae(%rip), %rax      # 0xbd50
movq (%rcx,%rax), %rsi
movq %rbp, %rdi
callq 0x2180
movq %r15, %rcx
testl %eax, %eax
jne 0x2a8a
movb $0x7d, (%rbx,%r12)
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
leaq 0x10(%rsp), %rbp
movq %rbp, %rsi
callq 0x2bc3
movq %rbx, %rdi
callq 0x3033
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
movq %rcx, %rdx
shlq $0x4, %rdx
movl $0x1, (%rax,%rdx)
leaq 0x925d(%rip), %rsi      # 0xbd50
movq -0x8(%r15,%rsi), %rsi
movq %rbp, %r15
movq %rsi, 0x8(%rax,%rdx)
incq %rcx
movq %rcx, 0x8(%rbx)
addq %r12, %r13
jmp 0x2b42
movb $0x5c, %al
incq %r13
movsbl %al, %esi
movq %r15, %rdi
callq 0x657f
jmp 0x296a
leaq 0x4995(%rip), %rdi      # 0x74bd
movq %rbx, %rsi
callq 0x2cc4
movq %r15, %rdi
leaq 0x49b4(%rip), %rsi      # 0x74ee
pushq $0x2
popq %rdx
callq 0x65aa
addq $0x2, %r13
jmp 0x296a
incq %r13
movq 0x94a3(%rip), %rax      # 0xbff8
movq (%rax), %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2190
movq %r15, %rdi
pushq $0x24
popq %rsi
callq 0x657f
jmp 0x296a
leaq 0x4963(%rip), %rdi      # 0x74dc
movq %rbp, %rsi
callq 0x2cc4
movb $0x7d, (%rbx,%r12)
leaq 0x10(%rsp), %r15
jmp 0x2b30
cmpq $0x0, 0x20(%rsp)
movq 0x8(%rsp), %rbx
je 0x2ba7
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x2bc3
leaq 0x10(%rsp), %rdi
callq 0x653e
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq