// File: /workspace/github_c_makefile_star2_O0/pipde[P]deos-songlib/utils/processtab/processtab.c
// Function: main
int 
main(int argc, char *argv[])
	{
    ASTTab *tab;
    Composition *composition;
    FILE *in;
    FILE *out = 0, *makefileOut = 0;
    char fileNameBuffer[256];
    char *baseName;
    int argIndex = 1;

	programCmdLine = argv[0];
    argIndex = processOptions(argc,argv);
    
    if (argc-argIndex == 0 && useStdIn)
        {
        baseName = "song";
        in = stdin;
        }
    else if (argc-argIndex == 1 && !useStdIn)
        {
  		baseName = getBaseFilename(argv[argIndex]);
        in = OpenFile(argv[argIndex],"r");
        }
    else
        {
        printHelp();
        exit(-1);
        }
    
    /* outputProgramName can be overriden via command line argument */
    if (outputProgramName == 0) outputProgramName = baseName;

    if (useStdOutForMakefile)
    	{
    	/* Print makefile to stdout, and exit */
    	
    	tab = parseTab(in);
		if (useStdIn) fclose(in);
    	composition = newCompositionFromTab(tab);
		outputMakefile(composition, stdout, baseName);
    	}
    else if (useStdOut)
        {
        /* Print songlib program to stdout, and exit */
        
        out = stdout;
    	tab = parseTab(in);
		if (useStdIn) fclose(in);
    	composition = newCompositionFromTab(tab);
    	outputSonglibFile(composition, out, baseName, outputProgramName, outputVersion);
        }
    else
        {
        /* Print songlib output and makefile to files, and display feedback via stdout */
        
		printf("Processing tab '%s':\n", baseName);
		
		printf("Parsing tab into syntax tree...\n");
    	tab = parseTab(in);
		if (useStdIn) fclose(in);
		
		/* Uncomment the following lines to get a printout of the tab syntax tree */
		//printf("Printing syntax tree...\n");
		//printASTTab(tab, stdout);
		
    	printf("Transforming syntax tree into composition...\n");
    	composition = newCompositionFromTab(tab);
        sprintf(fileNameBuffer, "%s.c", baseName);  
        
	    printf("Outputting %s...\n", fileNameBuffer);
        out = fopen(fileNameBuffer, "w");
    	outputSonglibFile(composition, out, baseName, outputProgramName, outputVersion);
	    fclose(out);
	    
	    if (!skipMakefile)
	    	{
			printf("Outputting makefile...\n");
		    makefileOut = fopen("makefile", "w");
			outputMakefile(composition, makefileOut, baseName);
			fclose(makefileOut);
			}
			
		printf("Done with tab '%s'.\n\n", baseName);
		}
    
    return 0;
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movl $0x1, -0x14c(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, 0x9e6f(%rip)      # 0xb150
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0x15a0
movl %eax, -0x14c(%rbp)
movl -0x8(%rbp), %eax
subl -0x14c(%rbp), %eax
cmpl $0x0, %eax
jne 0x1328
testb $0x1, 0x9e50(%rip)      # 0xb158
je 0x1328
leaq 0x5e25(%rip), %rax      # 0x7136
movq %rax, -0x148(%rbp)
movq 0x9cb9(%rip), %rax      # 0xafd8
movq (%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x138c
movl -0x8(%rbp), %eax
subl -0x14c(%rbp), %eax
cmpl $0x1, %eax
jne 0x137b
testb $0x1, 0x9e1b(%rip)      # 0xb158
jne 0x137b
movq -0x10(%rbp), %rax
movslq -0x14c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x17e0
movq %rax, -0x148(%rbp)
movq -0x10(%rbp), %rax
movslq -0x14c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x6a99(%rip), %rsi      # 0x7e09
callq 0x6530
movq %rax, -0x28(%rbp)
jmp 0x138a
callq 0x2d00
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1180
jmp 0x138c
cmpq $0x0, 0x9db4(%rip)      # 0xb148
jne 0x13a4
movq -0x148(%rbp), %rax
movq %rax, 0x9da4(%rip)      # 0xb148
testb $0x1, 0x9daf(%rip)      # 0xb15a
je 0x13f8
movq -0x28(%rbp), %rdi
callq 0x33c0
movq %rax, -0x18(%rbp)
testb $0x1, 0x9d97(%rip)      # 0xb158
je 0x13cc
movq -0x28(%rbp), %rdi
callq 0x1050
movq -0x18(%rbp), %rdi
callq 0x4f00
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
movq 0x9bec(%rip), %rax      # 0xafd0
movq (%rax), %rsi
movq -0x148(%rbp), %rdx
callq 0x18a0
jmp 0x1594
testb $0x1, 0x9d5a(%rip)      # 0xb159
je 0x1462
movq 0x9bc8(%rip), %rax      # 0xafd0
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rdi
callq 0x33c0
movq %rax, -0x18(%rbp)
testb $0x1, 0x9d35(%rip)      # 0xb158
je 0x142e
movq -0x28(%rbp), %rdi
callq 0x1050
movq -0x18(%rbp), %rdi
callq 0x4f00
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x148(%rbp), %rdx
movq 0x9cf7(%rip), %rcx      # 0xb148
movq 0x9c98(%rip), %r8       # 0xb0f0
callq 0x1c20
jmp 0x1592
movq -0x148(%rbp), %rsi
leaq 0x5ccb(%rip), %rdi      # 0x713b
movb $0x0, %al
callq 0x1080
leaq 0x5cd3(%rip), %rdi      # 0x7151
movb $0x0, %al
callq 0x1080
movq -0x28(%rbp), %rdi
callq 0x33c0
movq %rax, -0x18(%rbp)
testb $0x1, 0x9cbf(%rip)      # 0xb158
je 0x14a4
movq -0x28(%rbp), %rdi
callq 0x1050
leaq 0x5cc7(%rip), %rdi      # 0x7172
movb $0x0, %al
callq 0x1080
movq -0x18(%rbp), %rdi
callq 0x4f00
movq %rax, -0x20(%rbp)
leaq -0x140(%rbp), %rdi
movq -0x148(%rbp), %rdx
leaq 0x5ccc(%rip), %rsi      # 0x71a0
movb $0x0, %al
callq 0x1170
leaq -0x140(%rbp), %rsi
leaq 0x5cbc(%rip), %rdi      # 0x71a5
movb $0x0, %al
callq 0x1080
leaq -0x140(%rbp), %rdi
leaq 0x5cb9(%rip), %rsi      # 0x71b7
callq 0x1150
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x148(%rbp), %rdx
movq 0x9c2b(%rip), %rcx      # 0xb148
movq 0x9bcc(%rip), %r8       # 0xb0f0
callq 0x1c20
movq -0x30(%rbp), %rdi
callq 0x1050
testb $0x1, 0x9c22(%rip)      # 0xb15b
jne 0x157d
leaq 0x5c77(%rip), %rdi      # 0x71b9
movb $0x0, %al
callq 0x1080
leaq 0x5c81(%rip), %rdi      # 0x71d1
leaq 0x5c60(%rip), %rsi      # 0x71b7
callq 0x1150
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x148(%rbp), %rdx
callq 0x18a0
movq -0x38(%rbp), %rdi
callq 0x1050
movq -0x148(%rbp), %rsi
leaq 0x5c4f(%rip), %rdi      # 0x71da
movb $0x0, %al
callq 0x1080
jmp 0x1594
xorl %eax, %eax
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
nop