// File: /workspace/github_cpp_makefile_star2_O3/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 0x8a74
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 0x9f52
leaq 0x546a(%rip), %rsi      # 0xde69
movl $0x1, %ecx
movq %rbx, %rdi
xorl %edx, %edx
callq 0x3520
cmpq $-0x1, %rax
je 0x8ac0
movq %rax, %rbx
testq %rax, %rax
jne 0x8b47
movq 0x95a5(%rip), %rbx      # 0x11fd0
leaq 0x5ec4(%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 0x9573(%rip), %rdi      # 0x11fd0
callq 0x3040
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movq %rax, %rdi
callq 0x31b0
jmp 0x8d4e
movq 0x9555(%rip), %rbx      # 0x11fd0
leaq 0x5e74(%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 0x8d66
leaq -0x58(%rbp), %r12
movq %r12, -0x10(%r12)
movq -0x88(%rbp), %rsi
movq -0x80(%rbp), %rdx
addq %rsi, %rdx
leaq -0x68(%rbp), %rdi
callq 0x9f52
leaq -0x38(%rbp), %r13
movq %r13, -0x10(%r13)
leaq 0x6023(%rip), %rdx      # 0xeb12
leaq -0x48(%rbp), %rdi
movq %rdx, %rsi
callq 0x9ff0
movq -0x68(%rbp), %rdi
movq -0x48(%rbp), %rsi
movl $0x1, %edx
callq 0x3430
cmpl $-0x1, %eax
je 0x8be5
movq -0x48(%rbp), %rdi
cmpq %r13, %rdi
je 0x8b2b
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x32c0
movq -0x68(%rbp), %rdi
cmpq %r12, %rdi
je 0x8b40
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x32c0
xorl %ebx, %ebx
jmp 0x8d4e
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 0x8b85
leaq -0x48(%rbp), %rdi
movq %r12, (%rdi)
leaq 0x5f97(%rip), %rdx      # 0xeb12
movq %rdx, %rsi
callq 0x9ff0
jmp 0x8b9f
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 0x8c62
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x8bcf
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x32c0
leaq -0x58(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x8b34
jmp 0x8b40
callq 0x3060
movl (%rax), %r14d
movq 0x93dc(%rip), %rdi      # 0x11fd0
leaq 0x5d1d(%rip), %rsi      # 0xe918
movl $0x10, %edx
callq 0x3300
movq -0x88(%rbp), %rsi
movq -0x80(%rbp), %rdx
movq 0x93b9(%rip), %rdi      # 0x11fd0
callq 0x3300
movq %rax, %rbx
leaq 0x5ccb(%rip), %rsi      # 0xe8f1
movl $0x2, %edx
movq %rax, %rdi
callq 0x3300
movl %r14d, %edi
callq 0x30f0
testq %rax, %rax
je 0x8cdf
movq %rax, %r14
movq %rax, %rdi
callq 0x3130
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x3300
jmp 0x8cf8
callq 0x3060
movl (%rax), %r14d
movq 0x935f(%rip), %rdi      # 0x11fd0
leaq 0x5ca0(%rip), %rsi      # 0xe918
movl $0x10, %edx
callq 0x3300
movq -0x88(%rbp), %rsi
movq -0x80(%rbp), %rdx
movq 0x933c(%rip), %rdi      # 0x11fd0
callq 0x3300
movq %rax, %rbx
leaq 0x5c4e(%rip), %rsi      # 0xe8f1
movl $0x2, %edx
movq %rax, %rdi
callq 0x3300
movl %r14d, %edi
callq 0x30f0
testq %rax, %rax
je 0x8d77
movq %rax, %r14
movq %rax, %rdi
callq 0x3130
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x3300
jmp 0x8d90
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 0x8d34
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x32c0
movq -0x68(%rbp), %rdi
cmpq %r12, %rdi
je 0x8d49
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x32c0
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movq -0x88(%rbp), %rdi
cmpq %r15, %rdi
je 0x8d66
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 0x8dcc
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x32c0
leaq -0x58(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x8d3d
jmp 0x8d49
jmp 0x8de4
movq %rax, %rbx
jmp 0x8e0a
movq %rax, %rbx
jmp 0x8e31
jmp 0x8e48
jmp 0x8e48
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x8e0a
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x32c0
leaq -0x58(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x8e3a
jmp 0x8e4b
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r13, %rdi
je 0x8e31
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x32c0
movq -0x68(%rbp), %rdi
cmpq %r12, %rdi
je 0x8e4b
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x32c0
jmp 0x8e4b
movq %rax, %rbx
movq -0x88(%rbp), %rdi
cmpq %r15, %rdi
je 0x8e63
movq -0x78(%rbp), %rsi
incq %rsi
callq 0x32c0
movq %rbx, %rdi
callq 0x3530