// File: /workspace/github_cpp_makefile_star2_O2/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 %r14
pushq %rbx
subq $0x70, %rsp
movq (%rdi), %rsi
movq 0x8(%rdi), %rax
subq %rsi, %rax
cmpq $0x40, %rax
jne 0x6b34
addq $0x20, %rsi
leaq -0x78(%rbp), %rbx
movq %rbx, %rdi
callq 0x3380
leaq 0x4371(%rip), %rsi      # 0xae69
movq %rbx, %rdi
xorl %edx, %edx
callq 0x3520
cmpq $-0x1, %rax
je 0x6b57
movq %rax, %rbx
testq %rax, %rax
jne 0x6be8
movq 0x94ad(%rip), %rdi      # 0xffc8
leaq 0x4dd4(%rip), %rsi      # 0xb8f6
callq 0x3280
movq %rax, %rdi
callq 0x3130
jmp 0x6cc3
movq 0x948d(%rip), %rdi      # 0xffc8
leaq 0x4db4(%rip), %rsi      # 0xb8f6
callq 0x3280
movq %rax, %rdi
callq 0x3130
pushq $-0x1
popq %rbx
jmp 0x6ccf
leaq -0x58(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x3380
leaq 0x4f77(%rip), %rsi      # 0xbae2
leaq -0x38(%rbp), %rdi
leaq -0x11(%rbp), %rdx
callq 0x3100
movq -0x58(%rbp), %rdi
movq -0x38(%rbp), %rsi
pushq $0x1
popq %rdx
callq 0x3400
cmpl $-0x1, %eax
jne 0x6c49
callq 0x3050
movl (%rax), %ebx
movq 0x9429(%rip), %rdi      # 0xffc8
leaq 0x4d72(%rip), %rsi      # 0xb918
callq 0x3280
leaq -0x78(%rbp), %rsi
movq %rax, %rdi
callq 0x3250
leaq 0x4d33(%rip), %rsi      # 0xb8f1
movq %rax, %rdi
callq 0x3280
movq %rax, %r14
movl %ebx, %edi
callq 0x30d0
movq %r14, %rdi
movq %rax, %rsi
callq 0x3280
movq %rax, %rdi
callq 0x3130
jmp 0x6cb1
leaq -0x58(%rbp), %rdi
leaq -0x78(%rbp), %rsi
xorl %edx, %edx
movq %rbx, %rcx
callq 0x32b0
movq -0x70(%rbp), %rcx
leaq -0x1(%rcx), %rax
cmpq %rax, %rbx
jne 0x6c1d
leaq 0x4ed4(%rip), %rsi      # 0xbae2
leaq -0x38(%rbp), %rdi
leaq -0x11(%rbp), %rdx
callq 0x3100
jmp 0x6c34
leaq 0x1(%rbx), %rdx
notq %rbx
addq %rbx, %rcx
leaq -0x38(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x32b0
movq -0x58(%rbp), %rdi
movq -0x38(%rbp), %rsi
pushq $0x1
popq %rdx
callq 0x3400
cmpl $-0x1, %eax
je 0x6c5f
leaq -0x38(%rbp), %rdi
callq 0x3120
leaq -0x58(%rbp), %rdi
callq 0x3120
xorl %ebx, %ebx
jmp 0x6cc6
callq 0x3050
movl (%rax), %ebx
movq 0x935b(%rip), %rdi      # 0xffc8
leaq 0x4ca4(%rip), %rsi      # 0xb918
callq 0x3280
leaq -0x78(%rbp), %rsi
movq %rax, %rdi
callq 0x3250
leaq 0x4c65(%rip), %rsi      # 0xb8f1
movq %rax, %rdi
callq 0x3280
movq %rax, %r14
movl %ebx, %edi
callq 0x30d0
movq %r14, %rdi
movq %rax, %rsi
callq 0x3280
movq %rax, %rdi
callq 0x3130
leaq -0x38(%rbp), %rdi
callq 0x3120
leaq -0x58(%rbp), %rdi
callq 0x3120
pushq $-0x1
popq %rbx
leaq -0x78(%rbp), %rdi
callq 0x3120
movl %ebx, %eax
addq $0x70, %rsp
popq %rbx
popq %r14
popq %rbp
retq
jmp 0x6cde
jmp 0x6cde
movq %rax, %rbx
jmp 0x6cf5
jmp 0x6d00
jmp 0x6d00
jmp 0x6ce9
movq %rax, %rbx
leaq -0x38(%rbp), %rdi
callq 0x3120
leaq -0x58(%rbp), %rdi
callq 0x3120
jmp 0x6d03
movq %rax, %rbx
leaq -0x78(%rbp), %rdi
callq 0x3120
movq %rbx, %rdi
callq 0x34b0