// File: /workspace/github_c_makefile_star2_O2/ikbenlike[P]nngutils/src/env.c
// Function: main
int main(int argc, char **argv){
    if(argc == 1){
        for(int i = 0; environ[i] != NULL; i++){
            puts(environ[i]);
        }
        return 0;
    }
    struct env_args *args = calloc(1, sizeof(struct env_args));
    if(args == NULL){
        fprintf(stderr, "%s: %s\n", argv[0], strerror(errno));
        return 1;
    }
    args = parse_arg(args, argc, argv);
    if(args->ignore_env){
        *environ = NULL;
    }
    if(args->nunset > 0){
        for(int i = 0; i < args->nunset; i++){
            puts(args->unset[i]);
        }
    }
    if(args->nvar > 0){
        for(int i = 0; i < args->nvar; i++){
            if(putenv(args->vars[i]) != 0){
                fprintf(stderr, "%s: %s\n", argv[0], strerror(errno));
                return 1;
            }
        }
    }
    if(args->nunset > 0){
        for(int i = 0; i < args->nunset; i++){
            if(unsetenv(args->unset[i]) == -1){
                fprintf(stderr, "%s: %s\n", argv[0], strerror(errno));
                return 1;
            }
        }
    }
    if(args->command == NULL){
        for(int i = 0; environ[i] != NULL; i++){
            puts(environ[i]);
        }
        free(args->unset);
        free(args->vars);
        free(args->args);
        free(args);
        return 0;
    }
    if(execvp(args->command, args->args) == -1){
        fprintf(stderr, "%s: %s\n", argv[0], strerror(errno));
        return 1;
    }
    free(args->unset);
    free(args->vars);
    free(args->args);
    free(args);
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
cmpl $0x1, %edi
jne 0x1463
xorl %ebx, %ebx
movq 0x2b9b(%rip), %r14      # 0x3fe0
xorl %r15d, %r15d
movq (%r14), %rax
movq (%rax,%r15), %rdi
testq %rdi, %rdi
je 0x1559
callq 0x1050
addq $0x8, %r15
jmp 0x1448
movq %rsi, %r14
movl %edi, %r15d
pushq $0x1
popq %rdi
pushq $0x40
popq %rsi
callq 0x1070
testq %rax, %rax
je 0x1587
movq %rax, %rbx
movq %rax, %rdi
movl %r15d, %esi
movq %r14, %rdx
callq 0x11ec
cmpb $0x1, (%rbx)
jne 0x14a1
movq 0x2b46(%rip), %rax      # 0x3fe0
movq (%rax), %rax
andq $0x0, (%rax)
movl 0x10(%rbx), %eax
testl %eax, %eax
jle 0x14c8
xorl %r15d, %r15d
movslq %eax, %rcx
cmpq %rcx, %r15
jge 0x14c8
movq 0x8(%rbx), %rax
movq (%rax,%r15,8), %rdi
callq 0x1050
incq %r15
movl 0x10(%rbx), %eax
jmp 0x14ab
cmpl $0x0, 0x38(%rbx)
jle 0x14f6
xorl %r15d, %r15d
movslq 0x38(%rbx), %rax
cmpq %rax, %r15
jge 0x14f3
movq 0x30(%rbx), %rax
movq (%rax,%r15,8), %rdi
callq 0x1080
incq %r15
testl %eax, %eax
je 0x14d1
jmp 0x1587
movl 0x10(%rbx), %eax
testl %eax, %eax
jle 0x151d
xorl %r15d, %r15d
movslq 0x10(%rbx), %rax
cmpq %rax, %r15
jge 0x151d
movq 0x8(%rbx), %rax
movq (%rax,%r15,8), %rdi
callq 0x10b0
incq %r15
cmpl $-0x1, %eax
jne 0x14fd
jmp 0x1587
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x1566
movq 0x20(%rbx), %rsi
callq 0x10c0
cmpl $-0x1, %eax
je 0x1587
movq 0x8(%rbx), %rdi
callq 0x1030
movq 0x30(%rbx), %rdi
callq 0x1030
movq 0x20(%rbx), %rdi
callq 0x1030
movq %rbx, %rdi
callq 0x1030
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
xorl %r14d, %r14d
movq 0x2a70(%rip), %r15      # 0x3fe0
movq (%r15), %rax
movq (%rax,%r14), %rdi
testq %rdi, %rdi
je 0x1534
callq 0x1050
addq $0x8, %r14
jmp 0x1570
movq 0x2a6a(%rip), %rax      # 0x3ff8
movq (%rax), %rbx
movq (%r14), %r14
callq 0x1040
movl (%rax), %edi
callq 0x10e0
leaq 0xa5d(%rip), %rsi       # 0x2004
movq %rbx, %rdi
movq %r14, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x10a0
pushq $0x1
popq %rbx
jmp 0x1559