// File: 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:
subq $0x408, %rsp            # imm = 0x408
movq %rsi, 0xf0(%rsp)
movq %rdi, 0x400(%rsp)
movq %rsi, 0x3f8(%rsp)
movq %rdx, 0x3f0(%rsp)
movq 0x400(%rsp), %rax
movq %rax, 0xe8(%rsp)
movq 0x194e2(%rip), %rdi     # 0x33fc0
leaq 0xdddd(%rip), %rsi      # 0x288c2
callq 0x3290
movq 0xf0(%rsp), %rsi
movq %rax, %rdi
callq 0x3270
movq %rax, %rdi
leaq 0xdd90(%rip), %rsi      # 0x28894
callq 0x3290
movq %rax, %rdi
movq 0x194b5(%rip), %rsi     # 0x33fc8
callq 0x32c0
leaq 0x1f0(%rsp), %rdi
movq %rdi, 0xf8(%rsp)
callq 0x3450
movq 0xf0(%rsp), %rdi
callq 0x3110
movq 0xf8(%rsp), %rdi
movq %rax, %rsi
movl $0x10, %edx
callq 0x3060
jmp 0x1ab51
leaq 0xdd71(%rip), %rsi      # 0x288c9
leaq 0x1f0(%rsp), %rdi
callq 0x3290
movq %rax, 0xe0(%rsp)
jmp 0x1ab6f
movq 0xe0(%rsp), %rdi
movq 0x19422(%rip), %rsi     # 0x33fa0
callq 0x32c0
jmp 0x1ab85
movq 0xe8(%rsp), %rax
movq 0x18(%rax), %rsi
leaq 0x1f0(%rsp), %rdi
callq 0x3090
movq %rax, 0xd8(%rsp)
jmp 0x1aba8
movq 0xd8(%rsp), %rdi
leaq 0xe091(%rip), %rsi      # 0x28c48
callq 0x3290
movq %rax, 0xd0(%rsp)
jmp 0x1abc6
movq 0xd0(%rsp), %rdi
movq 0xe8(%rsp), %rax
movq 0x20(%rax), %rsi
callq 0x3090
movq %rax, 0xc8(%rsp)
jmp 0x1abe9
movq 0xc8(%rsp), %rdi
leaq 0xdcd4(%rip), %rsi      # 0x288cc
callq 0x3290
movq %rax, 0xc0(%rsp)
jmp 0x1ac07
movq 0xc0(%rsp), %rdi
movq 0x1938a(%rip), %rsi     # 0x33fa0
callq 0x32c0
jmp 0x1ac1d
movq 0xe8(%rsp), %rdi
callq 0x1b760
movq %rax, %rcx
movq 0xe8(%rsp), %rax
movq %rcx, 0x1c8(%rsp)
movq 0x3f0(%rsp), %rsi
movq 0x18(%rax), %rcx
movq 0x20(%rax), %rax
imulq %rcx, %rsi
imulq %rax, %rsi
leaq 0x1c8(%rsp), %rdi
callq 0x1b790
movq 0xe8(%rsp), %rdi
movq %rax, 0x1d0(%rsp)
callq 0x1b760
movq %rax, %rcx
movq 0xe8(%rsp), %rax
movq %rcx, 0x1b8(%rsp)
movq 0x3f0(%rsp), %rsi
incq %rsi
movq 0x18(%rax), %rcx
movq 0x20(%rax), %rax
imulq %rcx, %rsi
imulq %rax, %rsi
leaq 0x1b8(%rsp), %rdi
callq 0x1b790
movq %rax, 0x1c0(%rsp)
movq 0x1d0(%rsp), %rdi
movq 0x1c0(%rsp), %rsi
callq 0x1b710
movq %rax, 0xb8(%rsp)
jmp 0x1acd9
movq 0xb8(%rsp), %rax
movq %rax, 0x1d8(%rsp)
leaq 0x1d8(%rsp), %rdi
callq 0x1b7d0
movss (%rax), %xmm0
movss %xmm0, 0x1e0(%rsp)
movss 0x1e0(%rsp), %xmm0
movss 0xd400(%rip), %xmm1     # 0x28114
addss %xmm1, %xmm0
movss 0xd3f8(%rip), %xmm1     # 0x28118
mulss %xmm1, %xmm0
movaps %xmm0, %xmm1
cvttss2si %xmm1, %rax
movq %rax, %rdx
sarq $0x3f, %rdx
movss 0xd3c5(%rip), %xmm1     # 0x28100
subss %xmm1, %xmm0
cvttss2si %xmm0, %rcx
andq %rdx, %rcx
orq %rcx, %rax
movq %rax, 0xa8(%rsp)
movl $0x0, 0x19c(%rsp)
leaq 0x19b(%rsp), %rdi
movq %rdi, 0xb0(%rsp)
callq 0x12e80
movq 0xa8(%rsp), %rsi
movq 0xb0(%rsp), %rcx
leaq 0x1a0(%rsp), %rdi
leaq 0x19c(%rsp), %rdx
callq 0x1b7e0
jmp 0x1ad99
leaq 0x19b(%rsp), %rdi
callq 0x12f10
leaq 0x190(%rsp), %rdi
callq 0x1b860
jmp 0x1adb5
leaq 0x180(%rsp), %rdi
xorps %xmm0, %xmm0
movsd 0xd278(%rip), %xmm1     # 0x28040
callq 0x1b880
jmp 0x1adcf
movl $0xf, 0x17c(%rsp)
movq 0x191df(%rip), %rdi     # 0x33fc0
leaq 0xdae9(%rip), %rsi      # 0x288d1
callq 0x3290
movq %rax, 0xa0(%rsp)
jmp 0x1adf7
movq 0xa0(%rsp), %rdi
movss 0x1e0(%rsp), %xmm0
callq 0x3230
movq %rax, 0x98(%rsp)
jmp 0x1ae17
movq 0x98(%rsp), %rdi
leaq 0xdab3(%rip), %rsi      # 0x288d9
callq 0x3290
movq %rax, 0x90(%rsp)
jmp 0x1ae35
movq 0x90(%rsp), %rdi
movq 0x1915c(%rip), %rsi     # 0x33fa0
callq 0x32c0
jmp 0x1ae4b
movl $0x0, 0x178(%rsp)
movq $0x1, 0x170(%rsp)
movq 0x170(%rsp), %rax
movq %rax, %rdx
shrq %rdx
movl %eax, %ecx
andl $0x1, %ecx
orq %rdx, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
cvtsi2ss %rax, %xmm1
movss %xmm1, 0x88(%rsp)
testq %rax, %rax
movss %xmm0, 0x8c(%rsp)
js 0x1aeaf
movss 0x88(%rsp), %xmm0
movss %xmm0, 0x8c(%rsp)
movss 0x8c(%rsp), %xmm1
movss 0x1e0(%rsp), %xmm0
ucomiss %xmm1, %xmm0
jb 0x1b121
movl 0x17c(%rsp), %eax
cvtsi2sd %rax, %xmm1
movsd 0xd1a2(%rip), %xmm0     # 0x28080
divsd %xmm1, %xmm0
movl 0x178(%rsp), %eax
cvtsi2sd %rax, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, 0x158(%rsp)
leaq 0x180(%rsp), %rdi
leaq 0x190(%rsp), %rsi
callq 0x1b8b0
movsd %xmm0, 0x80(%rsp)
jmp 0x1af1b
movsd 0x80(%rsp), %xmm0
movsd 0xd11c(%rip), %xmm1     # 0x28048
mulsd %xmm1, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x160(%rsp)
leaq 0x180(%rsp), %rdi
leaq 0x190(%rsp), %rsi
callq 0x1b8b0
movsd %xmm0, 0x78(%rsp)
jmp 0x1af5a
movsd 0x78(%rsp), %xmm0
movsd 0xd120(%rip), %xmm1     # 0x28088
mulsd %xmm1, %xmm0
movsd 0xd11c(%rip), %xmm1     # 0x28090
addsd %xmm1, %xmm0
movsd %xmm0, 0x168(%rsp)
movq 0x168(%rsp), %rax
movq %rax, 0x130(%rsp)
movups 0x158(%rsp), %xmm0
movaps %xmm0, 0x120(%rsp)
movq 0x130(%rsp), %rcx
movq %rsp, %rax
movq %rcx, 0x10(%rax)
movaps 0x120(%rsp), %xmm0
movups %xmm0, (%rax)
leaq 0x140(%rsp), %rdi
callq 0x5e60
jmp 0x1afca
movl 0x178(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x178(%rsp)
movl 0x178(%rsp), %eax
cmpl 0x17c(%rsp), %eax
jb 0x1b05d
movl $0x0, 0x178(%rsp)
jmp 0x1b05d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1e8(%rsp)
movl %eax, 0x1e4(%rsp)
jmp 0x1b378
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1e8(%rsp)
movl %eax, 0x1e4(%rsp)
leaq 0x19b(%rsp), %rdi
callq 0x12f10
jmp 0x1b378
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1e8(%rsp)
movl %eax, 0x1e4(%rsp)
leaq 0x1a0(%rsp), %rdi
callq 0x12fb0
jmp 0x1b378
movsd 0xd033(%rip), %xmm0     # 0x28098
mulsd 0x140(%rsp), %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x6c(%rsp)
imulq $0x3, 0x170(%rsp), %rsi
addq $0x0, %rsi
leaq 0x1a0(%rsp), %rdi
callq 0x12d40
movl 0x6c(%rsp), %ecx
movl %ecx, (%rax)
movsd 0xcffa(%rip), %xmm0     # 0x28098
mulsd 0x148(%rsp), %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x70(%rsp)
imulq $0x3, 0x170(%rsp), %rsi
addq $0x1, %rsi
leaq 0x1a0(%rsp), %rdi
callq 0x12d40
movl 0x70(%rsp), %ecx
movl %ecx, (%rax)
movsd 0xcfc1(%rip), %xmm0     # 0x28098
mulsd 0x150(%rsp), %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x74(%rsp)
imulq $0x3, 0x170(%rsp), %rsi
addq $0x2, %rsi
leaq 0x1a0(%rsp), %rdi
callq 0x12d40
movl 0x74(%rsp), %ecx
movl %ecx, (%rax)
movq 0x170(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x170(%rsp)
jmp 0x1ae62
movq $0x0, 0x118(%rsp)
movq 0xe8(%rsp), %rcx
movq 0x118(%rsp), %rax
cmpq 0x20(%rcx), %rax
je 0x1b31a
movq $0x0, 0x110(%rsp)
movq 0xe8(%rsp), %rcx
movq 0x110(%rsp), %rax
cmpq 0x18(%rcx), %rax
je 0x1b2e9
movq 0xe8(%rsp), %rdi
movq 0x110(%rsp), %rsi
movq 0x118(%rsp), %rdx
movq 0x3f0(%rsp), %rcx
callq 0x15be0
movss %xmm0, 0x68(%rsp)
jmp 0x1b19a
movss 0x68(%rsp), %xmm0
cvttss2si %xmm0, %eax
movl %eax, 0x10c(%rsp)
movl 0x10c(%rsp), %ecx
movl %ecx, %eax
leal (%rax,%rax,2), %eax
movslq %eax, %rsi
leaq 0x1a0(%rsp), %rdi
callq 0x12f20
movq %rax, 0x60(%rsp)
jmp 0x1b1ce
movq 0x60(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x108(%rsp)
movl 0x10c(%rsp), %ecx
movl %ecx, %eax
leal 0x1(%rax,%rax,2), %eax
movslq %eax, %rsi
leaq 0x1a0(%rsp), %rdi
callq 0x12f20
movq %rax, 0x58(%rsp)
jmp 0x1b200
movq 0x58(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x104(%rsp)
movl 0x10c(%rsp), %ecx
movl %ecx, %eax
leal 0x2(%rax,%rax,2), %eax
movslq %eax, %rsi
leaq 0x1a0(%rsp), %rdi
callq 0x12f20
movq %rax, 0x50(%rsp)
jmp 0x1b232
movq 0x50(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x100(%rsp)
movl 0x108(%rsp), %esi
leaq 0x1f0(%rsp), %rdi
callq 0x3470
movq %rax, 0x48(%rsp)
jmp 0x1b25b
movq 0x48(%rsp), %rdi
leaq 0xd9e1(%rip), %rsi      # 0x28c48
callq 0x3290
movq %rax, 0x40(%rsp)
jmp 0x1b273
movq 0x40(%rsp), %rdi
movl 0x104(%rsp), %esi
callq 0x3470
movq %rax, 0x38(%rsp)
jmp 0x1b28b
movq 0x38(%rsp), %rdi
leaq 0xd9b1(%rip), %rsi      # 0x28c48
callq 0x3290
movq %rax, 0x30(%rsp)
jmp 0x1b2a3
movq 0x30(%rsp), %rdi
movl 0x100(%rsp), %esi
callq 0x3470
movq %rax, 0x28(%rsp)
jmp 0x1b2bb
movq 0x28(%rsp), %rdi
leaq 0xd981(%rip), %rsi      # 0x28c48
callq 0x3290
jmp 0x1b2ce
jmp 0x1b2d0
movq 0x110(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x110(%rsp)
jmp 0x1b153
movq 0x18cb0(%rip), %rsi     # 0x33fa0
leaq 0x1f0(%rsp), %rdi
callq 0x32c0
jmp 0x1b2ff
jmp 0x1b301
movq 0x118(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x118(%rsp)
jmp 0x1b12d
leaq 0x1f0(%rsp), %rdi
callq 0x3370
jmp 0x1b329
movq 0x18c90(%rip), %rdi     # 0x33fc0
leaq 0xd513(%rip), %rsi      # 0x2884a
callq 0x3290
movq %rax, 0x20(%rsp)
jmp 0x1b343
movq 0x20(%rsp), %rdi
movq 0x18c51(%rip), %rsi     # 0x33fa0
callq 0x32c0
jmp 0x1b356
leaq 0x1a0(%rsp), %rdi
callq 0x12fb0
leaq 0x1f0(%rsp), %rdi
callq 0x3390
addq $0x408, %rsp            # imm = 0x408
retq
leaq 0x1f0(%rsp), %rdi
callq 0x3390
movq 0x1e8(%rsp), %rdi
callq 0x34a0
nopw %cs:(%rax,%rax)
nopl (%rax)