// File: /workspace/github_cpp_makefile_star2_O1/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 0xad55(%rip), %rbx      # 0x1cfc8
leaq 0x56cb(%rip), %rsi      # 0x17945
movl $0x6, %edx
movq %rbx, %rdi
callq 0x3300
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq %rbx, %rdi
callq 0x3300
movq %rax, %rbx
leaq 0x5677(%rip), %rsi      # 0x17917
movl $0x5, %edx
movq %rax, %rdi
callq 0x3300
movq %rbx, %rdi
callq 0x31e0
leaq 0x58(%rsp), %rbx
movq %rbx, %rdi
callq 0x3410
movq (%r15), %rsi
movq %rbx, %rdi
movl $0x10, %edx
callq 0x3050
leaq 0x5673(%rip), %rsi      # 0x1794c
leaq 0x58(%rsp), %rbx
movl $0x2, %edx
movq %rbx, %rdi
callq 0x3300
movq 0x58(%rsp), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x32b0
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 0x5999(%rip), %rsi      # 0x17cc7
movl $0x1, %edx
movq %rax, %rdi
callq 0x3300
movq 0x20(%r14), %rsi
movq %rbx, %rdi
callq 0x31d0
movq %rax, %r15
leaq 0x55fe(%rip), %rsi      # 0x1794f
movl $0x4, %edx
movq %rax, %rdi
callq 0x3300
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x32b0
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
je 0x123cb
movq %rax, %rsi
jmp 0x123ef
leaq -0x4(,%rdx,4), %rdx
movss (%rcx), %xmm0
ucomiss (%rax), %xmm0
movq %rcx, %rsi
ja 0x123e2
movq %rax, %rsi
addq $0x4, %rcx
movq %rsi, %rax
addq $-0x4, %rdx
jne 0x123d3
movq %r14, 0x8(%rsp)
movss (%rsi), %xmm1
movss 0x4d60(%rip), %xmm0     # 0x17160
movss %xmm1, (%rsp)
addss %xmm1, %xmm0
mulss 0x4d53(%rip), %xmm0     # 0x17164
cvttss2si %xmm0, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subss 0x4d2b(%rip), %xmm0     # 0x17150
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 0x12bc8
movq $0x1, 0x18(%rsp)
movq 0xab6e(%rip), %rdi      # 0x1cfc8
leaq 0x54f3(%rip), %rsi      # 0x17954
movl $0x7, %edx
callq 0x3300
xorps %xmm0, %xmm0
cvtss2sd (%rsp), %xmm0
movq 0xab4e(%rip), %rdi      # 0x1cfc8
callq 0x33d0
movq %rax, %r15
leaq 0x54d3(%rip), %rsi      # 0x1795c
movl $0x7, %edx
movq %rax, %rdi
callq 0x3300
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x32b0
movsbl %al, %esi
movq %r15, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31e0
movss (%rsp), %xmm0
ucomiss 0x4c97(%rip), %xmm0     # 0x17160
jae 0x1269d
movq 0x8(%rsp), %rdi
cmpq $0x0, 0x20(%rdi)
je 0x125fa
xorl %r12d, %r12d
leaq 0x57de(%rip), %r13      # 0x17cc7
cmpq $0x0, 0x18(%rdi)
je 0x125b8
xorl %ebp, %ebp
movq %rbp, %rsi
movq %r12, %rdx
movq 0x10(%rsp), %rcx
callq 0xf418
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 0x12891
leal 0x1(%rcx), %eax
cltq
cmpq %rax, %rdx
jbe 0x1289f
addl $0x2, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rdx
jbe 0x12880
movl (%rdi,%rsi,4), %esi
movl (%rdi,%rax,4), %ebx
movl (%rdi,%rcx,4), %r15d
leaq 0x58(%rsp), %rdi
callq 0x3430
movq %rax, %r14
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x3300
movq %r14, %rdi
movl %ebx, %esi
callq 0x3430
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x3300
movq %rbx, %rdi
movl %r15d, %esi
callq 0x3430
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x3300
incq %rbp
movq 0x8(%rsp), %rdi
cmpq 0x18(%rdi), %rbp
jne 0x124f6
movq 0x58(%rsp), %rax
movq -0x18(%rax), %rdi
leaq 0x58(%rsp), %rax
addq %rax, %rdi
movl $0xa, %esi
callq 0x32b0
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 0x124e9
leaq 0x58(%rsp), %rdi
callq 0x3370
movq 0xa9bd(%rip), %rbx      # 0x1cfc8
leaq 0x52bb(%rip), %rsi      # 0x178cd
movl $0x5, %edx
movq %rbx, %rdi
callq 0x3300
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x32b0
movsbl %al, %esi
movq 0xa98b(%rip), %rdi      # 0x1cfc8
callq 0x3040
movq %rax, %rdi
callq 0x31e0
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x12659
callq 0x3290
movq 0xa958(%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 0x3260
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 0x4ab5(%rip), %r13      # 0x1716c
xorl %ebp, %ebp
movl %ebp, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
mulsd 0x49bd(%rip), %xmm0     # 0x17088
movapd %xmm0, 0x40(%rsp)
movq %r12, %rdi
callq 0x12d3b
movsd %xmm0, 0x20(%rsp)
movq %r12, %rdi
callq 0x12d3b
xorps %xmm1, %xmm1
movsd 0x20(%rsp), %xmm6
addsd %xmm1, %xmm6
addsd %xmm1, %xmm0
movsd 0x4948(%rip), %xmm2     # 0x17048
mulsd %xmm2, %xmm6
addsd %xmm2, %xmm6
mulsd 0x4980(%rip), %xmm0     # 0x17090
addsd 0x4980(%rip), %xmm0     # 0x17098
ucomisd %xmm6, %xmm1
movsd 0x492c(%rip), %xmm5     # 0x17050
jae 0x127ac
movsd 0x4976(%rip), %xmm1     # 0x170a8
movapd 0x40(%rsp), %xmm3
cmpnlesd %xmm3, %xmm1
divsd 0x495b(%rip), %xmm3     # 0x170a0
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 0x1286f
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 0x127b8
movapd %xmm0, %xmm2
movapd %xmm0, %xmm3
movapd %xmm0, %xmm1
incl %ebp
cmpl $0xf, %ebp
cmovael %ebx, %ebp
movsd 0x48e8(%rip), %xmm0     # 0x170b0
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 0x12802
xorps %xmm0, %xmm0
cvtsi2ss %r15, %xmm0
jmp 0x1281d
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 0x126b9
jmp 0x124cf
movapd %xmm5, %xmm2
movapd %xmm1, %xmm3
jmp 0x127b4
movapd %xmm1, %xmm2
movapd %xmm0, %xmm3
movapd %xmm5, %xmm1
jmp 0x127b8
movapd %xmm1, %xmm2
movapd %xmm4, %xmm3
jmp 0x127b4
movapd %xmm4, %xmm2
movapd %xmm0, %xmm3
jmp 0x127b8
movapd %xmm0, %xmm2
movapd %xmm1, %xmm3
movapd %xmm4, %xmm1
jmp 0x127b8
leaq 0x4ee2(%rip), %rdi      # 0x17769
movq %rcx, %rsi
xorl %eax, %eax
callq 0x33a0
leaq 0x4ed1(%rip), %rdi      # 0x17769
xorl %eax, %eax
callq 0x33a0
leaq 0x4ec3(%rip), %rdi      # 0x17769
movq %rax, %rsi
xorl %eax, %eax
callq 0x33a0
jmp 0x128b6
jmp 0x128c7
jmp 0x128c7
movq %rax, %rbx
jmp 0x128d9
jmp 0x128c7
jmp 0x128c7
jmp 0x128c7
jmp 0x128c7
jmp 0x128c7
jmp 0x128c7
movq %rax, %rbx
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x128d9
callq 0x3290
leaq 0x58(%rsp), %rdi
callq 0x3390
movq %rbx, %rdi
callq 0x3440
nop