// File: /workspace/github_c_makefile_star2_O0/maandree[P]libkeccak/spec/libkeccak_degeneralise_spec.c
// Function: libkeccak_degeneralise_spec
int
libkeccak_degeneralise_spec(struct libkeccak_generalised_spec *restrict spec, struct libkeccak_spec *restrict output_spec)
{
	long int state_size, word_size, capacity, bitrate, output;
	int have_state_size = spec->state_size != LIBKECCAK_GENERALISED_SPEC_AUTOMATIC;
	int have_word_size  = spec->word_size  != LIBKECCAK_GENERALISED_SPEC_AUTOMATIC;
	int have_capacity   = spec->capacity   != LIBKECCAK_GENERALISED_SPEC_AUTOMATIC;
	int have_bitrate    = spec->bitrate    != LIBKECCAK_GENERALISED_SPEC_AUTOMATIC;
	int have_output     = spec->output     != LIBKECCAK_GENERALISED_SPEC_AUTOMATIC;


	if (have_state_size) {
		state_size = spec->state_size;
		if (state_size <= 0)
			return LIBKECCAK_GENERALISED_SPEC_ERROR_STATE_NONPOSITIVE;
		if (state_size > 1600)
			return LIBKECCAK_GENERALISED_SPEC_ERROR_STATE_TOO_LARGE;
		if (state_size % 25)
			return LIBKECCAK_GENERALISED_SPEC_ERROR_STATE_MOD_25;
	}

	if (have_word_size) {
		word_size = spec->word_size;
		if (word_size <= 0)
			return LIBKECCAK_GENERALISED_SPEC_ERROR_WORD_NONPOSITIVE;
		if (word_size > 64)
			return LIBKECCAK_GENERALISED_SPEC_ERROR_WORD_TOO_LARGE;		
		if (have_state_size && state_size != word_size * 25)
			return LIBKECCAK_GENERALISED_SPEC_ERROR_STATE_WORD_INCOHERENCY;
		else if (!have_state_size) {
			have_state_size = 1;
			state_size = word_size * 25;
		}
	}

	if (have_capacity) {
		capacity = spec->capacity;
		if (capacity <= 0)
			return LIBKECCAK_GENERALISED_SPEC_ERROR_CAPACITY_NONPOSITIVE;
		if (capacity & 7)
			return LIBKECCAK_GENERALISED_SPEC_ERROR_CAPACITY_MOD_8;
	}

	if (have_bitrate) {
		bitrate = spec->bitrate;
		if (bitrate <= 0)
			return LIBKECCAK_GENERALISED_SPEC_ERROR_BITRATE_NONPOSITIVE;
		if (bitrate & 7)
			return LIBKECCAK_GENERALISED_SPEC_ERROR_BITRATE_MOD_8;
	}

	if (have_output) {
		output = spec->output;
		if (output <= 0)
			return LIBKECCAK_GENERALISED_SPEC_ERROR_OUTPUT_NONPOSITIVE;
	}


	if (have_bitrate + have_capacity == 2) {
		if (!have_state_size) {
			state_size = bitrate + capacity;
			output = deft(output, capacity * 2L <= 8 ? 8 : capacity * 2L);
		} else if (state_size != bitrate + capacity) {
			return LIBKECCAK_GENERALISED_SPEC_ERROR_STATE_BITRATE_CAPACITY_INCONSISTENCY;
		}
	} else if (have_bitrate + have_capacity == 1) {
		state_size = deft(state_size, 1600L);
		capacity = deft(capacity, state_size - bitrate);
		bitrate = deft(bitrate, state_size - capacity);
		output = deft(output, capacity * 2L <= 8 ? 8 : capacity * 2L);
	} else {
		state_size = deft(state_size, 1600L);
		capacity = state_size * 9 / 25;
		bitrate = state_size - capacity;
		output = deft(output, bitrate / 2L <= 8 ? 8 : bitrate / 2L);
	}


	spec->capacity   = output_spec->capacity = capacity;
	spec->bitrate    = output_spec->bitrate  = bitrate;
	spec->output     = output_spec->output   = output;
	spec->state_size = state_size;
	spec->word_size  = state_size / 25;

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x28, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
cmpq $-0x10000, 0x18(%rax)   # imm = 0xFFFF0000
setne %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x44(%rbp)
movq -0x10(%rbp), %rax
cmpq $-0x10000, 0x20(%rax)   # imm = 0xFFFF0000
setne %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x48(%rbp)
movq -0x10(%rbp), %rax
cmpq $-0x10000, 0x8(%rax)    # imm = 0xFFFF0000
setne %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4c(%rbp)
movq -0x10(%rbp), %rax
cmpq $-0x10000, (%rax)       # imm = 0xFFFF0000
setne %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x50(%rbp)
movq -0x10(%rbp), %rax
cmpq $-0x10000, 0x10(%rax)   # imm = 0xFFFF0000
setne %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x54(%rbp)
cmpl $0x0, -0x44(%rbp)
je 0xb9af
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jg 0xb977
movl $0x1, -0x4(%rbp)
jmp 0xbd39
cmpq $0x640, -0x20(%rbp)     # imm = 0x640
jle 0xb98d
movl $0x2, -0x4(%rbp)
jmp 0xbd39
movq -0x20(%rbp), %rax
movl $0x19, %ecx
cqto
idivq %rcx
cmpq $0x0, %rdx
je 0xb9ad
movl $0x3, -0x4(%rbp)
jmp 0xbd39
jmp 0xb9af
cmpl $0x0, -0x48(%rbp)
je 0xba21
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jg 0xb9d4
movl $0x4, -0x4(%rbp)
jmp 0xbd39
cmpq $0x40, -0x28(%rbp)
jle 0xb9e7
movl $0x5, -0x4(%rbp)
jmp 0xbd39
cmpl $0x0, -0x44(%rbp)
je 0xba07
movq -0x20(%rbp), %rax
imulq $0x19, -0x28(%rbp), %rcx
cmpq %rcx, %rax
je 0xba07
movl $0x6, -0x4(%rbp)
jmp 0xbd39
cmpl $0x0, -0x44(%rbp)
jne 0xba1d
movl $0x1, -0x44(%rbp)
imulq $0x19, -0x28(%rbp), %rax
movq %rax, -0x20(%rbp)
jmp 0xba1f
jmp 0xba21
cmpl $0x0, -0x4c(%rbp)
je 0xba62
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jg 0xba46
movl $0x7, -0x4(%rbp)
jmp 0xbd39
movq -0x30(%rbp), %rax
andq $0x7, %rax
cmpq $0x0, %rax
je 0xba60
movl $0x8, -0x4(%rbp)
jmp 0xbd39
jmp 0xba62
cmpl $0x0, -0x50(%rbp)
je 0xbaa2
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jg 0xba86
movl $0x9, -0x4(%rbp)
jmp 0xbd39
movq -0x38(%rbp), %rax
andq $0x7, %rax
cmpq $0x0, %rax
je 0xbaa0
movl $0xa, -0x4(%rbp)
jmp 0xbd39
jmp 0xbaa2
cmpl $0x0, -0x54(%rbp)
je 0xbac9
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jg 0xbac7
movl $0xb, -0x4(%rbp)
jmp 0xbd39
jmp 0xbac9
movl -0x50(%rbp), %eax
addl -0x4c(%rbp), %eax
cmpl $0x2, %eax
jne 0xbb4f
cmpl $0x0, -0x44(%rbp)
jne 0xbb2b
movq -0x38(%rbp), %rax
addq -0x30(%rbp), %rax
movq %rax, -0x20(%rbp)
cmpl $0x0, -0x54(%rbp)
je 0xbaf6
movq -0x40(%rbp), %rax
movq %rax, -0x60(%rbp)
jmp 0xbb21
movq -0x30(%rbp), %rax
shlq %rax
cmpq $0x8, %rax
jg 0xbb0e
movl $0x8, %eax
movq %rax, -0x68(%rbp)
jmp 0xbb19
movq -0x30(%rbp), %rax
shlq %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0xbb4a
movq -0x20(%rbp), %rax
movq -0x38(%rbp), %rcx
addq -0x30(%rbp), %rcx
cmpq %rcx, %rax
je 0xbb48
movl $0xc, -0x4(%rbp)
jmp 0xbd39
jmp 0xbb4a
jmp 0xbcd3
movl -0x50(%rbp), %eax
addl -0x4c(%rbp), %eax
cmpl $0x1, %eax
jne 0xbc23
cmpl $0x0, -0x44(%rbp)
je 0xbb6e
movq -0x20(%rbp), %rax
movq %rax, -0x70(%rbp)
jmp 0xbb79
movl $0x640, %eax            # imm = 0x640
movq %rax, -0x70(%rbp)
jmp 0xbb79
movq -0x70(%rbp), %rax
movq %rax, -0x20(%rbp)
cmpl $0x0, -0x4c(%rbp)
je 0xbb91
movq -0x30(%rbp), %rax
movq %rax, -0x78(%rbp)
jmp 0xbb9d
movq -0x20(%rbp), %rax
subq -0x38(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0x30(%rbp)
cmpl $0x0, -0x50(%rbp)
je 0xbbb5
movq -0x38(%rbp), %rax
movq %rax, -0x80(%rbp)
jmp 0xbbc1
movq -0x20(%rbp), %rax
subq -0x30(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x38(%rbp)
cmpl $0x0, -0x54(%rbp)
je 0xbbdc
movq -0x40(%rbp), %rax
movq %rax, -0x88(%rbp)
jmp 0xbc13
movq -0x30(%rbp), %rax
shlq %rax
cmpq $0x8, %rax
jg 0xbbf7
movl $0x8, %eax
movq %rax, -0x90(%rbp)
jmp 0xbc05
movq -0x30(%rbp), %rax
shlq %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0xbcd1
cmpl $0x0, -0x44(%rbp)
je 0xbc36
movq -0x20(%rbp), %rax
movq %rax, -0x98(%rbp)
jmp 0xbc44
movl $0x640, %eax            # imm = 0x640
movq %rax, -0x98(%rbp)
jmp 0xbc44
movq -0x98(%rbp), %rax
movq %rax, -0x20(%rbp)
imulq $0x9, -0x20(%rbp), %rax
movl $0x19, %ecx
cqto
idivq %rcx
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rax
subq -0x30(%rbp), %rax
movq %rax, -0x38(%rbp)
cmpl $0x0, -0x54(%rbp)
je 0xbc81
movq -0x40(%rbp), %rax
movq %rax, -0xa0(%rbp)
jmp 0xbcc6
movq -0x38(%rbp), %rax
movl $0x2, %ecx
cqto
idivq %rcx
cmpq $0x8, %rax
jg 0xbca3
movl $0x8, %eax
movq %rax, -0xa8(%rbp)
jmp 0xbcb8
movq -0x38(%rbp), %rax
movl $0x2, %ecx
cqto
idivq %rcx
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0xbcd3
movq -0x30(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x38(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x40(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x20(%rbp), %rax
movl $0x19, %ecx
cqto
idivq %rcx
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x20(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x28, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)