// File: 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
movq %rsp, %rbp
subq $0x300, %rsp            # imm = 0x300
movq %rdi, -0x8(%rbp)
leaq -0x40(%rbp), %rdi
movq %rdi, -0x228(%rbp)
callq 0x86b0
movq -0x228(%rbp), %rdi
leaq 0x9088(%rip), %rsi      # 0x103f5
callq 0x3290
jmp 0x7374
movb $0x1, -0x21c(%rbp)
leaq -0x138(%rbp), %rax
movq %rax, -0x238(%rbp)
movq %rax, -0x140(%rbp)
movb $-0xf, -0x152(%rbp)
movb $0x2, -0x151(%rbp)
leaq -0x152(%rbp), %rax
movq %rax, -0x150(%rbp)
movq $0x2, -0x148(%rbp)
leaq -0x153(%rbp), %rdi
movq %rdi, -0x230(%rbp)
callq 0x86e0
movq -0x238(%rbp), %rdi
movq -0x230(%rbp), %rcx
movq -0x150(%rbp), %rsi
movq -0x148(%rbp), %rdx
callq 0x8700
jmp 0x73ed
leaq -0x120(%rbp), %rax
movq %rax, -0x248(%rbp)
movq %rax, -0x140(%rbp)
movb $-0xf, -0x16a(%rbp)
movb $0x10, -0x169(%rbp)
leaq -0x16a(%rbp), %rax
movq %rax, -0x168(%rbp)
movq $0x2, -0x160(%rbp)
leaq -0x16b(%rbp), %rdi
movq %rdi, -0x240(%rbp)
callq 0x86e0
movq -0x248(%rbp), %rdi
movq -0x240(%rbp), %rcx
movq -0x168(%rbp), %rsi
movq -0x160(%rbp), %rdx
callq 0x8700
jmp 0x745f
leaq -0x108(%rbp), %rax
movq %rax, -0x258(%rbp)
movq %rax, -0x140(%rbp)
movb $-0xf, -0x182(%rbp)
movb $0x23, -0x181(%rbp)
leaq -0x182(%rbp), %rax
movq %rax, -0x180(%rbp)
movq $0x2, -0x178(%rbp)
leaq -0x183(%rbp), %rdi
movq %rdi, -0x250(%rbp)
callq 0x86e0
movq -0x258(%rbp), %rdi
movq -0x250(%rbp), %rcx
movq -0x180(%rbp), %rsi
movq -0x178(%rbp), %rdx
callq 0x8700
jmp 0x74d1
leaq -0xf0(%rbp), %rax
movq %rax, -0x268(%rbp)
movq %rax, -0x140(%rbp)
movb $-0xf, -0x19a(%rbp)
movb $0x30, -0x199(%rbp)
leaq -0x19a(%rbp), %rax
movq %rax, -0x198(%rbp)
movq $0x2, -0x190(%rbp)
leaq -0x19b(%rbp), %rdi
movq %rdi, -0x260(%rbp)
callq 0x86e0
movq -0x268(%rbp), %rdi
movq -0x260(%rbp), %rcx
movq -0x198(%rbp), %rsi
movq -0x190(%rbp), %rdx
callq 0x8700
jmp 0x7543
leaq -0xd8(%rbp), %rax
movq %rax, -0x278(%rbp)
movq %rax, -0x140(%rbp)
movb $-0xf, -0x1b2(%rbp)
movb $0x42, -0x1b1(%rbp)
leaq -0x1b2(%rbp), %rax
movq %rax, -0x1b0(%rbp)
movq $0x2, -0x1a8(%rbp)
leaq -0x1b3(%rbp), %rdi
movq %rdi, -0x270(%rbp)
callq 0x86e0
movq -0x278(%rbp), %rdi
movq -0x270(%rbp), %rcx
movq -0x1b0(%rbp), %rsi
movq -0x1a8(%rbp), %rdx
callq 0x8700
jmp 0x75b5
leaq -0xc0(%rbp), %rax
movq %rax, -0x288(%rbp)
movq %rax, -0x140(%rbp)
movb $-0xf, -0x1ca(%rbp)
movb $0x50, -0x1c9(%rbp)
leaq -0x1ca(%rbp), %rax
movq %rax, -0x1c8(%rbp)
movq $0x2, -0x1c0(%rbp)
leaq -0x1cb(%rbp), %rdi
movq %rdi, -0x280(%rbp)
callq 0x86e0
movq -0x288(%rbp), %rdi
movq -0x280(%rbp), %rcx
movq -0x1c8(%rbp), %rsi
movq -0x1c0(%rbp), %rdx
callq 0x8700
jmp 0x7627
leaq -0xa8(%rbp), %rax
movq %rax, -0x298(%rbp)
movq %rax, -0x140(%rbp)
movb $-0xf, -0x1e2(%rbp)
movb $0x61, -0x1e1(%rbp)
leaq -0x1e2(%rbp), %rax
movq %rax, -0x1e0(%rbp)
movq $0x2, -0x1d8(%rbp)
leaq -0x1e3(%rbp), %rdi
movq %rdi, -0x290(%rbp)
callq 0x86e0
movq -0x298(%rbp), %rdi
movq -0x290(%rbp), %rcx
movq -0x1e0(%rbp), %rsi
movq -0x1d8(%rbp), %rdx
callq 0x8700
jmp 0x7699
leaq -0x90(%rbp), %rax
movq %rax, -0x2a8(%rbp)
movq %rax, -0x140(%rbp)
movb $-0xf, -0x1fa(%rbp)
movb $0x72, -0x1f9(%rbp)
leaq -0x1fa(%rbp), %rax
movq %rax, -0x1f8(%rbp)
movq $0x2, -0x1f0(%rbp)
leaq -0x1fb(%rbp), %rdi
movq %rdi, -0x2a0(%rbp)
callq 0x86e0
movq -0x2a8(%rbp), %rdi
movq -0x2a0(%rbp), %rcx
movq -0x1f8(%rbp), %rsi
movq -0x1f0(%rbp), %rdx
callq 0x8700
jmp 0x770b
leaq -0x78(%rbp), %rax
movq %rax, -0x2b8(%rbp)
movq %rax, -0x140(%rbp)
movb $-0x10, -0x21a(%rbp)
movb $0x7f, -0x219(%rbp)
movb $0x7f, -0x218(%rbp)
movb $0x1, -0x217(%rbp)
movb $0x1, -0x216(%rbp)
movb $0x36, -0x215(%rbp)
movb $0x7, -0x214(%rbp)
movb $0x8, -0x213(%rbp)
movb $0x9, -0x212(%rbp)
movb $-0x9, -0x211(%rbp)
leaq -0x21a(%rbp), %rax
movq %rax, -0x210(%rbp)
movq $0xa, -0x208(%rbp)
leaq -0x21b(%rbp), %rdi
movq %rdi, -0x2b0(%rbp)
callq 0x86e0
movq -0x2b8(%rbp), %rdi
movq -0x2b0(%rbp), %rcx
movq -0x210(%rbp), %rsi
movq -0x208(%rbp), %rdx
callq 0x8700
jmp 0x77b2
movb $0x0, -0x21c(%rbp)
leaq -0x138(%rbp), %rax
movq %rax, -0x60(%rbp)
movq $0x9, -0x58(%rbp)
leaq -0x20(%rbp), %rdi
movq -0x60(%rbp), %rsi
movq -0x58(%rbp), %rdx
callq 0x8780
jmp 0x77df
leaq -0x138(%rbp), %rax
movq %rax, -0x2c8(%rbp)
addq $0xd8, %rax
movq %rax, -0x2c0(%rbp)
movq -0x2c0(%rbp), %rdi
addq $-0x18, %rdi
movq %rdi, -0x2d0(%rbp)
callq 0x83c0
movq -0x2c8(%rbp), %rcx
movq -0x2d0(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x2c0(%rbp)
jne 0x77fa
leaq -0x21b(%rbp), %rdi
callq 0x87d0
leaq -0x1fb(%rbp), %rdi
callq 0x87d0
leaq -0x1e3(%rbp), %rdi
callq 0x87d0
leaq -0x1cb(%rbp), %rdi
callq 0x87d0
leaq -0x1b3(%rbp), %rdi
callq 0x87d0
leaq -0x19b(%rbp), %rdi
callq 0x87d0
leaq -0x183(%rbp), %rdi
callq 0x87d0
leaq -0x16b(%rbp), %rdi
callq 0x87d0
leaq -0x153(%rbp), %rdi
callq 0x87d0
movq -0x8(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x87f0
jmp 0x78a6
leaq -0x40(%rbp), %rdi
callq 0x8860
addq $0x300, %rsp            # imm = 0x300
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x7a7c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x7a16
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x7a0a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x79fe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x79f2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x79e6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x79da
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x79ce
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x79c2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x79b6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x138(%rbp), %rax
movq %rax, -0x2e0(%rbp)
addq $0xd8, %rax
movq %rax, -0x2d8(%rbp)
movq -0x2d8(%rbp), %rdi
addq $-0x18, %rdi
movq %rdi, -0x2e8(%rbp)
callq 0x83c0
movq -0x2e0(%rbp), %rcx
movq -0x2e8(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x2d8(%rbp)
jne 0x7983
jmp 0x79b6
leaq -0x21b(%rbp), %rdi
callq 0x87d0
leaq -0x1fb(%rbp), %rdi
callq 0x87d0
leaq -0x1e3(%rbp), %rdi
callq 0x87d0
leaq -0x1cb(%rbp), %rdi
callq 0x87d0
leaq -0x1b3(%rbp), %rdi
callq 0x87d0
leaq -0x19b(%rbp), %rdi
callq 0x87d0
leaq -0x183(%rbp), %rdi
callq 0x87d0
leaq -0x16b(%rbp), %rdi
callq 0x87d0
leaq -0x153(%rbp), %rdi
callq 0x87d0
testb $0x1, -0x21c(%rbp)
jne 0x7a2d
jmp 0x7a7a
movq -0x140(%rbp), %rax
leaq -0x138(%rbp), %rcx
cmpq %rax, %rcx
movq %rax, -0x2f0(%rbp)
je 0x7a78
movq -0x2f0(%rbp), %rdi
addq $-0x18, %rdi
movq %rdi, -0x2f8(%rbp)
callq 0x83c0
movq -0x2f8(%rbp), %rax
leaq -0x138(%rbp), %rcx
cmpq %rcx, %rax
movq %rax, -0x2f0(%rbp)
jne 0x7a47
jmp 0x7a7a
jmp 0x7a7c
leaq -0x40(%rbp), %rdi
callq 0x8860
movq -0x48(%rbp), %rdi
callq 0x3320
nop