// File: dtsaras[P]GCW/Utilities.cpp
// Function: Utilities::readBudgetsFromFile(int, int, int, int)
int* Utilities::readBudgetsFromFile(int V, int P, int k, int run_program)
{   
    int* budgets;
    budgets = new int[P];
    char filename[256]; 
    
    
    
    if (run_program==0)
    snprintf(filename, sizeof(char) * 256, "/home/lefteris/stcpu2/entaflos/CIM_Create_Budgets/Test/P=%i/file%i.txt", P, k);


    if (run_program==1)
        snprintf(filename, sizeof(char) * 256, "/home/lefteris/stcpu2/entaflos/CIM_Create_Budgets/Gowalla/P=%i/file%i.txt", P, k);


    if (run_program==2)
        snprintf(filename, sizeof(char) * 256, "/home/lefteris/stcpu2/entaflos/CIM_Create_Budgets/Foursquare/P=%i/file%i.txt", P, k);

    
    ifstream fin(filename);
    string line;   

    if (! fin)
        cout << "Cannot open budgets file " << filename << endl;
        
    
    int p=0;
    while(getline(fin, line))
    { 
        if(p==P) break;
        fin.clear();
        std::istringstream iss(line);
        iss.clear();
        iss >> budgets[p];
        if (! fin.good())
        {
            cout << "fin is not good: event = " << p << endl;
            continue;
        }
        p++;
    }
   
   
   
   return budgets;
}

// Assembly:
subq $0x528, %rsp            # imm = 0x528
movq %rdi, 0x520(%rsp)
movl %esi, 0x51c(%rsp)
movl %edx, 0x518(%rsp)
movl %ecx, 0x514(%rsp)
movl %r8d, 0x510(%rsp)
movslq 0x518(%rsp), %rax
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x4030
movq %rax, 0x508(%rsp)
cmpl $0x0, 0x510(%rsp)
jne 0x1a371
leaq 0x400(%rsp), %rdi
movl 0x518(%rsp), %ecx
movl 0x514(%rsp), %r8d
movl $0x100, %esi            # imm = 0x100
leaq 0x1815e(%rip), %rdx     # 0x324c8
movb $0x0, %al
callq 0x45c0
cmpl $0x1, 0x510(%rsp)
jne 0x1a3a5
leaq 0x400(%rsp), %rdi
movl 0x518(%rsp), %ecx
movl 0x514(%rsp), %r8d
movl $0x100, %esi            # imm = 0x100
leaq 0x18171(%rip), %rdx     # 0x3250f
movb $0x0, %al
callq 0x45c0
cmpl $0x2, 0x510(%rsp)
jne 0x1a3d9
leaq 0x400(%rsp), %rdi
movl 0x518(%rsp), %ecx
movl 0x514(%rsp), %r8d
movl $0x100, %esi            # imm = 0x100
leaq 0x18187(%rip), %rdx     # 0x32559
movb $0x0, %al
callq 0x45c0
leaq 0x1f8(%rsp), %rdi
leaq 0x400(%rsp), %rsi
movl $0x8, %edx
callq 0x4700
leaq 0x1d8(%rsp), %rdi
callq 0x4510
movq 0x1f8(%rsp), %rax
movq -0x18(%rax), %rax
leaq 0x1f8(%rsp,%rax), %rdi
callq 0x41b0
movb %al, 0x43(%rsp)
jmp 0x1a41f
movb 0x43(%rsp), %al
testb $0x1, %al
jne 0x1a429
jmp 0x1a48a
movq 0x26b90(%rip), %rdi     # 0x40fc0
leaq 0x1816f(%rip), %rsi     # 0x325a6
callq 0x43f0
movq %rax, 0x38(%rsp)
jmp 0x1a443
movq 0x38(%rsp), %rdi
leaq 0x400(%rsp), %rsi
callq 0x43f0
movq %rax, 0x30(%rsp)
jmp 0x1a45c
movq 0x30(%rsp), %rdi
movq 0x26b48(%rip), %rsi     # 0x40fb0
callq 0x4430
jmp 0x1a46f
jmp 0x1a48a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1d0(%rsp)
movl %eax, 0x1cc(%rsp)
jmp 0x1a665
movl $0x0, 0x1c8(%rsp)
leaq 0x1f8(%rsp), %rdi
leaq 0x1d8(%rsp), %rsi
callq 0x40c0
movq %rax, 0x28(%rsp)
jmp 0x1a4b1
movq 0x28(%rsp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x4490
movb %al, 0x27(%rsp)
jmp 0x1a4cb
movb 0x27(%rsp), %al
testb $0x1, %al
jne 0x1a4d8
jmp 0x1a629
movl 0x1c8(%rsp), %eax
cmpl 0x518(%rsp), %eax
jne 0x1a4ed
jmp 0x1a629
movq 0x1f8(%rsp), %rax
movq -0x18(%rax), %rax
leaq 0x1f8(%rsp,%rax), %rdi
xorl %esi, %esi
callq 0x4630
jmp 0x1a50a
leaq 0x48(%rsp), %rdi
leaq 0x1d8(%rsp), %rsi
movl $0x8, %edx
callq 0x4610
jmp 0x1a523
movq 0x48(%rsp), %rax
movq -0x18(%rax), %rax
leaq 0x48(%rsp,%rax), %rdi
xorl %esi, %esi
callq 0x4630
jmp 0x1a53a
movq 0x508(%rsp), %rax
movslq 0x1c8(%rsp), %rcx
leaq (%rax,%rcx,4), %rsi
leaq 0x48(%rsp), %rdi
callq 0x4250
jmp 0x1a55a
movq 0x1f8(%rsp), %rax
movq -0x18(%rax), %rax
leaq 0x1f8(%rsp,%rax), %rdi
callq 0x4640
movb %al, 0x26(%rsp)
jmp 0x1a579
movb 0x26(%rsp), %al
testb $0x1, %al
jne 0x1a5f2
jmp 0x1a583
movq 0x26a36(%rip), %rdi     # 0x40fc0
leaq 0x1802f(%rip), %rsi     # 0x325c0
callq 0x43f0
movq %rax, 0x18(%rsp)
jmp 0x1a59d
movq 0x18(%rsp), %rdi
movl 0x1c8(%rsp), %esi
callq 0x4670
movq %rax, 0x10(%rsp)
jmp 0x1a5b5
movq 0x10(%rsp), %rdi
movq 0x269ef(%rip), %rsi     # 0x40fb0
callq 0x4430
jmp 0x1a5c8
movl $0x2, 0x44(%rsp)
jmp 0x1a60b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1d0(%rsp)
movl %eax, 0x1cc(%rsp)
leaq 0x48(%rsp), %rdi
callq 0x41c0
jmp 0x1a665
movl 0x1c8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c8(%rsp)
movl $0x0, 0x44(%rsp)
leaq 0x48(%rsp), %rdi
callq 0x41c0
movl 0x44(%rsp), %eax
testl %eax, %eax
je 0x1a624
jmp 0x1a61f
jmp 0x1a495
jmp 0x1a495
movq 0x508(%rsp), %rax
movq %rax, 0x8(%rsp)
movl $0x1, 0x44(%rsp)
leaq 0x1d8(%rsp), %rdi
callq 0x4260
leaq 0x1f8(%rsp), %rdi
callq 0x4100
movq 0x8(%rsp), %rax
addq $0x528, %rsp            # imm = 0x528
retq
leaq 0x1d8(%rsp), %rdi
callq 0x4260
leaq 0x1f8(%rsp), %rdi
callq 0x4100
movq 0x1d0(%rsp), %rdi
callq 0x4690
nopl (%rax)