#include "Logger.cuh"

#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include <time.h>

#define PREFIX_SIZE 256

// Do not change order. It matches the values of LOGGER_LEVEL_XXXXX
static char* level_name_by_level[] = { "ERROR", "WARN", "INFO", "DEBUG" };

static void logger_print(const char *log_name, unsigned int level, unsigned int level_message, char* fmt, va_list args) {

    if (level < level_message) return;

    // Create a "prefixed" format string, by appending the log level and the log name
    char* prefixed_fmt = (char*) malloc(PREFIX_SIZE + (strlen(log_name) + 1) + (strlen(fmt) + 1));
    char* log_level = level_name_by_level[level_message];
    time_t t = time(NULL);
    struct tm tm = *localtime(&t);

    sprintf(
        prefixed_fmt,
        "%02d/%02d/%04d %02d:%02d:%02d - [%5s] - %s - %s \n",
        tm.tm_mday, // day
        tm.tm_mon + 1, // month
        tm.tm_year + 1900, // year
        tm.tm_hour, tm.tm_min, tm.tm_sec, // hour:minutes:seconds
        log_level,
        log_name,
        fmt
    );

    vprintf(prefixed_fmt, args);

    free(prefixed_fmt);
}

Logger::Logger(char* name, unsigned int level) {
    unsigned int name_size = strlen(name) + 1;
    this->name = (char *) malloc(name_size * sizeof(char));
    strcpy(this->name, name);

    this->level = level;
}

void Logger::info(char* fmt, ...) {
    va_list args;
    va_start(args, fmt);
    logger_print(this->name, this->level, LOGGER_LEVEL_INFO, fmt, args);
    va_end(args);
}

void Logger::warn(char* fmt, ...) {
    va_list args;
    va_start(args, fmt);
    logger_print(this->name, this->level, LOGGER_LEVEL_WARN, fmt, args);
    va_end(args);
}

void Logger::error(char* fmt, ...) {
    va_list args;
    va_start(args, fmt);
    logger_print(this->name, this->level, LOGGER_LEVEL_ERROR, fmt, args);
    va_end(args);
}

void Logger::debug(char* fmt, ...) {
    va_list args;
    va_start(args, fmt);
    logger_print(this->name, this->level, LOGGER_LEVEL_DEBUG, fmt, args);
    va_end(args);
}

Logger::~Logger() {
    free(this->name);
}
	.file	"tmpxft_002e02f4_00000000-6_Logger.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2040:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2040:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%02d/%02d/%04d %02d:%02d:%02d - [%5s] - %s - %s \n"
	.text
	.type	_ZL12logger_printPKcjjPcP13__va_list_tag, @function
_ZL12logger_printPKcjjPcP13__va_list_tag:
.LFB2027:
	.cfi_startproc
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	%edx, %ebx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	cmpl	%ebx, %esi
	jb	.L2
	movq	%rcx, %r12
	movq	%r8, %r13
	movq	%rdi, %r15
	call	strlen@PLT
	movq	%r12, %rdi
	movq	%rax, %rbp
	call	strlen@PLT
	leaq	258(%rbp,%rax), %r14
	movq	%r14, %rdi
	call	malloc@PLT
	xorl	%edi, %edi
	movq	%rax, %rbp
	leaq	_ZL19level_name_by_level(%rip), %rax
	movq	(%rax,%rbx,8), %rbx
	call	time@PLT
	movq	%rsp, %rdi
	movq	%rax, (%rsp)
	call	localtime@PLT
	movl	$2, %esi
	movq	%rbp, %rdi
	movl	16(%rax), %edx
	movl	12(%rax), %r8d
	pushq	%rcx
	.cfi_def_cfa_offset 88
	pushq	%r12
	.cfi_def_cfa_offset 96
	pushq	%r15
	.cfi_def_cfa_offset 104
	leal	1(%rdx), %r9d
	movq	%r14, %rdx
	pushq	%rbx
	.cfi_def_cfa_offset 112
	movl	(%rax), %ecx
	pushq	%rcx
	.cfi_def_cfa_offset 120
	movl	4(%rax), %ecx
	pushq	%rcx
	.cfi_def_cfa_offset 128
	movl	8(%rax), %ecx
	pushq	%rcx
	.cfi_def_cfa_offset 136
	movl	20(%rax), %eax
	leaq	.LC0(%rip), %rcx
	addl	$1900, %eax
	pushq	%rax
	.cfi_def_cfa_offset 144
	xorl	%eax, %eax
	call	__sprintf_chk@PLT
	addq	$64, %rsp
	.cfi_def_cfa_offset 80
	movq	%r13, %rdx
	movq	%rbp, %rsi
	movl	$2, %edi
	call	__vprintf_chk@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L7
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	movq	%rbp, %rdi
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	free@PLT
.L2:
	.cfi_restore_state
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	je	.L5
.L7:
	call	__stack_chk_fail@PLT
.L5:
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2027:
	.size	_ZL12logger_printPKcjjPcP13__va_list_tag, .-_ZL12logger_printPKcjjPcP13__va_list_tag
	.align 2
	.globl	_ZN6LoggerC2EPcj
	.type	_ZN6LoggerC2EPcj, @function
_ZN6LoggerC2EPcj:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movl	%edx, %r12d
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movq	%rdi, %rbx
	movq	%rsi, %rdi
	subq	$16, %rsp
	.cfi_def_cfa_offset 48
	movq	%rsi, 8(%rsp)
	call	strlen@PLT
	leal	1(%rax), %r13d
	movq	%r13, %rdi
	call	malloc@PLT
	movq	8(%rsp), %rsi
	movq	%r13, %rdx
	movq	%rax, (%rbx)
	movq	%rax, %rdi
	call	__strcpy_chk@PLT
	movl	%r12d, 8(%rbx)
	addq	$16, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2029:
	.size	_ZN6LoggerC2EPcj, .-_ZN6LoggerC2EPcj
	.globl	_ZN6LoggerC1EPcj
	.set	_ZN6LoggerC1EPcj,_ZN6LoggerC2EPcj
	.align 2
	.globl	_ZN6Logger4infoEPcz
	.type	_ZN6Logger4infoEPcz, @function
_ZN6Logger4infoEPcz:
.LFB2031:
	.cfi_startproc
	endbr64
	subq	$216, %rsp
	.cfi_def_cfa_offset 224
	movq	%rdx, 48(%rsp)
	movq	%rcx, 56(%rsp)
	movq	%r8, 64(%rsp)
	movq	%r9, 72(%rsp)
	testb	%al, %al
	je	.L12
	movaps	%xmm0, 80(%rsp)
	movaps	%xmm1, 96(%rsp)
	movaps	%xmm2, 112(%rsp)
	movaps	%xmm3, 128(%rsp)
	movaps	%xmm4, 144(%rsp)
	movaps	%xmm5, 160(%rsp)
	movaps	%xmm6, 176(%rsp)
	movaps	%xmm7, 192(%rsp)
.L12:
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	movq	%rsi, %rcx
	leaq	224(%rsp), %rax
	movl	8(%rdi), %esi
	movq	(%rdi), %rdi
	movq	%rax, 8(%rsp)
	movq	%rsp, %r8
	leaq	32(%rsp), %rax
	movl	$2, %edx
	movq	%rax, 16(%rsp)
	movl	$16, (%rsp)
	movl	$48, 4(%rsp)
	call	_ZL12logger_printPKcjjPcP13__va_list_tag
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	je	.L13
	call	__stack_chk_fail@PLT
.L13:
	addq	$216, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2031:
	.size	_ZN6Logger4infoEPcz, .-_ZN6Logger4infoEPcz
	.align 2
	.globl	_ZN6Logger4warnEPcz
	.type	_ZN6Logger4warnEPcz, @function
_ZN6Logger4warnEPcz:
.LFB2032:
	.cfi_startproc
	endbr64
	subq	$216, %rsp
	.cfi_def_cfa_offset 224
	movq	%rdx, 48(%rsp)
	movq	%rcx, 56(%rsp)
	movq	%r8, 64(%rsp)
	movq	%r9, 72(%rsp)
	testb	%al, %al
	je	.L16
	movaps	%xmm0, 80(%rsp)
	movaps	%xmm1, 96(%rsp)
	movaps	%xmm2, 112(%rsp)
	movaps	%xmm3, 128(%rsp)
	movaps	%xmm4, 144(%rsp)
	movaps	%xmm5, 160(%rsp)
	movaps	%xmm6, 176(%rsp)
	movaps	%xmm7, 192(%rsp)
.L16:
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	movq	%rsi, %rcx
	leaq	224(%rsp), %rax
	movl	8(%rdi), %esi
	movq	(%rdi), %rdi
	movq	%rax, 8(%rsp)
	movq	%rsp, %r8
	leaq	32(%rsp), %rax
	movl	$1, %edx
	movq	%rax, 16(%rsp)
	movl	$16, (%rsp)
	movl	$48, 4(%rsp)
	call	_ZL12logger_printPKcjjPcP13__va_list_tag
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	addq	$216, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2032:
	.size	_ZN6Logger4warnEPcz, .-_ZN6Logger4warnEPcz
	.align 2
	.globl	_ZN6Logger5errorEPcz
	.type	_ZN6Logger5errorEPcz, @function
_ZN6Logger5errorEPcz:
.LFB2033:
	.cfi_startproc
	endbr64
	subq	$216, %rsp
	.cfi_def_cfa_offset 224
	movq	%rdx, 48(%rsp)
	movq	%rcx, 56(%rsp)
	movq	%r8, 64(%rsp)
	movq	%r9, 72(%rsp)
	testb	%al, %al
	je	.L20
	movaps	%xmm0, 80(%rsp)
	movaps	%xmm1, 96(%rsp)
	movaps	%xmm2, 112(%rsp)
	movaps	%xmm3, 128(%rsp)
	movaps	%xmm4, 144(%rsp)
	movaps	%xmm5, 160(%rsp)
	movaps	%xmm6, 176(%rsp)
	movaps	%xmm7, 192(%rsp)
.L20:
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	movq	%rsi, %rcx
	leaq	224(%rsp), %rax
	movl	8(%rdi), %esi
	movq	(%rdi), %rdi
	movq	%rax, 8(%rsp)
	xorl	%edx, %edx
	leaq	32(%rsp), %rax
	movq	%rsp, %r8
	movq	%rax, 16(%rsp)
	movl	$16, (%rsp)
	movl	$48, 4(%rsp)
	call	_ZL12logger_printPKcjjPcP13__va_list_tag
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	je	.L21
	call	__stack_chk_fail@PLT
.L21:
	addq	$216, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2033:
	.size	_ZN6Logger5errorEPcz, .-_ZN6Logger5errorEPcz
	.align 2
	.globl	_ZN6Logger5debugEPcz
	.type	_ZN6Logger5debugEPcz, @function
_ZN6Logger5debugEPcz:
.LFB2034:
	.cfi_startproc
	endbr64
	subq	$216, %rsp
	.cfi_def_cfa_offset 224
	movq	%rdx, 48(%rsp)
	movq	%rcx, 56(%rsp)
	movq	%r8, 64(%rsp)
	movq	%r9, 72(%rsp)
	testb	%al, %al
	je	.L24
	movaps	%xmm0, 80(%rsp)
	movaps	%xmm1, 96(%rsp)
	movaps	%xmm2, 112(%rsp)
	movaps	%xmm3, 128(%rsp)
	movaps	%xmm4, 144(%rsp)
	movaps	%xmm5, 160(%rsp)
	movaps	%xmm6, 176(%rsp)
	movaps	%xmm7, 192(%rsp)
.L24:
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	movq	%rsi, %rcx
	leaq	224(%rsp), %rax
	movl	8(%rdi), %esi
	movq	(%rdi), %rdi
	movq	%rax, 8(%rsp)
	movq	%rsp, %r8
	leaq	32(%rsp), %rax
	movl	$3, %edx
	movq	%rax, 16(%rsp)
	movl	$16, (%rsp)
	movl	$48, 4(%rsp)
	call	_ZL12logger_printPKcjjPcP13__va_list_tag
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	je	.L25
	call	__stack_chk_fail@PLT
.L25:
	addq	$216, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2034:
	.size	_ZN6Logger5debugEPcz, .-_ZN6Logger5debugEPcz
	.align 2
	.globl	_ZN6LoggerD2Ev
	.type	_ZN6LoggerD2Ev, @function
_ZN6LoggerD2Ev:
.LFB2036:
	.cfi_startproc
	endbr64
	movq	(%rdi), %rdi
	jmp	free@PLT
	.cfi_endproc
.LFE2036:
	.size	_ZN6LoggerD2Ev, .-_ZN6LoggerD2Ev
	.globl	_ZN6LoggerD1Ev
	.set	_ZN6LoggerD1Ev,_ZN6LoggerD2Ev
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2063:
	.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
.LFE2063:
	.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
	.section	.rodata.str1.1
.LC1:
	.string	"ERROR"
.LC2:
	.string	"WARN"
.LC3:
	.string	"INFO"
.LC4:
	.string	"DEBUG"
	.section	.data.rel.ro.local,"aw"
	.align 32
	.type	_ZL19level_name_by_level, @object
	.size	_ZL19level_name_by_level, 32
_ZL19level_name_by_level:
	.quad	.LC1
	.quad	.LC2
	.quad	.LC3
	.quad	.LC4
	.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 "Logger.cuh"

#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include <time.h>

#define PREFIX_SIZE 256

// Do not change order. It matches the values of LOGGER_LEVEL_XXXXX
static char* level_name_by_level[] = { "ERROR", "WARN", "INFO", "DEBUG" };

static void logger_print(const char *log_name, unsigned int level, unsigned int level_message, char* fmt, va_list args) {

    if (level < level_message) return;

    // Create a "prefixed" format string, by appending the log level and the log name
    char* prefixed_fmt = (char*) malloc(PREFIX_SIZE + (strlen(log_name) + 1) + (strlen(fmt) + 1));
    char* log_level = level_name_by_level[level_message];
    time_t t = time(NULL);
    struct tm tm = *localtime(&t);

    sprintf(
        prefixed_fmt,
        "%02d/%02d/%04d %02d:%02d:%02d - [%5s] - %s - %s \n",
        tm.tm_mday, // day
        tm.tm_mon + 1, // month
        tm.tm_year + 1900, // year
        tm.tm_hour, tm.tm_min, tm.tm_sec, // hour:minutes:seconds
        log_level,
        log_name,
        fmt
    );

    vprintf(prefixed_fmt, args);

    free(prefixed_fmt);
}

Logger::Logger(char* name, unsigned int level) {
    unsigned int name_size = strlen(name) + 1;
    this->name = (char *) malloc(name_size * sizeof(char));
    strcpy(this->name, name);

    this->level = level;
}

void Logger::info(char* fmt, ...) {
    va_list args;
    va_start(args, fmt);
    logger_print(this->name, this->level, LOGGER_LEVEL_INFO, fmt, args);
    va_end(args);
}

void Logger::warn(char* fmt, ...) {
    va_list args;
    va_start(args, fmt);
    logger_print(this->name, this->level, LOGGER_LEVEL_WARN, fmt, args);
    va_end(args);
}

void Logger::error(char* fmt, ...) {
    va_list args;
    va_start(args, fmt);
    logger_print(this->name, this->level, LOGGER_LEVEL_ERROR, fmt, args);
    va_end(args);
}

void Logger::debug(char* fmt, ...) {
    va_list args;
    va_start(args, fmt);
    logger_print(this->name, this->level, LOGGER_LEVEL_DEBUG, fmt, args);
    va_end(args);
}

Logger::~Logger() {
    free(this->name);
}
	.text
	.file	"Logger.hip"
	.globl	_ZN6LoggerC2EPcj                # -- Begin function _ZN6LoggerC2EPcj
	.p2align	1, 0x90
	.type	_ZN6LoggerC2EPcj,@function
_ZN6LoggerC2EPcj:                       # @_ZN6LoggerC2EPcj
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movl	%edx, %ebx
	movq	%rsi, %r14
	movq	%rdi, %r15
	movq	%rsi, %rdi
	callq	strlen
	leal	1(%rax), %edi
	callq	malloc
	movq	%rax, (%r15)
	movq	%rax, %rdi
	movq	%r14, %rsi
	callq	strcpy
	movl	%ebx, 8(%r15)
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_ZN6LoggerC2EPcj, .Lfunc_end0-_ZN6LoggerC2EPcj
	.cfi_endproc
                                        # -- End function
	.globl	_ZN6Logger4infoEPcz             # -- Begin function _ZN6Logger4infoEPcz
	.p2align	1, 0x90
	.type	_ZN6Logger4infoEPcz,@function
_ZN6Logger4infoEPcz:                    # @_ZN6Logger4infoEPcz
	.cfi_startproc
# %bb.0:
	subq	$216, %rsp
	.cfi_def_cfa_offset 224
	movq	%rsi, %r10
	leaq	32(%rsp), %rsi
	movq	%rdx, 16(%rsi)
	movq	%rcx, 24(%rsi)
	movq	%r8, 32(%rsi)
	movq	%r9, 40(%rsi)
	testb	%al, %al
	je	.LBB1_2
# %bb.1:
	movaps	%xmm0, 80(%rsp)
	movaps	%xmm1, 96(%rsp)
	movaps	%xmm2, 112(%rsp)
	movaps	%xmm3, 128(%rsp)
	movaps	%xmm4, 144(%rsp)
	movaps	%xmm5, 160(%rsp)
	movaps	%xmm6, 176(%rsp)
	movaps	%xmm7, 192(%rsp)
.LBB1_2:
	movq	%rsp, %r8
	movq	%rsi, 16(%r8)
	leaq	224(%rsp), %rax
	movq	%rax, 8(%r8)
	movabsq	$206158430224, %rax             # imm = 0x3000000010
	movq	%rax, (%r8)
	movq	(%rdi), %rax
	movl	8(%rdi), %esi
	movq	%rax, %rdi
	movl	$2, %edx
	movq	%r10, %rcx
	callq	_ZL12logger_printPKcjjPcP13__va_list_tag
	addq	$216, %rsp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	_ZN6Logger4infoEPcz, .Lfunc_end1-_ZN6Logger4infoEPcz
	.cfi_endproc
                                        # -- End function
	.type	_ZL12logger_printPKcjjPcP13__va_list_tag,@function # -- Begin function _ZL12logger_printPKcjjPcP13__va_list_tag
_ZL12logger_printPKcjjPcP13__va_list_tag: # @_ZL12logger_printPKcjjPcP13__va_list_tag
	.cfi_startproc
# %bb.0:
	cmpl	%edx, %esi
	jb	.LBB2_2
# %bb.1:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	pushq	%rax
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%r8, %rbx
	movq	%rcx, %r14
	movl	%edx, %ebp
	movq	%rdi, %r15
	callq	strlen
	movq	%rax, %r12
	movq	%r14, %rdi
	callq	strlen
	leaq	(%r12,%rax), %rdi
	addq	$258, %rdi                      # imm = 0x102
	callq	malloc
	movq	%rax, %r12
	movl	%ebp, %eax
	movq	_ZL19level_name_by_level(,%rax,8), %r13
	xorl	%edi, %edi
	callq	time
	movq	%rsp, %rdi
	movq	%rax, (%rdi)
	callq	localtime
	movl	(%rax), %r10d
	movl	4(%rax), %r11d
	movl	8(%rax), %r9d
	movl	12(%rax), %edx
	movl	16(%rax), %ecx
	incl	%ecx
	movl	$1900, %r8d                     # imm = 0x76C
	addl	20(%rax), %r8d
	subq	$8, %rsp
	.cfi_adjust_cfa_offset 8
	movl	$.L.str, %esi
	movq	%r12, %rdi
	xorl	%eax, %eax
	pushq	%r14
	.cfi_adjust_cfa_offset 8
	pushq	%r15
	.cfi_adjust_cfa_offset 8
	pushq	%r13
	.cfi_adjust_cfa_offset 8
	pushq	%r10
	.cfi_adjust_cfa_offset 8
	pushq	%r11
	.cfi_adjust_cfa_offset 8
	callq	sprintf
	addq	$48, %rsp
	.cfi_adjust_cfa_offset -48
	movq	%r12, %rdi
	movq	%rbx, %rsi
	callq	vprintf
	movq	%r12, %rdi
	callq	free
	addq	$8, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %r12
	.cfi_restore %r13
	.cfi_restore %r14
	.cfi_restore %r15
	.cfi_restore %rbp
.LBB2_2:
	retq
.Lfunc_end2:
	.size	_ZL12logger_printPKcjjPcP13__va_list_tag, .Lfunc_end2-_ZL12logger_printPKcjjPcP13__va_list_tag
	.cfi_endproc
                                        # -- End function
	.globl	_ZN6Logger4warnEPcz             # -- Begin function _ZN6Logger4warnEPcz
	.p2align	1, 0x90
	.type	_ZN6Logger4warnEPcz,@function
_ZN6Logger4warnEPcz:                    # @_ZN6Logger4warnEPcz
	.cfi_startproc
# %bb.0:
	subq	$216, %rsp
	.cfi_def_cfa_offset 224
	movq	%rsi, %r10
	leaq	32(%rsp), %rsi
	movq	%rdx, 16(%rsi)
	movq	%rcx, 24(%rsi)
	movq	%r8, 32(%rsi)
	movq	%r9, 40(%rsi)
	testb	%al, %al
	je	.LBB3_2
# %bb.1:
	movaps	%xmm0, 80(%rsp)
	movaps	%xmm1, 96(%rsp)
	movaps	%xmm2, 112(%rsp)
	movaps	%xmm3, 128(%rsp)
	movaps	%xmm4, 144(%rsp)
	movaps	%xmm5, 160(%rsp)
	movaps	%xmm6, 176(%rsp)
	movaps	%xmm7, 192(%rsp)
.LBB3_2:
	movq	%rsp, %r8
	movq	%rsi, 16(%r8)
	leaq	224(%rsp), %rax
	movq	%rax, 8(%r8)
	movabsq	$206158430224, %rax             # imm = 0x3000000010
	movq	%rax, (%r8)
	movq	(%rdi), %rax
	movl	8(%rdi), %esi
	movq	%rax, %rdi
	movl	$1, %edx
	movq	%r10, %rcx
	callq	_ZL12logger_printPKcjjPcP13__va_list_tag
	addq	$216, %rsp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end3:
	.size	_ZN6Logger4warnEPcz, .Lfunc_end3-_ZN6Logger4warnEPcz
	.cfi_endproc
                                        # -- End function
	.globl	_ZN6Logger5errorEPcz            # -- Begin function _ZN6Logger5errorEPcz
	.p2align	1, 0x90
	.type	_ZN6Logger5errorEPcz,@function
_ZN6Logger5errorEPcz:                   # @_ZN6Logger5errorEPcz
	.cfi_startproc
# %bb.0:
	subq	$216, %rsp
	.cfi_def_cfa_offset 224
	movq	%rsi, %r10
	leaq	32(%rsp), %rsi
	movq	%rdx, 16(%rsi)
	movq	%rcx, 24(%rsi)
	movq	%r8, 32(%rsi)
	movq	%r9, 40(%rsi)
	testb	%al, %al
	je	.LBB4_2
# %bb.1:
	movaps	%xmm0, 80(%rsp)
	movaps	%xmm1, 96(%rsp)
	movaps	%xmm2, 112(%rsp)
	movaps	%xmm3, 128(%rsp)
	movaps	%xmm4, 144(%rsp)
	movaps	%xmm5, 160(%rsp)
	movaps	%xmm6, 176(%rsp)
	movaps	%xmm7, 192(%rsp)
.LBB4_2:
	movq	%rsp, %r8
	movq	%rsi, 16(%r8)
	leaq	224(%rsp), %rax
	movq	%rax, 8(%r8)
	movabsq	$206158430224, %rax             # imm = 0x3000000010
	movq	%rax, (%r8)
	movq	(%rdi), %rax
	movl	8(%rdi), %esi
	movq	%rax, %rdi
	xorl	%edx, %edx
	movq	%r10, %rcx
	callq	_ZL12logger_printPKcjjPcP13__va_list_tag
	addq	$216, %rsp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end4:
	.size	_ZN6Logger5errorEPcz, .Lfunc_end4-_ZN6Logger5errorEPcz
	.cfi_endproc
                                        # -- End function
	.globl	_ZN6Logger5debugEPcz            # -- Begin function _ZN6Logger5debugEPcz
	.p2align	1, 0x90
	.type	_ZN6Logger5debugEPcz,@function
_ZN6Logger5debugEPcz:                   # @_ZN6Logger5debugEPcz
	.cfi_startproc
# %bb.0:
	subq	$216, %rsp
	.cfi_def_cfa_offset 224
	movq	%rsi, %r10
	leaq	32(%rsp), %rsi
	movq	%rdx, 16(%rsi)
	movq	%rcx, 24(%rsi)
	movq	%r8, 32(%rsi)
	movq	%r9, 40(%rsi)
	testb	%al, %al
	je	.LBB5_2
# %bb.1:
	movaps	%xmm0, 80(%rsp)
	movaps	%xmm1, 96(%rsp)
	movaps	%xmm2, 112(%rsp)
	movaps	%xmm3, 128(%rsp)
	movaps	%xmm4, 144(%rsp)
	movaps	%xmm5, 160(%rsp)
	movaps	%xmm6, 176(%rsp)
	movaps	%xmm7, 192(%rsp)
.LBB5_2:
	movq	%rsp, %r8
	movq	%rsi, 16(%r8)
	leaq	224(%rsp), %rax
	movq	%rax, 8(%r8)
	movabsq	$206158430224, %rax             # imm = 0x3000000010
	movq	%rax, (%r8)
	movq	(%rdi), %rax
	movl	8(%rdi), %esi
	movq	%rax, %rdi
	movl	$3, %edx
	movq	%r10, %rcx
	callq	_ZL12logger_printPKcjjPcP13__va_list_tag
	addq	$216, %rsp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end5:
	.size	_ZN6Logger5debugEPcz, .Lfunc_end5-_ZN6Logger5debugEPcz
	.cfi_endproc
                                        # -- End function
	.globl	_ZN6LoggerD2Ev                  # -- Begin function _ZN6LoggerD2Ev
	.p2align	1, 0x90
	.type	_ZN6LoggerD2Ev,@function
_ZN6LoggerD2Ev:                         # @_ZN6LoggerD2Ev
	.cfi_startproc
# %bb.0:
	movq	(%rdi), %rdi
	jmp	free                            # TAILCALL
.Lfunc_end6:
	.size	_ZN6LoggerD2Ev, .Lfunc_end6-_ZN6LoggerD2Ev
	.cfi_endproc
                                        # -- End function
	.type	_ZL19level_name_by_level,@object # @_ZL19level_name_by_level
	.section	.rodata,"a",@progbits
	.p2align	4, 0x0
_ZL19level_name_by_level:
	.quad	.L.str.1
	.quad	.L.str.2
	.quad	.L.str.3
	.quad	.L.str.4
	.size	_ZL19level_name_by_level, 32

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"%02d/%02d/%04d %02d:%02d:%02d - [%5s] - %s - %s \n"
	.size	.L.str, 50

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"ERROR"
	.size	.L.str.1, 6

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"WARN"
	.size	.L.str.2, 5

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"INFO"
	.size	.L.str.3, 5

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"DEBUG"
	.size	.L.str.4, 6

	.type	__hip_cuid_,@object             # @__hip_cuid_
	.bss
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               # 0x0
	.size	__hip_cuid_, 1

	.globl	_ZN6LoggerC1EPcj
	.type	_ZN6LoggerC1EPcj,@function
.set _ZN6LoggerC1EPcj, _ZN6LoggerC2EPcj
	.globl	_ZN6LoggerD1Ev
	.type	_ZN6LoggerD1Ev,@function
.set _ZN6LoggerD1Ev, _ZN6LoggerD2Ev
	.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
