// File: UTSASRG[P]Guarder/libguarder.cpp
// Function: parseEnvOpts()
void parseEnvOpts() {
		char * value;

		// opts is a global struct located in bibopheap.hh
		if((value = getenv("GUARDER_NUMERATOR"))) {
				opts.over_prov_numerator = atoi(value);
		}
    if((value = getenv("GUARDER_DENOMINATOR"))) {
        opts.over_prov_denominator = atoi(value);
    }
		// Over provisioning ratio must be greater than or equal to 1
		if((opts.over_prov_denominator <= 0) ||
						(opts.over_prov_numerator < opts.over_prov_denominator)) {
				PRERR("over provisioning ratio invalid; setting to 1/1");
				opts.over_prov_numerator = 1;
				opts.over_prov_denominator = 1;
		}

    if((value = getenv("GUARDER_ENTROPY_BITS"))) {
        opts.bibop_entropy_bits = atoi(value);
    }
		// Entropy bits must be a positive integer
		if(opts.bibop_entropy_bits <= 0) {
				PRERR("invalid bibop entropy bits; setting to default value (%u)",
								DEFAULT_BIBOP_ENTROPY_BITS);
				opts.bibop_entropy_bits = DEFAULT_BIBOP_ENTROPY_BITS;
		}

		opts.bibop_cache_size = (1U << (opts.bibop_entropy_bits + 1));

		/*
    if((value = getenv("GUARDER_CACHE_DIVISOR"))) {
        opts.bibop_cache_allowance_divisor = atoi(value);
    }
		// Cache allowance divisor must be a positive integer >= 2
		if(opts.bibop_cache_allowance_divisor < 2) {
				PRERR("invalid bibop cache allowance divisor; "
								"setting to default value (%u)", DEFAULT_BIBOP_CACHE_ALLOWANCE_DIVISOR);
				opts.bibop_cache_allowance_divisor = DEFAULT_BIBOP_CACHE_ALLOWANCE_DIVISOR;
		}
		*/

    if((value = getenv("GUARDER_RAND_GUARD_PROP"))) {
        opts.random_guard_prop = atof(value);
    }
		// Random guard proportion must be a fraction between [0, 1)
		if((opts.random_guard_prop < 0.0f) || (opts.random_guard_prop >= 1.0f)) {
				PRERR("invalid random guard proportion; "
								"setting to default value (%4.2f)", DEFAULT_RAND_GUARD_PROP);
				opts.random_guard_prop = DEFAULT_RAND_GUARD_PROP;
		}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
leaq 0x5b19(%rip), %rdi      # 0xc108
callq 0x55c0
movq %rax, -0x8(%rbp)
cmpq $0x0, %rax
je 0x6613
movq -0x8(%rbp), %rdi
callq 0x57b0
movl %eax, %ecx
movq 0xa908(%rip), %rax      # 0x10f18
movl %ecx, 0xc(%rax)
leaq 0x5b00(%rip), %rdi      # 0xc11a
callq 0x55c0
movq %rax, -0x8(%rbp)
cmpq $0x0, %rax
je 0x663e
movq -0x8(%rbp), %rdi
callq 0x57b0
movl %eax, %ecx
movq 0xa8dd(%rip), %rax      # 0x10f18
movl %ecx, 0x10(%rax)
movq 0xa8d3(%rip), %rax      # 0x10f18
cmpl $0x0, 0x10(%rax)
jbe 0x6661
movq 0xa8c6(%rip), %rax      # 0x10f18
movl 0xc(%rax), %eax
movq 0xa8bc(%rip), %rcx      # 0x10f18
cmpl 0x10(%rcx), %eax
jae 0x66d9
callq 0x52d0
movq %rax, -0x18(%rbp)
callq 0x5400
movq -0x18(%rbp), %rdi
movq %rax, %rcx
movl $0x1000, %esi           # imm = 0x1000
leaq 0x5aac(%rip), %rdx      # 0xc12e
leaq 0x5a70(%rip), %r8       # 0xc0f9
movl $0xb4, %r9d
movb $0x0, %al
callq 0x57e0
callq 0x52d0
movq %rax, -0x10(%rbp)
callq 0x52d0
movq %rax, %rdi
callq 0x51e0
movq -0x10(%rbp), %rsi
movq %rax, %rdx
movl $0x2, %edi
callq 0x5160
movq 0xa854(%rip), %rax      # 0x10f18
movl $0x1, 0xc(%rax)
movq 0xa846(%rip), %rax      # 0x10f18
movl $0x1, 0x10(%rax)
leaq 0x5aa2(%rip), %rdi      # 0xc182
callq 0x55c0
movq %rax, -0x8(%rbp)
cmpq $0x0, %rax
je 0x6704
movq -0x8(%rbp), %rdi
callq 0x57b0
movl %eax, %ecx
movq 0xa817(%rip), %rax      # 0x10f18
movl %ecx, 0x4(%rax)
movq 0xa80d(%rip), %rax      # 0x10f18
cmpl $0x0, 0x4(%rax)
ja 0x6782
callq 0x52d0
movq %rax, -0x28(%rbp)
callq 0x5400
movq -0x28(%rbp), %rdi
movq %rax, %rcx
movl $0x1000, %esi           # imm = 0x1000
leaq 0x5a65(%rip), %rdx      # 0xc197
leaq 0x59c0(%rip), %r8       # 0xc0f9
movl $0xbf, %r9d
movl $0xa, (%rsp)
movb $0x0, %al
callq 0x57e0
callq 0x52d0
movq %rax, -0x20(%rbp)
callq 0x52d0
movq %rax, %rdi
callq 0x51e0
movq -0x20(%rbp), %rsi
movq %rax, %rdx
movl $0x2, %edi
callq 0x5160
movq 0xa79d(%rip), %rax      # 0x10f18
movl $0xa, 0x4(%rax)
movq 0xa78f(%rip), %rax      # 0x10f18
movl 0x4(%rax), %ecx
addl $0x1, %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, %ecx
movq 0xa779(%rip), %rax      # 0x10f18
movl %ecx, 0x8(%rax)
leaq 0x5a4c(%rip), %rdi      # 0xc1f5
callq 0x55c0
movq %rax, -0x8(%rbp)
cmpq $0x0, %rax
je 0x67d1
movq -0x8(%rbp), %rdi
callq 0x55e0
cvtsd2ss %xmm0, %xmm0
movq 0xa74c(%rip), %rax      # 0x10f18
movss %xmm0, 0x14(%rax)
xorps %xmm0, %xmm0
movq 0xa73d(%rip), %rax      # 0x10f18
ucomiss 0x14(%rax), %xmm0
ja 0x67fa
movq 0xa730(%rip), %rax      # 0x10f18
movss 0x14(%rax), %xmm0
movss 0x5853(%rip), %xmm1     # 0xc048
ucomiss %xmm1, %xmm0
jb 0x6872
callq 0x52d0
movq %rax, -0x38(%rbp)
callq 0x5400
movq -0x38(%rbp), %rdi
movq %rax, %rcx
movl $0x1000, %esi           # imm = 0x1000
leaq 0x59f2(%rip), %rdx      # 0xc20d
leaq 0x58d7(%rip), %r8       # 0xc0f9
movl $0xd7, %r9d
movsd 0x5820(%rip), %xmm0     # 0xc050
movb $0x1, %al
callq 0x57e0
callq 0x52d0
movq %rax, -0x30(%rbp)
callq 0x52d0
movq %rax, %rdi
callq 0x51e0
movq -0x30(%rbp), %rsi
movq %rax, %rdx
movl $0x2, %edi
callq 0x5160
movq 0xa6b3(%rip), %rax      # 0x10f18
movss 0x57df(%rip), %xmm0     # 0xc04c
movss %xmm0, 0x14(%rax)
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)