// File: /workspace/github_cpp_makefile_star2_O3/spatialfruitsalad[P]volume2position/./tomogram.hpp
// Function: tomogram3d<float>::write_ppm(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, unsigned long) const
void write_ppm(std::string outfilename, unsigned long picnumber) const
    {
        std::cout << "write " << outfilename << " ... " << std::flush;
        std::ofstream myfile;
        myfile.open (outfilename.c_str());
        myfile << "P3" << std::endl;
        myfile << sx << " " << sy << "\n255"  << std::endl;
        VALUE maxvalue = *std::max_element (data.begin()+(picnumber*sx*sy),data.begin()+((picnumber+1)*sx*sy));
        std::vector<int> cvals((maxvalue+1)*3, 0);

        std::default_random_engine rng;
        std::uniform_real_distribution<double> d(0,1);

        unsigned int N = 15;
        // create color list
        std::cout << "create " << maxvalue << " colors" << std::endl;


        unsigned int idx = 0;
        for (unsigned long k = 1; k <= maxvalue; ++k)
        {
            hsv ch;
            ch.h = 360.0/static_cast<double>(N) * static_cast<double>(idx);
            ch.s = 0.5 + 0.5 * d(rng);
            ch.v = 0.3 + 0.7 * d(rng);
            rgb c = hsv2rgb(ch);
            idx++;
            if (idx >= N) idx = 0;
            //std::cout << "r= " << c.r*255.0 << std::endl;
            //std::cout << "g= " << c.g*255.0 << std::endl;
            //std::cout << "b= " << c.b << std::endl;
            cvals[k*3 + 0] = (c.r*255.0);
            cvals[k*3 + 1] = (c.g*255.0);
            cvals[k*3 + 2] = (c.b*255.0);
        }

        for (unsigned long j = 0; j != sy; ++j)
        {
            for (unsigned long i = 0; i != sx; ++i)
            {
                int val = int(get(i,j,picnumber));

                int r = cvals.at(val*3 + 0);
                int g = cvals.at(val*3 + 1);
                int b = cvals.at(val*3 + 2);
                myfile << r << " " << g << " " << b << " ";
            }
            myfile << std::endl;
        }
        myfile.close();
        std::cout << " done" << std::endl;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x258, %rsp            # imm = 0x258
movq %rdx, 0x10(%rsp)
movq %rsi, %r15
movq %rdi, %r14
movq 0xaec7(%rip), %rbx      # 0x1cfc8
leaq 0x582d(%rip), %rsi      # 0x17935
movl $0x6, %edx
movq %rbx, %rdi
callq 0x32f0
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq %rbx, %rdi
callq 0x32f0
movq %rax, %rbx
leaq 0x57d9(%rip), %rsi      # 0x17907
movl $0x5, %edx
movq %rax, %rdi
callq 0x32f0
movq %rbx, %rdi
callq 0x31e0
leaq 0x58(%rsp), %rbx
movq %rbx, %rdi
callq 0x3400
movq (%r15), %rsi
movq %rbx, %rdi
movl $0x10, %edx
callq 0x3050
leaq 0x57d5(%rip), %rsi      # 0x1793c
leaq 0x58(%rsp), %rbx
movl $0x2, %edx
movq %rbx, %rdi
callq 0x32f0
movq 0x58(%rsp), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x32a0
movsbl %al, %esi
leaq 0x58(%rsp), %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31e0
movq 0x18(%r14), %rsi
leaq 0x58(%rsp), %rdi
callq 0x31d0
movq %rax, %rbx
leaq 0x5afb(%rip), %rsi      # 0x17cb7
movl $0x1, %edx
movq %rax, %rdi
callq 0x32f0
movq 0x20(%r14), %rsi
movq %rbx, %rdi
callq 0x31d0
movq %rax, %r15
leaq 0x5760(%rip), %rsi      # 0x1793f
movl $0x4, %edx
movq %rax, %rdi
callq 0x32f0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x32a0
movsbl %al, %esi
movq %r15, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31e0
movq (%r14), %rcx
movq 0x18(%r14), %rdx
imulq 0x20(%r14), %rdx
movq %rdx, %rsi
movq 0x10(%rsp), %rdi
imulq %rdi, %rsi
leaq (%rcx,%rsi,4), %rax
incq %rdi
imulq %rdx, %rdi
leaq (%rcx,%rdi,4), %r8
cmpq %rdi, %rsi
sete %sil
movq %rax, %rcx
addq $0x4, %rcx
cmpq %r8, %rcx
sete %dil
orb %sil, %dil
jne 0x1227c
movss (%rax), %xmm0
leaq -0x4(,%rdx,4), %rdx
movss (%rcx), %xmm1
ucomiss %xmm0, %xmm1
cmovaq %rcx, %rax
maxss %xmm0, %xmm1
addq $0x4, %rcx
movaps %xmm1, %xmm0
addq $-0x4, %rdx
jne 0x12260
movq %r14, 0x8(%rsp)
movss (%rax), %xmm1
movss 0x4ec3(%rip), %xmm0     # 0x17150
movss %xmm1, (%rsp)
addss %xmm1, %xmm0
mulss 0x4eb6(%rip), %xmm0     # 0x17154
cvttss2si %xmm0, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subss 0x4e8e(%rip), %xmm0     # 0x17140
cvttss2si %xmm0, %rsi
andq %rcx, %rsi
orq %rax, %rsi
leaq 0x18(%rsp), %rdx
movl $0x0, (%rdx)
leaq 0x28(%rsp), %rdi
leaq 0x7(%rsp), %rcx
callq 0x12a60
movq $0x1, 0x18(%rsp)
movq 0xace1(%rip), %rdi      # 0x1cfc8
leaq 0x5656(%rip), %rsi      # 0x17944
movl $0x7, %edx
callq 0x32f0
xorps %xmm0, %xmm0
cvtss2sd (%rsp), %xmm0
movq 0xacc1(%rip), %rdi      # 0x1cfc8
callq 0x33c0
movq %rax, %r15
leaq 0x5636(%rip), %rsi      # 0x1794c
movl $0x7, %edx
movq %rax, %rdi
callq 0x32f0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x32a0
movsbl %al, %esi
movq %r15, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31e0
movss (%rsp), %xmm0
ucomiss 0x4dfa(%rip), %xmm0     # 0x17150
jae 0x1252a
movq 0x8(%rsp), %rdi
cmpq $0x0, 0x20(%rdi)
je 0x12487
xorl %r12d, %r12d
leaq 0x5941(%rip), %r13      # 0x17cb7
cmpq $0x0, 0x18(%rdi)
je 0x12445
xorl %ebp, %ebp
movq %rbp, %rsi
movq %r12, %rdx
movq 0x10(%rsp), %rcx
callq 0xf342
cvttss2si %xmm0, %eax
leal (%rax,%rax,2), %ecx
movslq %ecx, %rsi
movq 0x28(%rsp), %rdi
movq 0x30(%rsp), %rdx
subq %rdi, %rdx
sarq $0x2, %rdx
cmpq %rsi, %rdx
jbe 0x1271e
leal 0x1(%rcx), %eax
cltq
cmpq %rax, %rdx
jbe 0x1272c
addl $0x2, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rdx
jbe 0x1270d
movl (%rdi,%rsi,4), %esi
movl (%rdi,%rax,4), %ebx
movl (%rdi,%rcx,4), %r15d
leaq 0x58(%rsp), %rdi
callq 0x3420
movq %rax, %r14
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x32f0
movq %r14, %rdi
movl %ebx, %esi
callq 0x3420
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x32f0
movq %rbx, %rdi
movl %r15d, %esi
callq 0x3420
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x32f0
incq %rbp
movq 0x8(%rsp), %rdi
cmpq 0x18(%rdi), %rbp
jne 0x12383
movq 0x58(%rsp), %rax
movq -0x18(%rax), %rdi
leaq 0x58(%rsp), %rax
addq %rax, %rdi
movl $0xa, %esi
callq 0x32a0
movsbl %al, %esi
leaq 0x58(%rsp), %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31e0
incq %r12
movq 0x8(%rsp), %rdi
cmpq 0x20(%rdi), %r12
jne 0x12376
leaq 0x58(%rsp), %rdi
callq 0x3360
movq 0xab30(%rip), %rbx      # 0x1cfc8
leaq 0x541e(%rip), %rsi      # 0x178bd
movl $0x5, %edx
movq %rbx, %rdi
callq 0x32f0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x32a0
movsbl %al, %esi
movq 0xaafe(%rip), %rdi      # 0x1cfc8
callq 0x3040
movq %rax, %rdi
callq 0x31e0
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x124e6
callq 0x3280
movq 0xaacb(%rip), %rax      # 0x1cfb8
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0x60(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0x58(%rsp,%rcx)
callq 0x3250
leaq 0x150(%rsp), %rdi
callq 0x30c0
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %ebx, %ebx
movl $0x14, %r14d
movl $0x2, %r15d
leaq 0x18(%rsp), %r12
leaq 0x4c18(%rip), %r13      # 0x1715c
xorl %ebp, %ebp
movl %ebp, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
mulsd 0x4b28(%rip), %xmm0     # 0x17080
movapd %xmm0, 0x40(%rsp)
movq %r12, %rdi
callq 0x12bdc
movsd %xmm0, 0x20(%rsp)
movq %r12, %rdi
callq 0x12bdc
xorps %xmm1, %xmm1
movsd 0x20(%rsp), %xmm6
addsd %xmm1, %xmm6
addsd %xmm1, %xmm0
movsd 0x4abb(%rip), %xmm2     # 0x17048
mulsd %xmm2, %xmm6
addsd %xmm2, %xmm6
mulsd 0x4aeb(%rip), %xmm0     # 0x17088
addsd 0x4aeb(%rip), %xmm0     # 0x17090
ucomisd %xmm6, %xmm1
movsd 0x4a9f(%rip), %xmm5     # 0x17050
jae 0x12639
movsd 0x4ae1(%rip), %xmm1     # 0x170a0
movapd 0x40(%rsp), %xmm3
cmpnlesd %xmm3, %xmm1
divsd 0x4ac6(%rip), %xmm3     # 0x17098
andpd %xmm1, %xmm3
cvttsd2si %xmm3, %rax
xorps %xmm1, %xmm1
cvtsi2sd %rax, %xmm1
subsd %xmm1, %xmm3
movapd %xmm5, %xmm1
subsd %xmm6, %xmm1
mulsd %xmm0, %xmm1
movapd %xmm6, %xmm2
mulsd %xmm3, %xmm2
movapd %xmm5, %xmm4
subsd %xmm2, %xmm4
mulsd %xmm0, %xmm4
cmpq $0x4, %rax
ja 0x126fc
movapd %xmm5, %xmm2
subsd %xmm3, %xmm2
mulsd %xmm2, %xmm6
subsd %xmm6, %xmm5
mulsd %xmm0, %xmm5
movslq (%r13,%rax,4), %rax
addq %r13, %rax
jmpq *%rax
movapd %xmm0, %xmm2
movapd %xmm5, %xmm3
jmp 0x12645
movapd %xmm0, %xmm2
movapd %xmm0, %xmm3
movapd %xmm0, %xmm1
incl %ebp
cmpl $0xf, %ebp
cmovael %ebx, %ebp
movsd 0x4a53(%rip), %xmm0     # 0x170a8
mulsd %xmm0, %xmm2
cvttsd2si %xmm2, %eax
movq 0x28(%rsp), %rcx
movl %eax, -0x8(%rcx,%r14)
mulsd %xmm0, %xmm3
cvttsd2si %xmm3, %eax
movl %eax, -0x4(%rcx,%r14)
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %eax
movl %eax, (%rcx,%r14)
testq %r15, %r15
js 0x1268f
xorps %xmm0, %xmm0
cvtsi2ss %r15, %xmm0
jmp 0x126aa
movq %r15, %rax
shrq %rax
movl %r15d, %ecx
andl $0x1, %ecx
orq %rax, %rcx
xorps %xmm0, %xmm0
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
addq $0xc, %r14
incq %r15
movss (%rsp), %xmm1
ucomiss %xmm0, %xmm1
jae 0x12546
jmp 0x1235c
movapd %xmm5, %xmm2
movapd %xmm1, %xmm3
jmp 0x12641
movapd %xmm1, %xmm2
movapd %xmm0, %xmm3
movapd %xmm5, %xmm1
jmp 0x12645
movapd %xmm1, %xmm2
movapd %xmm4, %xmm3
jmp 0x12641
movapd %xmm4, %xmm2
movapd %xmm0, %xmm3
jmp 0x12645
movapd %xmm0, %xmm2
movapd %xmm1, %xmm3
movapd %xmm4, %xmm1
jmp 0x12645
leaq 0x5045(%rip), %rdi      # 0x17759
movq %rcx, %rsi
xorl %eax, %eax
callq 0x3390
leaq 0x5034(%rip), %rdi      # 0x17759
xorl %eax, %eax
callq 0x3390
leaq 0x5026(%rip), %rdi      # 0x17759
movq %rax, %rsi
xorl %eax, %eax
callq 0x3390
jmp 0x12743
jmp 0x12754
jmp 0x12754
movq %rax, %rbx
jmp 0x12766
jmp 0x12754
jmp 0x12754
jmp 0x12754
jmp 0x12754
jmp 0x12754
jmp 0x12754
movq %rax, %rbx
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x12766
callq 0x3280
leaq 0x58(%rsp), %rdi
callq 0x3380
movq %rbx, %rdi
callq 0x3430