// File: /workspace/github_c_makefile_star2_O2/containers[P]conmon/src/ctr_logging.c
// Function: configure_log_drivers
void configure_log_drivers(gchar **log_drivers, int64_t log_size_max_, int64_t log_global_size_max_, char *cuuid_, char *name_, char *tag,
			   gchar **log_labels)
{
	log_size_max = log_size_max_;
	log_global_size_max = log_global_size_max_;
	if (log_drivers == NULL)
		nexit("Log driver not provided. Use --log-path");
	for (int driver = 0; log_drivers[driver]; ++driver) {
		parse_log_path(log_drivers[driver]);
	}
	if (use_k8s_logging) {
		/* Open the log path file. */
		k8s_log_fd = open(k8s_log_path, O_WRONLY | O_APPEND | O_CREAT | O_CLOEXEC, 0640);
		if (k8s_log_fd < 0)
			pexit("Failed to open log file");

		struct stat statbuf;
		if (fstat(k8s_log_fd, &statbuf) == 0) {
			k8s_bytes_written = statbuf.st_size;
		} else {
			nwarnf("Could not stat log file %s, assuming 0 size", k8s_log_path);
			k8s_bytes_written = 0;
		}
		k8s_total_bytes_written = k8s_bytes_written;

		if (!use_journald_logging) {
			if (tag) {
				nexit("k8s-file doesn't support --log-tag");
			}
			if (log_labels) {
				nexit("k8s-file doesn't support --log-label");
			}
		}
	}

	if (use_journald_logging) {
#ifndef USE_JOURNALD
		nexit("Include journald in compilation path to log to systemd journal");
#endif
		/* save the length so we don't have to compute every sd_journal_* call */
		if (cuuid_ == NULL)
			nexit("Container ID must be provided and of the correct length");
		cuuid_len = strlen(cuuid_);
		if (cuuid_len <= TRUNC_ID_LEN)
			nexit("Container ID must be longer than 12 characters");

		cuuid = cuuid_;
		strncpy(short_cuuid, cuuid, TRUNC_ID_LEN);
		short_cuuid[TRUNC_ID_LEN] = '\0';
		name = name_;

		/* Setup some sd_journal_sendv arguments that won't change */
		container_id_full = g_strdup_printf("CONTAINER_ID_FULL=%s", cuuid);
		container_id = g_strdup_printf("CONTAINER_ID=%s", short_cuuid);

		/* Priority order of syslog_identifier (in order of precedence) is tag, name, `conmon`. */
		syslog_identifier = g_strdup_printf("SYSLOG_IDENTIFIER=%s", short_cuuid);
		syslog_identifier_len = TRUNC_ID_LEN + SYSLOG_IDENTIFIER_EQ_LEN;
		if (name) {
			name_len = strlen(name);
			container_name = g_strdup_printf("CONTAINER_NAME=%s", name);

			g_free(syslog_identifier);
			syslog_identifier = g_strdup_printf("SYSLOG_IDENTIFIER=%s", name);
			syslog_identifier_len = name_len + SYSLOG_IDENTIFIER_EQ_LEN;
		}
		if (tag) {
			container_tag = g_strdup_printf("CONTAINER_TAG=%s", tag);
			container_tag_len = strlen(container_tag);

			g_free(syslog_identifier);
			syslog_identifier = g_strdup_printf("SYSLOG_IDENTIFIER=%s", tag);
			syslog_identifier_len = strlen(syslog_identifier);
		}
		if (log_labels) {
			container_labels = log_labels;

			/* Ensure that valid LABEL=VALUE pairs have been passed */
			for (char **ptr = log_labels; *ptr; ptr++) {
				if (**ptr == '=') {
					nexitf("Container labels must be in format LABEL=VALUE (no LABEL present in '%s')", *ptr);
				}
				if (count_chars_in_string(*ptr, '=') != 1) {
					nexitf("Container labels must be in format LABEL=VALUE (none or more than one '=' present in '%s')",
					       *ptr);
				}
				if (!is_valid_label_name(*ptr)) {
					nexitf("Container label names must contain only uppercase letters, numbers and underscore (in '%s')",
					       *ptr);
				}
			}
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rsi, 0xdda8(%rip)      # 0x14490
movq %rdx, 0xdda9(%rip)      # 0x14498
testq %rdi, %rdi
je 0x68e2
movq %rdi, %r14
movq %r9, (%rsp)
leaq 0x7439(%rip), %r15      # 0xdb3f
movq (%r14), %r13
testq %r13, %r13
je 0x682f
movq %r13, %rdi
pushq $0x3a
popq %rsi
callq 0x4560
movq %rax, %rbp
movq %r13, %rdi
movq %r15, %rsi
callq 0x4650
movq %rax, %rbx
xorl %edi, %edi
movq %r15, %rsi
callq 0x4650
movq %rax, %rcx
orq %rbx, %rcx
je 0x692e
cmpq %r13, %rbp
movl $0x0, %r12d
cmoveq %rbx, %r12
movq %rbx, %r13
leaq 0x7441(%rip), %rcx      # 0xdb9c
cmoveq %rcx, %r13
testq %rax, %rax
cmovneq %rbx, %r13
cmovneq %rax, %r12
movq %r13, %rdi
leaq 0x7431(%rip), %rsi      # 0xdba5
callq 0x4620
testl %eax, %eax
je 0x6826
movq %r13, %rdi
leaq 0x68e3(%rip), %rsi      # 0xd06e
callq 0x4620
testl %eax, %eax
je 0x6826
movq %r13, %rdi
leaq 0x7407(%rip), %rsi      # 0xdba9
callq 0x4620
testl %eax, %eax
je 0x6826
movq %r13, %rdi
leaq 0x73f9(%rip), %rsi      # 0xdbae
callq 0x4620
testl %eax, %eax
je 0x67fd
movq %r13, %rdi
leaq 0x73f2(%rip), %rsi      # 0xdbba
callq 0x4620
testl %eax, %eax
je 0x6806
movq %r13, %rdi
leaq 0x73c1(%rip), %rsi      # 0xdb9c
callq 0x4620
testl %eax, %eax
je 0x680f
orq %rbp, %r12
jne 0x6b06
movb $0x1, 0x1e690(%rip)     # 0x24e84
movq %r13, 0x1e68d(%rip)     # 0x24e88
jmp 0x6826
movb $0x1, 0x1e67c(%rip)     # 0x24e80
jmp 0x6826
movb $0x1, 0x1e693(%rip)     # 0x24ea0
jmp 0x6826
testq %r12, %r12
je 0x6b4d
movb $0x1, 0x1e665(%rip)     # 0x24e84
movq %r12, 0x1e662(%rip)     # 0x24e88
addq $0x8, %r14
jmp 0x6706
cmpb $0x0, 0x1e64e(%rip)     # 0x24e84
je 0x6886
movq 0x1e649(%rip), %rdi     # 0x24e88
movl $0x80441, %esi          # imm = 0x80441
movl $0x1a0, %edx            # imm = 0x1A0
xorl %eax, %eax
callq 0x48d0
movl %eax, 0xdc4a(%rip)      # 0x144a0
testl %eax, %eax
js 0x69c6
leaq 0x8(%rsp), %rsi
movl %eax, %edi
callq 0x41f0
testl %eax, %eax
je 0x6894
leaq 0xdc2f(%rip), %rax      # 0x144a4
cmpl $0x0, (%rax)
movq (%rsp), %r14
jne 0x6aac
xorl %ebx, %ebx
jmp 0x689d
cmpb $0x0, 0x1e613(%rip)     # 0x24ea0
je 0x68d0
jmp 0x697a
movq 0x38(%rsp), %rbx
movq (%rsp), %r14
movq %rbx, 0x1e5ec(%rip)     # 0x24e90
movq %rbx, 0x1e5ed(%rip)     # 0x24e98
cmpb $0x1, 0x1e5ee(%rip)     # 0x24ea0
je 0x697a
testq %r14, %r14
jne 0x6a12
cmpq $0x0, 0xd0(%rsp)
jne 0x6a57
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xd707(%rip), %rax      # 0x13ff0
movq (%rax), %rdi
leaq 0x6d2e(%rip), %rsi      # 0xd621
leaq 0x7076(%rip), %rdx      # 0xd970
xorl %eax, %eax
callq 0x4830
leaq 0x225d0(%rip), %rax     # 0x28ed8
cmpl $0x0, (%rax)
je 0x6aa4
leaq 0x225b8(%rip), %rax     # 0x28ed0
movq (%rax), %rdx
leaq 0x6d2e(%rip), %rsi      # 0xd650
leaq 0x7047(%rip), %rcx      # 0xd970
jmp 0x6a9a
movq 0xd6bb(%rip), %rax      # 0x13ff0
movq (%rax), %rcx
leaq 0x7202(%rip), %rdi      # 0xdb41
pushq $0x27
popq %rsi
pushq $0x1
popq %rdx
callq 0x4800
leaq 0x22587(%rip), %rax     # 0x28ed8
cmpl $0x0, (%rax)
je 0x6aa4
leaq 0x2256f(%rip), %rax     # 0x28ed0
movq (%rax), %rdx
leaq 0x71fe(%rip), %rsi      # 0xdb69
pushq $0x3
popq %rdi
xorl %eax, %eax
callq 0x4120
jmp 0x6aa4
movq 0xd66f(%rip), %rax      # 0x13ff0
movq (%rax), %rdi
leaq 0x6c96(%rip), %rsi      # 0xd621
leaq 0x70e3(%rip), %rdx      # 0xda75
xorl %eax, %eax
callq 0x4830
leaq 0x22538(%rip), %rax     # 0x28ed8
cmpl $0x0, (%rax)
je 0x6aa4
leaq 0x22520(%rip), %rax     # 0x28ed0
movq (%rax), %rdx
leaq 0x6c96(%rip), %rsi      # 0xd650
leaq 0x70b4(%rip), %rcx      # 0xda75
jmp 0x6a9a
movq 0xd623(%rip), %rax      # 0x13ff0
movq (%rax), %rdi
leaq 0x663c(%rip), %rsi      # 0xd013
leaq 0x6fba(%rip), %rdx      # 0xd998
xorl %eax, %eax
callq 0x4830
leaq 0x224ec(%rip), %rax     # 0x28ed8
cmpl $0x0, (%rax)
je 0x6aa4
leaq 0x224d4(%rip), %rax     # 0x28ed0
movq (%rax), %rdx
leaq 0x6637(%rip), %rsi      # 0xd03d
leaq 0x6f8b(%rip), %rcx      # 0xd998
jmp 0x6a9a
movq 0xd5d7(%rip), %rax      # 0x13ff0
movq (%rax), %rdi
leaq 0x6bfe(%rip), %rsi      # 0xd621
leaq 0x7003(%rip), %rdx      # 0xda2d
xorl %eax, %eax
callq 0x4830
leaq 0x224a0(%rip), %rax     # 0x28ed8
cmpl $0x0, (%rax)
je 0x6aa4
leaq 0x2248c(%rip), %rax     # 0x28ed0
movq (%rax), %rdx
leaq 0x6c02(%rip), %rsi      # 0xd650
leaq 0x6fd8(%rip), %rcx      # 0xda2d
jmp 0x6a9a
movq 0xd592(%rip), %rax      # 0x13ff0
movq (%rax), %rdi
leaq 0x6bb9(%rip), %rsi      # 0xd621
leaq 0x6fe1(%rip), %rdx      # 0xda50
xorl %eax, %eax
callq 0x4830
leaq 0x2245b(%rip), %rax     # 0x28ed8
cmpl $0x0, (%rax)
je 0x6aa4
leaq 0x22447(%rip), %rax     # 0x28ed0
movq (%rax), %rdx
leaq 0x6bbd(%rip), %rsi      # 0xd650
leaq 0x6fb6(%rip), %rcx      # 0xda50
pushq $0x3
popq %rdi
xorl %eax, %eax
callq 0x4120
pushq $0x1
popq %rdi
callq 0x41e0
movq 0xd53d(%rip), %rax      # 0x13ff0
movq (%rax), %rdi
movq 0x1e3cb(%rip), %rdx     # 0x24e88
leaq 0x6eec(%rip), %rsi      # 0xd9b0
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x4830
leaq 0x22404(%rip), %rax     # 0x28ed8
cmpl $0x0, (%rax)
je 0x689d
leaq 0x223ec(%rip), %rax     # 0x28ed0
movq (%rax), %rdx
movq 0x1e39a(%rip), %rcx     # 0x24e88
leaq 0x6ef4(%rip), %rsi      # 0xd9e9
xorl %ebx, %ebx
pushq $0x6
popq %rdi
xorl %eax, %eax
callq 0x4120
jmp 0x689d
movq 0xd4e3(%rip), %rax      # 0x13ff0
movq (%rax), %rdi
leaq 0x710b(%rip), %rsi      # 0xdc22
movq %r13, %rdx
xorl %eax, %eax
callq 0x4830
leaq 0x223b0(%rip), %rax     # 0x28ed8
cmpl $0x0, (%rax)
je 0x6aa4
leaq 0x22398(%rip), %rax     # 0x28ed0
movq (%rax), %rdx
leaq 0x7103(%rip), %rsi      # 0xdc45
pushq $0x3
popq %rdi
movq %r13, %rcx
jmp 0x6a9d
movq 0xd49c(%rip), %rax      # 0x13ff0
movq (%rax), %rcx
leaq 0x7065(%rip), %rdi      # 0xdbc3
pushq $0x29
popq %rsi
pushq $0x1
popq %rdx
callq 0x4800
leaq 0x22368(%rip), %rax     # 0x28ed8
cmpl $0x0, (%rax)
je 0x6aa4
leaq 0x22350(%rip), %rax     # 0x28ed0
movq (%rax), %rdx
leaq 0x7063(%rip), %rsi      # 0xdbed
jmp 0x696b