// File: /workspace/github_cpp_makefile_star2_O1/brandoncanaday[P]1730sh/1730sh.cpp
// Function: export_builtin(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>> const&)
int export_builtin(const vector<string> & args) {
  if(args.size() != 2) {
    cout << "1730sh: Usage: export NAME[=WORD]" << endl;
    return -1;
  } else {
    string str = args[1];
    size_t pos;
    if((pos = str.find("=")) != string::npos) {
      if(pos == 0) { // user entered '=NAME' or '='
	cout << "1730sh: Usage: export NAME[=WORD]" << endl;
	return -1;
      } else { // user entered 'NA=ME' or 'NAME='
	string name = str.substr(0,pos);
	string value = (pos == str.length()-1) ? "" : str.substr(pos+1,str.length()-1-pos); 
	if(setenv(name.c_str(),value.c_str(),1) == -1) {
	  int err = errno; 
	  cout << "1730sh: export: " << str << ": " << strerror(err) << endl;
	  return -1;
	} // if
      } // if/else
    } else { // user entered something like 'NAME'
      string name = str;
      string value = "";
      if(setenv(name.c_str(),value.c_str(),1) == -1) { 
	int err = errno; 
	cout << "1730sh: export: " << str << ": " << strerror(err) << endl;
	return -1;
      } // if
    } // if/else
  } // if/else
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq (%rdi), %rax
movq 0x8(%rdi), %rcx
subq %rax, %rcx
cmpq $0x40, %rcx
jne 0x8aac
leaq -0x78(%rbp), %r15
movq %r15, -0x10(%r15)
movq 0x20(%rax), %rsi
movq 0x28(%rax), %rdx
addq %rsi, %rdx
leaq -0x88(%rbp), %rbx
movq %rbx, %rdi
callq 0x9f9e
leaq 0x5432(%rip), %rsi      # 0xde69
movl $0x1, %ecx
movq %rbx, %rdi
xorl %edx, %edx
callq 0x3520
cmpq $-0x1, %rax
je 0x8af8
movq %rax, %rbx
testq %rax, %rax
jne 0x8b7f
movq 0x956d(%rip), %rbx      # 0x11fd0
leaq 0x5e8c(%rip), %rsi      # 0xe8f6
movl $0x21, %edx
movq %rbx, %rdi
callq 0x3300
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x3290
movsbl %al, %esi
movq 0x953b(%rip), %rdi      # 0x11fd0
callq 0x3040
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movq %rax, %rdi
callq 0x31b0
jmp 0x8d86
movq 0x951d(%rip), %rbx      # 0x11fd0
leaq 0x5e3c(%rip), %rsi      # 0xe8f6
movl $0x21, %edx
movq %rbx, %rdi
callq 0x3300
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3290
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31b0
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x8d9e
leaq -0x58(%rbp), %r12
movq %r12, -0x10(%r12)
movq -0x88(%rbp), %rsi
movq -0x80(%rbp), %rdx
addq %rsi, %rdx
leaq -0x68(%rbp), %rdi
callq 0x9f9e
leaq -0x38(%rbp), %r13
movq %r13, -0x10(%r13)
leaq 0x5feb(%rip), %rdx      # 0xeb12
leaq -0x48(%rbp), %rdi
movq %rdx, %rsi
callq 0xa038
movq -0x68(%rbp), %rdi
movq -0x48(%rbp), %rsi
movl $0x1, %edx
callq 0x3430
cmpl $-0x1, %eax
je 0x8c1d
movq -0x48(%rbp), %rdi
cmpq %r13, %rdi
je 0x8b63
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x32c0
movq -0x68(%rbp), %rdi
cmpq %r12, %rdi
je 0x8b78
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x32c0
xorl %ebx, %ebx
jmp 0x8d86
leaq -0x68(%rbp), %rdi
leaq -0x88(%rbp), %rsi
xorl %edx, %edx
movq %rbx, %rcx
callq 0x32d0
movq -0x80(%rbp), %rcx
leaq -0x1(%rcx), %rax
leaq -0x38(%rbp), %r12
cmpq %rax, %rbx
jne 0x8bbd
leaq -0x48(%rbp), %rdi
movq %r12, (%rdi)
leaq 0x5f5f(%rip), %rdx      # 0xeb12
movq %rdx, %rsi
callq 0xa038
jmp 0x8bd7
leaq 0x1(%rbx), %rdx
notq %rbx
addq %rbx, %rcx
leaq -0x48(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x32d0
movq -0x68(%rbp), %rdi
movq -0x48(%rbp), %rsi
movl $0x1, %edx
callq 0x3430
cmpl $-0x1, %eax
je 0x8c9a
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x8c07
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x32c0
leaq -0x58(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x8b6c
jmp 0x8b78
callq 0x3060
movl (%rax), %r14d
movq 0x93a4(%rip), %rdi      # 0x11fd0
leaq 0x5ce5(%rip), %rsi      # 0xe918
movl $0x10, %edx
callq 0x3300
movq -0x88(%rbp), %rsi
movq -0x80(%rbp), %rdx
movq 0x9381(%rip), %rdi      # 0x11fd0
callq 0x3300
movq %rax, %rbx
leaq 0x5c93(%rip), %rsi      # 0xe8f1
movl $0x2, %edx
movq %rax, %rdi
callq 0x3300
movl %r14d, %edi
callq 0x30f0
testq %rax, %rax
je 0x8d17
movq %rax, %r14
movq %rax, %rdi
callq 0x3130
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x3300
jmp 0x8d30
callq 0x3060
movl (%rax), %r14d
movq 0x9327(%rip), %rdi      # 0x11fd0
leaq 0x5c68(%rip), %rsi      # 0xe918
movl $0x10, %edx
callq 0x3300
movq -0x88(%rbp), %rsi
movq -0x80(%rbp), %rdx
movq 0x9304(%rip), %rdi      # 0x11fd0
callq 0x3300
movq %rax, %rbx
leaq 0x5c16(%rip), %rsi      # 0xe8f1
movl $0x2, %edx
movq %rax, %rdi
callq 0x3300
movl %r14d, %edi
callq 0x30f0
testq %rax, %rax
je 0x8daf
movq %rax, %r14
movq %rax, %rdi
callq 0x3130
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x3300
jmp 0x8dc8
movq (%rbx), %rax
movq -0x18(%rax), %rax
movq %rbx, %rdi
addq %rax, %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x3500
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3290
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31b0
movq -0x48(%rbp), %rdi
cmpq %r13, %rdi
je 0x8d6c
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x32c0
movq -0x68(%rbp), %rdi
cmpq %r12, %rdi
je 0x8d81
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x32c0
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movq -0x88(%rbp), %rdi
cmpq %r15, %rdi
je 0x8d9e
movq -0x78(%rbp), %rsi
incq %rsi
callq 0x32c0
movl %ebx, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%rbx), %rax
movq -0x18(%rax), %rax
movq %rbx, %rdi
addq %rax, %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x3500
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3290
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31b0
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x8e04
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x32c0
leaq -0x58(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x8d75
jmp 0x8d81
movq %rax, %rbx
jmp 0x8e40
movq %rax, %rbx
jmp 0x8e67
jmp 0x8e7e
jmp 0x8e7e
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x8e40
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x32c0
leaq -0x58(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x8e70
jmp 0x8e81
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r13, %rdi
je 0x8e67
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x32c0
movq -0x68(%rbp), %rdi
cmpq %r12, %rdi
je 0x8e81
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x32c0
jmp 0x8e81
movq %rax, %rbx
movq -0x88(%rbp), %rdi
cmpq %r15, %rdi
je 0x8e99
movq -0x78(%rbp), %rsi
incq %rsi
callq 0x32c0
movq %rbx, %rdi
callq 0x3530