// File: /workspace/github_c_makefile_star2_O0/containers[P]conmon/src/ctr_logging.c
// Function: set_k8s_timestamp
static void set_k8s_timestamp(char *buf, ssize_t buflen, const char *pipename)
{
	static int tzset_called = 0;

	/* Initialize timestamp variables with sensible defaults. */
	struct timespec ts = {0};
	struct tm current_tm = {0};
	char off_sign = '+';
	int off = 0;

	/* Attempt to get the current time. */
	if (clock_gettime(CLOCK_REALTIME, &ts) < 0) {
		if (errno != EINVAL) {
			ts.tv_nsec = 0; /* If other errors, fallback to nanoseconds = 0. */
		}
	}

	/* Ensure tzset is called only once. */
	if (!tzset_called) {
		tzset();
		tzset_called = 1;
	}

	/* Get the local time or fallback to defaults. */
	if (localtime_r(&ts.tv_sec, &current_tm) == NULL) {
		current_tm.tm_year = 70; /* 1970 (default epoch year) */
		current_tm.tm_mon = 0;	 /* January */
		current_tm.tm_mday = 1;	 /* 1st day of the month */
		current_tm.tm_hour = 0;	 /* midnight */
		current_tm.tm_min = 0;
		current_tm.tm_sec = 0;
		current_tm.tm_gmtoff = 0; /* UTC offset */
	}

	/* Calculate timezone offset. */
	off = (int)current_tm.tm_gmtoff;
	if (off < 0) {
		off_sign = '-';
		off = -off;
	}

	/* Format the timestamp into the buffer. */
	int len = snprintf(buf, buflen, "%d-%02d-%02dT%02d:%02d:%02d.%09ld%c%02d:%02d %s ", current_tm.tm_year + 1900,
			   current_tm.tm_mon + 1, current_tm.tm_mday, current_tm.tm_hour, current_tm.tm_min, current_tm.tm_sec, ts.tv_nsec,
			   off_sign, off / 3600, (off % 3600) / 60, pipename);

	/* Ensure null termination if snprintf output exceeds buffer length. */
	if (len >= buflen && buflen > 0) {
		buf[buflen - 1] = '\0';
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rdi, -0x30(%rbp)
movq %rsi, -0x38(%rbp)
movq %rdx, -0x40(%rbp)
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x40b0
leaq -0x88(%rbp), %rdi
xorl %esi, %esi
movl $0x38, %edx
callq 0x40b0
movb $0x2b, -0x89(%rbp)
movl $0x0, -0x90(%rbp)
xorl %edi, %edi
leaq -0x50(%rbp), %rsi
callq 0x4180
cmpl $0x0, %eax
jge 0x86d8
callq 0x45c0
cmpl $0x16, (%rax)
je 0x86d6
movq $0x0, -0x48(%rbp)
jmp 0x86d8
cmpl $0x0, 0x22859(%rip)     # 0x2af38
jne 0x86f0
callq 0x4320
movl $0x1, 0x22848(%rip)     # 0x2af38
leaq -0x50(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x4720
cmpq $0x0, %rax
jne 0x873e
movl $0x46, -0x74(%rbp)
movl $0x0, -0x78(%rbp)
movl $0x1, -0x7c(%rbp)
movl $0x0, -0x80(%rbp)
movl $0x0, -0x84(%rbp)
movl $0x0, -0x88(%rbp)
movq $0x0, -0x60(%rbp)
movq -0x60(%rbp), %rax
movl %eax, -0x90(%rbp)
cmpl $0x0, -0x90(%rbp)
jge 0x8766
movb $0x2d, -0x89(%rbp)
xorl %eax, %eax
subl -0x90(%rbp), %eax
movl %eax, -0x90(%rbp)
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
movl -0x74(%rbp), %ecx
addl $0x76c, %ecx            # imm = 0x76C
movl -0x78(%rbp), %r8d
addl $0x1, %r8d
movl -0x7c(%rbp), %r9d
movl -0x80(%rbp), %r13d
movl -0x84(%rbp), %r12d
movl -0x88(%rbp), %r15d
movq -0x48(%rbp), %r14
movsbl -0x89(%rbp), %ebx
movl -0x90(%rbp), %eax
movl $0xe10, %r10d           # imm = 0xE10
cltd
idivl %r10d
movl %eax, %r11d
movl -0x90(%rbp), %eax
movl $0xe10, %r10d           # imm = 0xE10
cltd
idivl %r10d
movl %edx, %eax
movl $0x3c, %r10d
cltd
idivl %r10d
movl %eax, %r10d
movq -0x40(%rbp), %rax
leaq 0x791f(%rip), %rdx      # 0x100fc
movl %r13d, (%rsp)
movl %r12d, 0x8(%rsp)
movl %r15d, 0x10(%rsp)
movq %r14, 0x18(%rsp)
movl %ebx, 0x20(%rsp)
movl %r11d, 0x28(%rsp)
movl %r10d, 0x30(%rsp)
movq %rax, 0x38(%rsp)
movb $0x0, %al
callq 0x40c0
movl %eax, -0x94(%rbp)
movslq -0x94(%rbp), %rax
cmpq -0x38(%rbp), %rax
jl 0x8834
cmpq $0x0, -0x38(%rbp)
jle 0x8834
movq -0x30(%rbp), %rax
movq -0x38(%rbp), %rcx
subq $0x1, %rcx
movb $0x0, (%rax,%rcx)
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopw %cs:(%rax,%rax)