// File: /workspace/github_c_makefile_star2_O3/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 0x15ab
movq 0x2a66(%rip), %r14      # 0x3fe0
movq (%r14), %rax
movq (%rax), %rdi
xorl %ebx, %ebx
testq %rdi, %rdi
je 0x16dc
movl $0x8, %r15d
callq 0x1050
movq (%r14), %rax
movq (%rax,%r15), %rdi
addq $0x8, %r15
testq %rdi, %rdi
jne 0x1591
jmp 0x16dc
movq %rsi, %r14
movl %edi, %r15d
movl $0x1, %edi
movl $0x40, %esi
callq 0x1070
testq %rax, %rax
je 0x16e9
movq %rax, %rbx
movq %rax, %rdi
movl %r15d, %esi
movq %r14, %rdx
callq 0x134c
cmpb $0x1, (%rbx)
jne 0x15f0
movq 0x29fa(%rip), %rax      # 0x3fe0
movq (%rax), %rax
movq $0x0, (%rax)
movl 0x10(%rbx), %eax
testl %eax, %eax
jle 0x1613
xorl %r15d, %r15d
movq 0x8(%rbx), %rax
movq (%rax,%r15,8), %rdi
callq 0x1050
incq %r15
movslq 0x10(%rbx), %rax
cmpq %rax, %r15
jl 0x15fa
cmpl $0x0, 0x38(%rbx)
jle 0x1640
xorl %r15d, %r15d
movq 0x30(%rbx), %rax
movq (%rax,%r15,8), %rdi
callq 0x1080
testl %eax, %eax
jne 0x16f3
incq %r15
movslq 0x38(%rbx), %rax
cmpq %rax, %r15
jl 0x161c
movl 0x10(%rbx), %eax
testl %eax, %eax
jle 0x1669
xorl %r15d, %r15d
movq 0x8(%rbx), %rax
movq (%rax,%r15,8), %rdi
callq 0x10b0
cmpl $-0x1, %eax
je 0x16fd
incq %r15
movslq 0x10(%rbx), %rax
cmpq %rax, %r15
jl 0x1647
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x168a
movq 0x20(%rbx), %rsi
callq 0x10c0
cmpl $-0x1, %eax
jne 0x16b7
movq %r14, %rdi
callq 0x11a4
jmp 0x1705
movq 0x294f(%rip), %r14      # 0x3fe0
movq (%r14), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x16b7
movl $0x8, %r15d
callq 0x1050
movq (%r14), %rax
movq (%rax,%r15), %rdi
addq $0x8, %r15
testq %rdi, %rdi
jne 0x16a2
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
movq %r14, %rdi
callq 0x121a
jmp 0x1705
movq %r14, %rdi
callq 0x1169
jmp 0x1705
movq %r14, %rdi
callq 0x11df
movl $0x1, %ebx
jmp 0x16dc