// File: /workspace/github_c_makefile_star2_O1/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, 0xc2ab(%rip)      # 0x15480
movq %rdx, 0xc2ac(%rip)      # 0x15488
testq %rdi, %rdi
je 0x93dd
movq %rdi, %r14
movq (%rdi), %r13
testq %r13, %r13
je 0x9325
addq $0x8, %r14
leaq 0x492a(%rip), %r15      # 0xdb29
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 0x93d0
cmpq %r13, %rbx
movl $0x0, %r12d
cmoveq %rbp, %r12
movq %rbp, %r13
leaq 0x493c(%rip), %rcx      # 0xdb86
cmoveq %rcx, %r13
testq %rax, %rax
cmovneq %rbp, %r13
cmovneq %rax, %r12
movq %r13, %rdi
leaq 0x492c(%rip), %rsi      # 0xdb8f
callq 0x4610
testl %eax, %eax
je 0x9315
movq %r13, %rdi
leaq 0x3df4(%rip), %rsi      # 0xd06e
callq 0x4610
testl %eax, %eax
je 0x9315
movq %r13, %rdi
leaq 0x4902(%rip), %rsi      # 0xdb93
callq 0x4610
testl %eax, %eax
je 0x9315
movq %r13, %rdi
leaq 0x48f4(%rip), %rsi      # 0xdb98
callq 0x4610
testl %eax, %eax
je 0x92ec
movq %r13, %rdi
leaq 0x48ed(%rip), %rsi      # 0xdba4
callq 0x4610
testl %eax, %eax
je 0x92f5
movq %r13, %rdi
leaq 0x48bc(%rip), %rsi      # 0xdb86
callq 0x4610
testl %eax, %eax
je 0x92fe
orq %rbx, %r12
jne 0x93d5
movb $0x1, 0x1cb91(%rip)     # 0x25e74
movq %r13, 0x1cb8e(%rip)     # 0x25e78
jmp 0x9315
movb $0x1, 0x1cb7d(%rip)     # 0x25e70
jmp 0x9315
movb $0x1, 0x1cb94(%rip)     # 0x25e90
jmp 0x9315
testq %r12, %r12
je 0x93e7
movb $0x1, 0x1cb66(%rip)     # 0x25e74
movq %r12, 0x1cb63(%rip)     # 0x25e78
movq (%r14), %r13
addq $0x8, %r14
testq %r13, %r13
jne 0x91ff
cmpb $0x0, 0x1cb48(%rip)     # 0x25e74
je 0x93a3
movq 0x1cb43(%rip), %rdi     # 0x25e78
movl $0x80441, %esi          # imm = 0x80441
movl $0x1a0, %edx            # imm = 0x1A0
xorl %eax, %eax
callq 0x48c0
movl %eax, 0xc144(%rip)      # 0x15490
testl %eax, %eax
js 0x93ec
leaq 0x18(%rsp), %rsi
movl %eax, %edi
callq 0x41f0
testl %eax, %eax
je 0x9374
leaq 0xc129(%rip), %rax      # 0x15494
cmpl $0x0, (%rax)
jne 0x93be
xorl %eax, %eax
jmp 0x9379
movq 0x48(%rsp), %rax
movq %rax, 0x1cb00(%rip)     # 0x25e80
movq %rax, 0x1cb01(%rip)     # 0x25e88
cmpb $0x0, 0x1cb02(%rip)     # 0x25e90
jne 0x93a3
cmpq $0x0, 0x8(%rsp)
jne 0x93f1
cmpq $0x0, 0xe0(%rsp)
jne 0x93f6
cmpb $0x1, 0x1cae6(%rip)     # 0x25e90
je 0x93e2
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
callq 0x58ed
movq (%rbx), %rax
jmp 0x9379
callq 0x58a1
movq %r13, %rdi
callq 0x5804
callq 0x5a9c
callq 0x59f0
callq 0x5855
callq 0x5a46
callq 0x5944
callq 0x599a