// File: /workspace/github_c_makefile_star2_O3/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
movl $0x1, %edi
movl $0x18, %esi
callq 0x2170
movq %rax, 0x8(%rsp)
leaq 0x10(%rsp), %rbx
movl $0x80, %esi
movq %rbx, %rdi
callq 0x6a9d
xorl %r15d, %r15d
leaq (%r14,%r15), %rbp
movb (%r14,%r15), %al
movzbl %al, %ecx
cmpl $0x5b, %ecx
jle 0x2cee
cmpl $0x5c, %ecx
je 0x2d69
cmpl $0x7b, %ecx
jne 0x2e88
movb $0x7b, %al
cmpb $0x7b, 0x1(%rbp)
jne 0x2e88
leaq 0x2(%rbp), %r13
movl $0x2, %r12d
movzbl (%rbp,%r12), %eax
testl %eax, %eax
je 0x2da7
cmpl $0x7d, %eax
je 0x2da7
incq %r12
jmp 0x2cd2
cmpl $0x24, %ecx
jne 0x2d9a
movb $0x24, %al
cmpb $0x7b, 0x1(%rbp)
jne 0x2e88
leaq 0x2(%rbp), %r12
movq %r12, %rdi
leaq 0x4670(%rip), %rsi      # 0x7381
callq 0x2150
cmpb $0x7d, 0x2(%rbp,%rax)
leaq 0x4666(%rip), %rdi      # 0x7388
jne 0x2e9b
movq %rax, %r13
leaq 0x46d1(%rip), %rdi      # 0x7403
testq %rax, %rax
je 0x2e9b
movb $0x0, (%r12,%r13)
movq %r12, %rdi
callq 0x2030
movb $0x7d, (%r12,%r13)
testq %rax, %rax
je 0x2d5d
movq %rbx, %rdi
movq %rax, %rsi
callq 0x6b64
addq %r13, %r15
addq $0x3, %r15
jmp 0x2c9a
movb 0x1(%r14,%r15), %al
movzbl %al, %ecx
leal -0x5c(%rcx), %edx
cmpl $0x21, %edx
ja 0x2d89
movabsq $0x280000001, %rsi      # imm = 0x280000001
btq %rdx, %rsi
jb 0x2d92
cmpl $0x24, %ecx
jne 0x2e86
incq %r15
jmp 0x2e88
testl %ecx, %ecx
jne 0x2e88
jmp 0x2f0e
cmpq $0x2, %r12
je 0x2ec8
cmpb $0x7d, %al
jne 0x2eae
cmpb $0x7d, 0x1(%rbp,%r12)
jne 0x2eae
movb $0x0, (%rbp,%r12)
movl $0x8, %ebx
leaq 0x8f79(%rip), %rax      # 0xbd50
movq -0x8(%rbx,%rax), %rsi
movq %r13, %rdi
callq 0x2180
testl %eax, %eax
je 0x2e2e
addq $0x10, %rbx
cmpq $0x98, %rbx
jne 0x2dd0
movq 0x91fc(%rip), %rax      # 0xbff8
movq (%rax), %rdi
leaq 0x46eb(%rip), %rsi      # 0x74f1
leaq 0x46cf(%rip), %rdx      # 0x74dc
movq %r13, %rcx
leaq 0x9349(%rip), %r8       # 0xc160
xorl %eax, %eax
callq 0x2190
movb $0x7d, (%rbp,%r12)
leaq 0x10(%rsp), %rbx
jmp 0x2ef1
movb $0x7d, (%rbp,%r12)
movq 0x8(%rsp), %r13
movq %r13, %rdi
leaq 0x10(%rsp), %rbp
movq %rbp, %rsi
callq 0x2f44
movq %r13, %rdi
callq 0x341f
movq (%r13), %rax
movq 0x8(%r13), %rcx
movq %rcx, %rdx
shlq $0x4, %rdx
movl $0x1, (%rax,%rdx)
leaq 0x8ee2(%rip), %rsi      # 0xbd50
movq (%rbx,%rsi), %rsi
movq %rbp, %rbx
movq %rsi, 0x8(%rax,%rdx)
incq %rcx
movq %rcx, 0x8(%r13)
addq %r12, %r15
jmp 0x2f05
movb $0x5c, %al
incq %r15
movsbl %al, %esi
movq %rbx, %rdi
callq 0x6b05
jmp 0x2c9a
incq %r15
movq %rbp, %rsi
movq %rbx, %rdx
callq 0x239e
jmp 0x2c9a
movq 0x9143(%rip), %rax      # 0xbff8
movq (%rax), %rdi
leaq 0x4632(%rip), %rsi      # 0x74f1
leaq 0x45f7(%rip), %rdx      # 0x74bd
jmp 0x2ee0
movq 0x9129(%rip), %rax      # 0xbff8
movq (%rax), %rdi
leaq 0x4618(%rip), %rsi      # 0x74f1
leaq 0x45b5(%rip), %rdx      # 0x7495
movq %rbp, %rcx
leaq 0x9276(%rip), %r8       # 0xc160
xorl %eax, %eax
callq 0x2190
movl $0x2, %edx
movq %rbx, %rdi
leaq 0x45ee(%rip), %rsi      # 0x74ee
callq 0x6b32
addq $0x2, %r15
jmp 0x2c9a
cmpq $0x0, 0x20(%rsp)
movq 0x8(%rsp), %rbx
je 0x2f28
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x2f44
leaq 0x10(%rsp), %rdi
callq 0x6ac6
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq