#include <string>
/*

struct PointCloud {
    utility::device_vector<Eigen::Vector3f> points_;
};

namespace ply_pointcloud_reader {

    struct PLYReaderState {
        utility::ConsoleProgressBar *progress_bar;
        HostPointCloud *pointcloud_ptr;
        long vertex_index;
        long vertex_num;
        long normal_index;
        long normal_num;
        long color_index;
        long color_num;
    };

    int ReadVertexCallback(p_ply_argument argument) {
        PLYReaderState *state_ptr;
        long index;
        ply_get_argument_user_data(argument, reinterpret_cast<void **>(&state_ptr),
                                   &index);
        if (state_ptr->vertex_index >= state_ptr->vertex_num) {
            return 0;  // some sanity check
        }

        float value = ply_get_argument_value(argument);
        state_ptr->pointcloud_ptr->points_[state_ptr->vertex_index](index) = value;
        if (index == 2) {  // reading 'z'
            state_ptr->vertex_index++;
            ++(*state_ptr->progress_bar);
        }
        return 1;
    }

    int ReadNormalCallback(p_ply_argument argument) {
        PLYReaderState *state_ptr;
        long index;
        ply_get_argument_user_data(argument, reinterpret_cast<void **>(&state_ptr),
                                   &index);
        if (state_ptr->normal_index >= state_ptr->normal_num) {
            return 0;
        }

        float value = ply_get_argument_value(argument);
        state_ptr->pointcloud_ptr->normals_[state_ptr->normal_index](index) = value;
        if (index == 2) {  // reading 'nz'
            state_ptr->normal_index++;
        }
        return 1;
    }

    int ReadColorCallback(p_ply_argument argument) {
        PLYReaderState *state_ptr;
        long index;
        ply_get_argument_user_data(argument, reinterpret_cast<void **>(&state_ptr),
                                   &index);
        if (state_ptr->color_index >= state_ptr->color_num) {
            return 0;
        }

        float value = ply_get_argument_value(argument);
        state_ptr->pointcloud_ptr->colors_[state_ptr->color_index](index) =
                value / 255.0;
        if (index == 2) {  // reading 'blue'
            state_ptr->color_index++;
        }
        return 1;
    }

}  // namespace ply_pointcloud_reader

bool ReadPointCloudFromPLY(const std::string &filename,
                           PointCloud &pointcloud,
                           bool print_progress = false);

bool ReadPointCloudFromPLY(const std::string &filename,
                           geometry::PointCloud &pointcloud,
                           bool print_progress) {
    using namespace ply_pointcloud_reader;

    p_ply ply_file = ply_open(filename.c_str(), NULL, 0, NULL);
    if (!ply_file) {
        utility::LogWarning("Read PLY failed: unable to open file: %s",
                            filename.c_str());
        return false;
    }
    if (!ply_read_header(ply_file)) {
        utility::LogWarning("Read PLY failed: unable to parse header.");
        ply_close(ply_file);
        return false;
    }

    PLYReaderState state;
    HostPointCloud host_pc;
    state.pointcloud_ptr = &host_pc;
    state.vertex_num = ply_set_read_cb(ply_file, "vertex", "x",
                                       ReadVertexCallback, &state, 0);
    ply_set_read_cb(ply_file, "vertex", "y", ReadVertexCallback, &state, 1);
    ply_set_read_cb(ply_file, "vertex", "z", ReadVertexCallback, &state, 2);

    state.normal_num = ply_set_read_cb(ply_file, "vertex", "nx",
                                       ReadNormalCallback, &state, 0);
    ply_set_read_cb(ply_file, "vertex", "ny", ReadNormalCallback, &state, 1);
    ply_set_read_cb(ply_file, "vertex", "nz", ReadNormalCallback, &state, 2);

    state.color_num = ply_set_read_cb(ply_file, "vertex", "red",
                                      ReadColorCallback, &state, 0);
    ply_set_read_cb(ply_file, "vertex", "green", ReadColorCallback, &state, 1);
    ply_set_read_cb(ply_file, "vertex", "blue", ReadColorCallback, &state, 2);

    if (state.vertex_num <= 0) {
        utility::LogWarning("Read PLY failed: number of vertex <= 0.");
        ply_close(ply_file);
        return false;
    }

    state.vertex_index = 0;
    state.normal_index = 0;
    state.color_index = 0;

    host_pc.Clear();
    host_pc.points_.resize(state.vertex_num);
    host_pc.normals_.resize(state.normal_num);
    host_pc.colors_.resize(state.color_num);

    utility::ConsoleProgressBar progress_bar(state.vertex_num + 1,
                                             "Reading PLY: ", print_progress);
    state.progress_bar = &progress_bar;

    if (!ply_read(ply_file)) {
        utility::LogWarning("Read PLY failed: unable to read file: {}",
                            filename);
        ply_close(ply_file);
        return false;
    }

    ply_close(ply_file);
    ++progress_bar;
    host_pc.ToDevice(pointcloud);
    return true;
}
*/
int main() {

}
	.file	"tmpxft_002cf804_00000000-6_01_read_ply.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3026:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3026:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB3023:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
	ret
	.cfi_endproc
.LFE3023:
	.size	main, .-main
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3049:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	movq	%rax, %rdi
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE3049:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:


#include <hip/hip_runtime.h>
#include <string>
/*

struct PointCloud {
    utility::device_vector<Eigen::Vector3f> points_;
};

namespace ply_pointcloud_reader {

    struct PLYReaderState {
        utility::ConsoleProgressBar *progress_bar;
        HostPointCloud *pointcloud_ptr;
        long vertex_index;
        long vertex_num;
        long normal_index;
        long normal_num;
        long color_index;
        long color_num;
    };

    int ReadVertexCallback(p_ply_argument argument) {
        PLYReaderState *state_ptr;
        long index;
        ply_get_argument_user_data(argument, reinterpret_cast<void **>(&state_ptr),
                                   &index);
        if (state_ptr->vertex_index >= state_ptr->vertex_num) {
            return 0;  // some sanity check
        }

        float value = ply_get_argument_value(argument);
        state_ptr->pointcloud_ptr->points_[state_ptr->vertex_index](index) = value;
        if (index == 2) {  // reading 'z'
            state_ptr->vertex_index++;
            ++(*state_ptr->progress_bar);
        }
        return 1;
    }

    int ReadNormalCallback(p_ply_argument argument) {
        PLYReaderState *state_ptr;
        long index;
        ply_get_argument_user_data(argument, reinterpret_cast<void **>(&state_ptr),
                                   &index);
        if (state_ptr->normal_index >= state_ptr->normal_num) {
            return 0;
        }

        float value = ply_get_argument_value(argument);
        state_ptr->pointcloud_ptr->normals_[state_ptr->normal_index](index) = value;
        if (index == 2) {  // reading 'nz'
            state_ptr->normal_index++;
        }
        return 1;
    }

    int ReadColorCallback(p_ply_argument argument) {
        PLYReaderState *state_ptr;
        long index;
        ply_get_argument_user_data(argument, reinterpret_cast<void **>(&state_ptr),
                                   &index);
        if (state_ptr->color_index >= state_ptr->color_num) {
            return 0;
        }

        float value = ply_get_argument_value(argument);
        state_ptr->pointcloud_ptr->colors_[state_ptr->color_index](index) =
                value / 255.0;
        if (index == 2) {  // reading 'blue'
            state_ptr->color_index++;
        }
        return 1;
    }

}  // namespace ply_pointcloud_reader

bool ReadPointCloudFromPLY(const std::string &filename,
                           PointCloud &pointcloud,
                           bool print_progress = false);

bool ReadPointCloudFromPLY(const std::string &filename,
                           geometry::PointCloud &pointcloud,
                           bool print_progress) {
    using namespace ply_pointcloud_reader;

    p_ply ply_file = ply_open(filename.c_str(), NULL, 0, NULL);
    if (!ply_file) {
        utility::LogWarning("Read PLY failed: unable to open file: %s",
                            filename.c_str());
        return false;
    }
    if (!ply_read_header(ply_file)) {
        utility::LogWarning("Read PLY failed: unable to parse header.");
        ply_close(ply_file);
        return false;
    }

    PLYReaderState state;
    HostPointCloud host_pc;
    state.pointcloud_ptr = &host_pc;
    state.vertex_num = ply_set_read_cb(ply_file, "vertex", "x",
                                       ReadVertexCallback, &state, 0);
    ply_set_read_cb(ply_file, "vertex", "y", ReadVertexCallback, &state, 1);
    ply_set_read_cb(ply_file, "vertex", "z", ReadVertexCallback, &state, 2);

    state.normal_num = ply_set_read_cb(ply_file, "vertex", "nx",
                                       ReadNormalCallback, &state, 0);
    ply_set_read_cb(ply_file, "vertex", "ny", ReadNormalCallback, &state, 1);
    ply_set_read_cb(ply_file, "vertex", "nz", ReadNormalCallback, &state, 2);

    state.color_num = ply_set_read_cb(ply_file, "vertex", "red",
                                      ReadColorCallback, &state, 0);
    ply_set_read_cb(ply_file, "vertex", "green", ReadColorCallback, &state, 1);
    ply_set_read_cb(ply_file, "vertex", "blue", ReadColorCallback, &state, 2);

    if (state.vertex_num <= 0) {
        utility::LogWarning("Read PLY failed: number of vertex <= 0.");
        ply_close(ply_file);
        return false;
    }

    state.vertex_index = 0;
    state.normal_index = 0;
    state.color_index = 0;

    host_pc.Clear();
    host_pc.points_.resize(state.vertex_num);
    host_pc.normals_.resize(state.normal_num);
    host_pc.colors_.resize(state.color_num);

    utility::ConsoleProgressBar progress_bar(state.vertex_num + 1,
                                             "Reading PLY: ", print_progress);
    state.progress_bar = &progress_bar;

    if (!ply_read(ply_file)) {
        utility::LogWarning("Read PLY failed: unable to read file: {}",
                            filename);
        ply_close(ply_file);
        return false;
    }

    ply_close(ply_file);
    ++progress_bar;
    host_pc.ToDevice(pointcloud);
    return true;
}
*/
int main() {

}
	.text
	.file	"01_read_ply.hip"
	.globl	main                            # -- Begin function main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	xorl	%eax, %eax
	retq
.Lfunc_end0:
	.size	main, .Lfunc_end0-main
	.cfi_endproc
                                        # -- End function
	.type	__hip_cuid_,@object             # @__hip_cuid_
	.bss
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               # 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_

	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.amdgpu_metadata
---
amdhsa.kernels:  []
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
