// File: /workspace/github_cpp_makefile_star2_O1/danomatika[P]miditester/src/main.cpp
// Function: timecode(std::vector<TestSet, std::allocator<TestSet>>&)
void timecode(TestQueue &queue) {
    TestSet set;
    set.name = "timecode";
    set.messages = {

        // MIDI Time Code is more complicated then other messages:
        // http://www.recordingblogs.com/sa/Wiki/topic/MIDI-Quarter-Frame-message
        //
        // a MTC timestamp consists of 5 components:
        //
        //     hours:minutes:seconds:frames @ frames per second
        //
        // the first 3 components are sent as 2 separate MIDI messages
        //
        // you need a full 8 messages before you have the full time code value,
        // each message consists of 1 data byte that encodes 2 values:
        //
        //   * low nibble: value
        //   * high nibble: component and byte position within the final vale
        //
        // the hours portion is sent as a single nibble and the second data byte
        // is used to specify the frames per second:
        //
        //   * 0x00: 24 fps
        //   * 0x01: 25 fps
        //   * 0x02: 29.97 fps
        //   * 0x03: 30 fps
        //
        // the following test message sends: 01:02:03:04 @ 25 fps

        // 1 byte from 2 nibble messages
        // frames (5 bit): 0x02 = 2 frames (+ 2 added by receiver)
        {MIDI_TIMECODE, 0x02}, // 0x1X low frame nibble
        {MIDI_TIMECODE, 0x10}, // 0x0X high frame nibble

        // seconds (6 bit): 0x03 = 3 seconds
        {MIDI_TIMECODE, 0x23}, // 0x2X low second nibble
        {MIDI_TIMECODE, 0x30}, // 0x3X high second nibble

        // minutes (6 bit): 0x02 = 2 minutes
        {MIDI_TIMECODE, 0x42}, // 0x4X low minute nibble
        {MIDI_TIMECODE, 0x50}, // 0x5X high minute nibble

        // hours (5 bit): 0x01 = 1 hour, fps: b01 = 1 = 25 fps
        {MIDI_TIMECODE, 0x61}, // 0x6X hour low nibble
        {MIDI_TIMECODE, 0x72}, // 0x7X hour high bit & fps value: 0ffh

        // MTC Full Frame message: 06:07:08:09 @ 30 fps
        {
            MIDI_SYSEX,
            0x7F, // all makes
            0x7F, // all channels
            0x01, // MTC message
            0x01, // MTC Full Frame message
            0x36, // hour (5 bit) and fps (2 middle bits on high nibble)
            0x07, // minute (6 bit)
            0x08, // second (6 bit)
            0x09, // frame (5 bit)
            MIDI_SYSEXEND
        }
    };
    queue.push_back(set);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movq %rdi, %r15
leaq 0x38(%rsp), %rbp
movq %rbp, -0x10(%rbp)
xorl %eax, %eax
movq %rax, -0x8(%rbp)
movb $0x0, (%rbp)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rbp)
movq %rax, 0x20(%rbp)
leaq 0x28b9(%rip), %rcx      # 0x8281
leaq 0x28(%rsp), %rdi
movl $0x8, %r8d
xorl %esi, %esi
xorl %edx, %edx
callq 0x3210
leaq 0x26(%rsp), %rsi
movw $0x2f1, (%rsi)          # imm = 0x2F1
leaq 0x70(%rsp), %r14
leaq 0x17(%rsp), %rcx
movl $0x2, %edx
movq %r14, %rdi
callq 0x5e6e
leaq 0x88(%rsp), %rbx
leaq 0x24(%rsp), %rsi
movw $0x10f1, (%rsi)         # imm = 0x10F1
leaq 0x16(%rsp), %rcx
movl $0x2, %edx
movq %rbx, %rdi
callq 0x5e6e
leaq 0xa0(%rsp), %rbx
leaq 0x22(%rsp), %rsi
movw $0x23f1, (%rsi)         # imm = 0x23F1
leaq 0x15(%rsp), %rcx
movl $0x2, %edx
movq %rbx, %rdi
callq 0x5e6e
leaq 0xb8(%rsp), %rbx
leaq 0x20(%rsp), %rsi
movw $0x30f1, (%rsi)         # imm = 0x30F1
leaq 0x14(%rsp), %rcx
movl $0x2, %edx
movq %rbx, %rdi
callq 0x5e6e
leaq 0xd0(%rsp), %rbx
leaq 0x1e(%rsp), %rsi
movw $0x42f1, (%rsi)         # imm = 0x42F1
leaq 0x13(%rsp), %rcx
movl $0x2, %edx
movq %rbx, %rdi
callq 0x5e6e
leaq 0xe8(%rsp), %rbx
leaq 0x1c(%rsp), %rsi
movw $0x50f1, (%rsi)         # imm = 0x50F1
leaq 0x12(%rsp), %rcx
movl $0x2, %edx
movq %rbx, %rdi
callq 0x5e6e
leaq 0x100(%rsp), %rbx
leaq 0x1a(%rsp), %rsi
movw $0x61f1, (%rsi)         # imm = 0x61F1
leaq 0x11(%rsp), %rcx
movl $0x2, %edx
movq %rbx, %rdi
callq 0x5e6e
leaq 0x118(%rsp), %rbx
leaq 0x18(%rsp), %rsi
movw $0x72f1, (%rsi)         # imm = 0x72F1
leaq 0x10(%rsp), %rcx
movl $0x2, %edx
movq %rbx, %rdi
callq 0x5e6e
leaq 0x130(%rsp), %rbx
movabsq $0x8073601017f7ff0, %rax # imm = 0x8073601017F7FF0
leaq 0x66(%rsp), %rsi
movq %rax, (%rsi)
movw $0xf709, 0x8(%rsi)      # imm = 0xF709
leaq 0xf(%rsp), %rcx
movl $0xa, %edx
movq %rbx, %rdi
callq 0x5e6e
leaq 0x48(%rsp), %r12
leaq 0x148(%rsp), %r13
leaq 0x70(%rsp), %rsi
movq %r12, %rdi
movq %r13, %rdx
callq 0x60c8
movl $0xd8, %ebx
movq 0x58(%rsp,%rbx), %rdi
testq %rdi, %rdi
je 0x5b64
movq 0x68(%rsp,%rbx), %rsi
subq %rdi, %rsi
callq 0x31a0
addq $-0x18, %rbx
jne 0x5b4d
leaq 0x28(%rsp), %rsi
movq %r15, %rdi
callq 0x5eb2
movq %r12, %rdi
callq 0x5f0e
movq 0x28(%rsp), %rdi
cmpq %rbp, %rdi
je 0x5b96
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x31a0
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r15
leaq 0x70(%rsp), %rsi
movq %r13, %rdi
callq 0x33c0
movb $0x1, %al
jmp 0x5bcf
jmp 0x5bca
jmp 0x5bca
jmp 0x5bca
jmp 0x5bca
jmp 0x5bca
jmp 0x5bca
jmp 0x5bca
movq %rax, %r15
xorl %eax, %eax
cmpq %rbx, %r14
sete %cl
testb %al, %al
jne 0x5c0f
testb %cl, %cl
jne 0x5c0f
leaq 0x70(%rsp), %r14
movq -0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x5bf7
movq -0x8(%rbx), %rsi
subq %rdi, %rsi
callq 0x31a0
addq $-0x18, %rbx
cmpq %r14, %rbx
jne 0x5be2
jmp 0x5c0f
movq %rax, %r15
xorl %eax, %eax
movq %r14, %rbx
jmp 0x5bcf
movq %rax, %r15
leaq 0x28(%rsp), %rdi
callq 0x5edc
movq %r15, %rdi
callq 0x3280