// File: /workspace/github_c_makefile_star2_O3/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 $0xa8, %rsp
movq %r9, 0x8(%rsp)
movq %rsi, 0xc2b7(%rip)      # 0x15480
movq %rdx, 0xc2b8(%rip)      # 0x15488
testq %rdi, %rdi
je 0x93d3
movq %rdi, %r14
movq (%rdi), %r13
testq %r13, %r13
je 0x9319
addq $0x8, %r14
leaq 0x494c(%rip), %r15      # 0xdb3f
movq %r13, %rdi
movl $0x3a, %esi
callq 0x4550
movq %rax, %rbx
movq %r13, %rdi
movq %r15, %rsi
callq 0x4640
movq %rax, %rbp
xorl %edi, %edi
movq %r15, %rsi
callq 0x4640
movq %rax, %rcx
orq %rbp, %rcx
je 0x93c6
cmpq %r13, %rbx
movl $0x0, %r12d
cmoveq %rbp, %r12
movq %rbp, %r13
leaq 0x495e(%rip), %rcx      # 0xdb9c
cmoveq %rcx, %r13
testq %rax, %rax
cmovneq %rbp, %r13
cmovneq %rax, %r12
movq %r13, %rdi
leaq 0x494e(%rip), %rsi      # 0xdba5
callq 0x4610
testl %eax, %eax
je 0x9309
movq %r13, %rdi
leaq 0x3e00(%rip), %rsi      # 0xd06e
callq 0x4610
testl %eax, %eax
je 0x9309
movq %r13, %rdi
leaq 0x4924(%rip), %rsi      # 0xdba9
callq 0x4610
testl %eax, %eax
je 0x9309
movq %r13, %rdi
leaq 0x4916(%rip), %rsi      # 0xdbae
callq 0x4610
testl %eax, %eax
je 0x92e0
movq %r13, %rdi
leaq 0x490f(%rip), %rsi      # 0xdbba
callq 0x4610
testl %eax, %eax
je 0x92e9
movq %r13, %rdi
leaq 0x48de(%rip), %rsi      # 0xdb9c
callq 0x4610
testl %eax, %eax
je 0x92f2
orq %rbx, %r12
jne 0x93cb
movb $0x1, 0x1cb9d(%rip)     # 0x25e74
movq %r13, 0x1cb9a(%rip)     # 0x25e78
jmp 0x9309
movb $0x1, 0x1cb89(%rip)     # 0x25e70
jmp 0x9309
movb $0x1, 0x1cba0(%rip)     # 0x25e90
jmp 0x9309
testq %r12, %r12
je 0x93dd
movb $0x1, 0x1cb72(%rip)     # 0x25e74
movq %r12, 0x1cb6f(%rip)     # 0x25e78
movq (%r14), %r13
addq $0x8, %r14
testq %r13, %r13
jne 0x91f3
cmpb $0x0, 0x1cb54(%rip)     # 0x25e74
je 0x9368
movq 0x1cb4f(%rip), %rdi     # 0x25e78
movl $0x80441, %esi          # imm = 0x80441
movl $0x1a0, %edx            # imm = 0x1A0
xorl %eax, %eax
callq 0x48c0
movl %eax, 0xc150(%rip)      # 0x15490
testl %eax, %eax
js 0x93e2
leaq 0x18(%rsp), %rsi
movl %eax, %edi
callq 0x41f0
testl %eax, %eax
je 0x9373
leaq 0xc135(%rip), %rax      # 0x15494
cmpl $0x0, (%rax)
jne 0x93b4
xorl %eax, %eax
jmp 0x9378
cmpb $0x0, 0x1cb21(%rip)     # 0x25e90
je 0x93a2
jmp 0x93d8
movq 0x48(%rsp), %rax
movq %rax, 0x1cb01(%rip)     # 0x25e80
movq %rax, 0x1cb02(%rip)     # 0x25e88
cmpb $0x1, 0x1cb03(%rip)     # 0x25e90
je 0x93d8
cmpq $0x0, 0x8(%rsp)
jne 0x93e7
cmpq $0x0, 0xe0(%rsp)
jne 0x93ec
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
callq 0x5884
movq (%rbx), %rax
jmp 0x9378
callq 0x5838
movq %r13, %rdi
callq 0x579b
callq 0x5a33
callq 0x5987
callq 0x57ec
callq 0x59dd
callq 0x58db
callq 0x5931