// File: /workspace/github_c_makefile_star2_O0/silverneko[P]miku/isolate/isolate.c
// Function: apply_env_rule
static void
apply_env_rule(char **env, int *env_sizep, struct env_rule *r)
{
  // First remove the variable if already set
  int pos = 0;
  while (pos < *env_sizep && !match_env_var(env[pos], r))
    pos++;
  if (pos < *env_sizep)
    {
      (*env_sizep)--;
      env[pos] = env[*env_sizep];
      env[*env_sizep] = NULL;
    }

  // What is the new value?
  char *new;
  if (r->val)
    {
      if (!r->val[0])
	return;
      new = xmalloc(r->var_len + 1 + strlen(r->val) + 1);
      sprintf(new, "%s=%s", r->var, r->val);
    }
  else
    {
      pos = 0;
      while (environ[pos] && !match_env_var(environ[pos], r))
	pos++;
      if (!(new = environ[pos]))
	return;
    }

  // Add it at the end of the array
  env[(*env_sizep)++] = new;
  env[*env_sizep] = NULL;
}

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x40(%rsp)
movq %rsi, 0x38(%rsp)
movq %rdx, 0x30(%rsp)
movl $0x0, 0x2c(%rsp)
movl 0x2c(%rsp), %ecx
movq 0x38(%rsp), %rdx
xorl %eax, %eax
cmpl (%rdx), %ecx
movb %al, 0x1f(%rsp)
jge 0x5912
movq 0x40(%rsp), %rax
movslq 0x2c(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
movq 0x30(%rsp), %rsi
callq 0x5ac0
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
movb %al, 0x1f(%rsp)
movb 0x1f(%rsp), %al
testb $0x1, %al
jne 0x591c
jmp 0x5929
movl 0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c(%rsp)
jmp 0x58db
movl 0x2c(%rsp), %eax
movq 0x38(%rsp), %rcx
cmpl (%rcx), %eax
jge 0x5976
movq 0x38(%rsp), %rax
movl (%rax), %ecx
addl $-0x1, %ecx
movl %ecx, (%rax)
movq 0x40(%rsp), %rax
movq 0x38(%rsp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rdx
movq 0x40(%rsp), %rax
movslq 0x2c(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x40(%rsp), %rax
movq 0x38(%rsp), %rcx
movslq (%rcx), %rcx
movq $0x0, (%rax,%rcx,8)
movq 0x30(%rsp), %rax
cmpq $0x0, 0x8(%rax)
je 0x59f4
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rax
cmpb $0x0, (%rax)
jne 0x5995
jmp 0x5aae
movq 0x30(%rsp), %rax
movl 0x10(%rax), %eax
addl $0x1, %eax
cltq
movq %rax, 0x10(%rsp)
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x2180
movq 0x10(%rsp), %rdi
addq %rax, %rdi
addq $0x1, %rdi
callq 0x35b0
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rdi
movq 0x30(%rsp), %rax
movq (%rax), %rdx
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rcx
leaq 0x1e61(%rip), %rsi      # 0x7849
movb $0x0, %al
callq 0x2460
jmp 0x5a7a
movl $0x0, 0x2c(%rsp)
movq 0x45dd(%rip), %rax      # 0x9fe0
movq (%rax), %rcx
movslq 0x2c(%rsp), %rdx
xorl %eax, %eax
cmpq $0x0, (%rcx,%rdx,8)
movb %al, 0xf(%rsp)
je 0x5a41
movq 0x45c1(%rip), %rax      # 0x9fe0
movq (%rax), %rax
movslq 0x2c(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
movq 0x30(%rsp), %rsi
callq 0x5ac0
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
movb %al, 0xf(%rsp)
movb 0xf(%rsp), %al
testb $0x1, %al
jne 0x5a4b
jmp 0x5a58
movl 0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c(%rsp)
jmp 0x59fc
movq 0x4581(%rip), %rax      # 0x9fe0
movq (%rax), %rax
movslq 0x2c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x20(%rsp)
cmpq $0x0, %rax
jne 0x5a78
jmp 0x5aae
jmp 0x5a7a
movq 0x20(%rsp), %rdx
movq 0x40(%rsp), %rax
movq 0x38(%rsp), %rsi
movl (%rsi), %ecx
movl %ecx, %edi
addl $0x1, %edi
movl %edi, (%rsi)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x40(%rsp), %rax
movq 0x38(%rsp), %rcx
movslq (%rcx), %rcx
movq $0x0, (%rax,%rcx,8)
addq $0x48, %rsp
retq
nopw %cs:(%rax,%rax)