// File: /workspace/github_c_makefile_star2_O1/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 %r13
pushq %r12
pushq %rbx
pushq %rax
cmpl $0x1, %edi
jne 0x1521
movq 0x2af1(%rip), %rbx      # 0x3fe0
movq (%rbx), %rax
movq (%rax), %rdi
xorl %r15d, %r15d
testq %rdi, %rdi
je 0x1717
movl $0x8, %r14d
callq 0x1050
movq (%rbx), %rax
movq (%rax,%r14), %rdi
addq $0x8, %r14
testq %rdi, %rdi
jne 0x1507
jmp 0x1717
movq %rsi, %r14
movl %edi, %r15d
movl $0x1, %edi
movl $0x40, %esi
callq 0x1070
testq %rax, %rax
je 0x1729
movq %rax, %rbx
movq %rax, %rdi
movl %r15d, %esi
movq %r14, %rdx
callq 0x12cc
cmpb $0x1, (%rbx)
jne 0x1566
movq 0x2a84(%rip), %rax      # 0x3fe0
movq (%rax), %rax
movq $0x0, (%rax)
cmpl $0x0, 0x10(%rbx)
jle 0x158e
cmpl $0x0, 0x10(%rbx)
jle 0x158e
xorl %r15d, %r15d
movq 0x8(%rbx), %rax
movq (%rax,%r15,8), %rdi
callq 0x1050
incq %r15
movslq 0x10(%rbx), %rax
cmpq %rax, %r15
jl 0x1575
cmpl $0x0, 0x38(%rbx)
jle 0x161c
xorl %r15d, %r15d
cmpl $0x0, 0x38(%rbx)
setg %r13b
jle 0x1612
movq 0x30(%rbx), %rax
movq (%rax), %rdi
callq 0x1080
testl %eax, %eax
jne 0x15dc
movl $0x1, %r12d
movslq 0x38(%rbx), %rax
cmpq %rax, %r12
setl %r13b
jge 0x1612
movq 0x30(%rbx), %rax
movq (%rax,%r12,8), %rdi
callq 0x1080
incq %r12
testl %eax, %eax
je 0x15bb
movq 0x2a15(%rip), %rax      # 0x3ff8
movq (%rax), %r15
movq (%r14), %r12
callq 0x1040
movl (%rax), %edi
callq 0x10e0
leaq 0xa08(%rip), %rsi       # 0x2004
movq %r15, %rdi
movq %r12, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x10a0
movl $0x1, %r15d
testb %r13b, %r13b
je 0x161f
jmp 0x1717
xorl %r15d, %r15d
cmpl $0x0, 0x10(%rbx)
jle 0x16a3
cmpl $0x0, 0x10(%rbx)
setg %r13b
jle 0x169e
movq 0x8(%rbx), %rax
movq (%rax), %rdi
callq 0x10b0
cmpl $-0x1, %eax
je 0x1668
movl $0x1, %r12d
movslq 0x10(%rbx), %rax
cmpq %rax, %r12
setl %r13b
jge 0x169e
movq 0x8(%rbx), %rax
movq (%rax,%r12,8), %rdi
callq 0x10b0
incq %r12
cmpl $-0x1, %eax
jne 0x1646
movq 0x2989(%rip), %rax      # 0x3ff8
movq (%rax), %r15
movq (%r14), %r12
callq 0x1040
movl (%rax), %edi
callq 0x10e0
leaq 0x97c(%rip), %rsi       # 0x2004
movq %r15, %rdi
movq %r12, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x10a0
movl $0x1, %r15d
testb %r13b, %r13b
jne 0x1717
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x16c4
movq 0x20(%rbx), %rsi
callq 0x10c0
cmpl $-0x1, %eax
jne 0x16f1
movq %r14, %rdi
callq 0x1169
jmp 0x1731
movq 0x2915(%rip), %r14      # 0x3fe0
movq (%r14), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x16f1
movl $0x8, %r15d
callq 0x1050
movq (%r14), %rax
movq (%rax,%r15), %rdi
addq $0x8, %r15
testq %rdi, %rdi
jne 0x16dc
movq 0x8(%rbx), %rdi
callq 0x1030
movq 0x30(%rbx), %rdi
callq 0x1030
movq 0x20(%rbx), %rdi
callq 0x1030
movq %rbx, %rdi
callq 0x1030
xorl %r15d, %r15d
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
callq 0x11a4
movl $0x1, %r15d
jmp 0x1717