#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ isprime(unsigned int);
double log(float);
int /*<<< orphan*/ printf(char *, ...);
int valid_assignment(unsigned int exp, int bit_min, int bit_max,
                     int verbosity) {
  int ret = 1;
  if (exp < 100000) {
    ret = 0;
    if (verbosity >= 1)
      printf("WARNING: exponents < 100000 are not supported!\n");
  } else if (!isprime(exp)) {
    ret = 0;
    if (verbosity >= 1)
      printf("WARNING: exponent is not prime!\n");
  } else if (bit_min < 1) {
    ret = 0;
    if (verbosity >= 1)
      printf("WARNING: bit_min < 1 doesn't make sense!\n");
  } else if (bit_min > 94) {
    ret = 0;
    if (verbosity >= 1)
      printf("WARNING: bit_min > 94 is not supported!\n");
  } else if (bit_min >= bit_max) {
    ret = 0;
    if (verbosity >= 1)
      printf("WARNING: bit_min >= bit_max doesn't make sense!\n");
  } else if (bit_max > 95) {
    ret = 0;
    if (verbosity >= 1)
      printf("WARNING: bit_max > 95 is not supported!\n");
  } else if (((double)(bit_max - 1) - (log((double)exp) / log(2.0F))) > 63.9F) {
    ret = 0;
    if (verbosity >= 1)
      printf("WARNING: k_max > 2^63.9 is not supported!\n");
  }
  if (verbosity >= 1 && ret == 0)
    printf("         Ignoring TF M%u from 2^%d to 2^%d!\n", exp, bit_min,
           bit_max);
  return ret;
}


x86 assembly (clang, -O0):
<valid_assignment>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0x186a0,-0x4(%rbp)
jae    117c <valid_assignment+0x4c>
movl   $0x0,-0x14(%rbp)
cmpl   $0x1,-0x10(%rbp)
jl     1177 <valid_assignment+0x47>
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1306 <valid_assignment+0x1d6>
mov    -0x4(%rbp),%edi
call   1040 <isprime@plt>
cmp    $0x0,%eax
jne    11b1 <valid_assignment+0x81>
movl   $0x0,-0x14(%rbp)
cmpl   $0x1,-0x10(%rbp)
jl     11ac <valid_assignment+0x7c>
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1301 <valid_assignment+0x1d1>
cmpl   $0x1,-0x8(%rbp)
jge    11df <valid_assignment+0xaf>
movl   $0x0,-0x14(%rbp)
cmpl   $0x1,-0x10(%rbp)
jl     11da <valid_assignment+0xaa>
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12fc <valid_assignment+0x1cc>
cmpl   $0x5e,-0x8(%rbp)
jle    120d <valid_assignment+0xdd>
movl   $0x0,-0x14(%rbp)
cmpl   $0x1,-0x10(%rbp)
jl     1208 <valid_assignment+0xd8>
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12f7 <valid_assignment+0x1c7>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jl     123d <valid_assignment+0x10d>
movl   $0x0,-0x14(%rbp)
cmpl   $0x1,-0x10(%rbp)
jl     1238 <valid_assignment+0x108>
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12f2 <valid_assignment+0x1c2>
cmpl   $0x5f,-0xc(%rbp)
jle    126b <valid_assignment+0x13b>
movl   $0x0,-0x14(%rbp)
cmpl   $0x1,-0x10(%rbp)
jl     1266 <valid_assignment+0x136>
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12ed <valid_assignment+0x1bd>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x4(%rbp),%eax
cvtsi2sd %rax,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1050 <log@plt>
movsd  %xmm0,-0x28(%rbp)
movss  0xd70(%rip),%xmm0
call   1050 <log@plt>
movsd  -0x28(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x20(%rbp),%xmm0
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  0xd46(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    12e8 <valid_assignment+0x1b8>
movl   $0x0,-0x14(%rbp)
cmpl   $0x1,-0x10(%rbp)
jl     12e3 <valid_assignment+0x1b3>
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12e8 <valid_assignment+0x1b8>
jmp    12ed <valid_assignment+0x1bd>
jmp    12f2 <valid_assignment+0x1c2>
jmp    12f7 <valid_assignment+0x1c7>
jmp    12fc <valid_assignment+0x1cc>
jmp    1301 <valid_assignment+0x1d1>
jmp    1306 <valid_assignment+0x1d6>
cmpl   $0x1,-0x10(%rbp)
jl     1331 <valid_assignment+0x201>
cmpl   $0x0,-0x14(%rbp)
jne    1331 <valid_assignment+0x201>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xe0b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<valid_assignment>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %ecx,%r12d
mov    %edx,%r14d
mov    %esi,%r15d
mov    %edi,%ebx
cmp    $0x1869f,%edi
ja     1174 <valid_assignment+0x34>
test   %r12d,%r12d
jle    1274 <valid_assignment+0x134>
lea    0xfc1(%rip),%rdi
jmp    1255 <valid_assignment+0x115>
mov    %ebx,%edi
call   1050 <isprime@plt>
test   %eax,%eax
je     119f <valid_assignment+0x5f>
test   %r15d,%r15d
jle    11b4 <valid_assignment+0x74>
cmp    $0x5f,%r15d
jb     11c9 <valid_assignment+0x89>
test   %r12d,%r12d
jle    1274 <valid_assignment+0x134>
lea    0xf45(%rip),%rdi
jmp    1255 <valid_assignment+0x115>
test   %r12d,%r12d
jle    1274 <valid_assignment+0x134>
lea    0xe8e(%rip),%rdi
jmp    1255 <valid_assignment+0x115>
test   %r12d,%r12d
jle    1274 <valid_assignment+0x134>
lea    0xf43(%rip),%rdi
jmp    1255 <valid_assignment+0x115>
cmp    %r14d,%r15d
jge    11e6 <valid_assignment+0xa6>
cmp    $0x60,%r14d
jl     11f8 <valid_assignment+0xb8>
test   %r12d,%r12d
jle    1274 <valid_assignment+0x134>
lea    0xea3(%rip),%rdi
jmp    1255 <valid_assignment+0x115>
test   %r12d,%r12d
jle    1274 <valid_assignment+0x134>
lea    0xeb9(%rip),%rdi
jmp    1255 <valid_assignment+0x115>
lea    -0x1(%r14),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %ebx,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
call   1060 <log@plt>
movsd  %xmm0,(%rsp)
movss  0xdde(%rip),%xmm0
call   1060 <log@plt>
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  0x8(%rsp),%xmm0
subsd  %xmm1,%xmm0
mov    $0x1,%ebp
ucomisd 0xdc1(%rip),%xmm0
jbe    1276 <valid_assignment+0x136>
test   %r12d,%r12d
jle    1274 <valid_assignment+0x134>
lea    0xe08(%rip),%rdi
call   1030 <puts@plt>
lea    0xdaf(%rip),%rdi
xor    %ebp,%ebp
mov    %ebx,%esi
mov    %r15d,%edx
mov    %r14d,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1276 <valid_assignment+0x136>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [48 x i8] c"WARNING: exponents < 100000 are not supported!\0A\00"
@.str.1 = [33 x i8] c"WARNING: exponent is not prime!\0A\00"
@.str.2 = [42 x i8] c"WARNING: bit_min < 1 doesn't make sense!\0A\00"
@.str.3 = [41 x i8] c"WARNING: bit_min > 94 is not supported!\0A\00"
@.str.4 = [49 x i8] c"WARNING: bit_min >= bit_max doesn't make sense!\0A\00"
@.str.5 = [41 x i8] c"WARNING: bit_max > 95 is not supported!\0A\00"
@.str.6 = [43 x i8] c"WARNING: k_max > 2^63.9 is not supported!\0A\00"
@.str.7 = [45 x i8] c" Ignoring TF M%u from 2^%d to 2^%d!\0A\00"
define i32 @valid_assignment(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i32 1, i32* %9
%10 = load i32, i32* %5
%11 = icmp ult i32 %10, 100000
br i1 %11, label %12, label %18
12: ; preds = %4
store i32 0, i32* %9
%13 = load i32, i32* %8
%14 = icmp sge i32 %13, 1
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %15, %12
br label %89
18: ; preds = %4
%19 = load i32, i32* %5
%20 = call i32 @isprime(i32 %19)
%21 = icmp ne i32 %20, 0
br i1 %21, label %28, label %22
22: ; preds = %18
store i32 0, i32* %9
%23 = load i32, i32* %8
%24 = icmp sge i32 %23, 1
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
br label %27
27: ; preds = %25, %22
br label %88
28: ; preds = %18
%29 = load i32, i32* %6
%30 = icmp slt i32 %29, 1
br i1 %30, label %31, label %37
31: ; preds = %28
store i32 0, i32* %9
%32 = load i32, i32* %8
%33 = icmp sge i32 %32, 1
br i1 %33, label %34, label %36
34: ; preds = %31
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
br label %36
36: ; preds = %34, %31
br label %87
37: ; preds = %28
%38 = load i32, i32* %6
%39 = icmp sgt i32 %38, 94
br i1 %39, label %40, label %46
40: ; preds = %37
store i32 0, i32* %9
%41 = load i32, i32* %8
%42 = icmp sge i32 %41, 1
br i1 %42, label %43, label %45
43: ; preds = %40
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0))
br label %45
45: ; preds = %43, %40
br label %86
46: ; preds = %37
%47 = load i32, i32* %6
%48 = load i32, i32* %7
%49 = icmp sge i32 %47, %48
br i1 %49, label %50, label %56
50: ; preds = %46
store i32 0, i32* %9
%51 = load i32, i32* %8
%52 = icmp sge i32 %51, 1
br i1 %52, label %53, label %55
53: ; preds = %50
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.4, i64 0, i64 0))
br label %55
55: ; preds = %53, %50
br label %85
56: ; preds = %46
%57 = load i32, i32* %7
%58 = icmp sgt i32 %57, 95
br i1 %58, label %59, label %65
59: ; preds = %56
store i32 0, i32* %9
%60 = load i32, i32* %8
%61 = icmp sge i32 %60, 1
br i1 %61, label %62, label %64
62: ; preds = %59
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0))
br label %64
64: ; preds = %62, %59
br label %84
65: ; preds = %56
%66 = load i32, i32* %7
%67 = sub nsw i32 %66, 1
%68 = sitofp i32 %67 to double
%69 = load i32, i32* %5
%70 = uitofp i32 %69 to double
%71 = fptrunc double %70 to float
%72 = call double @log(float %71)
%73 = call double @log(float 2.000000e+00)
%74 = fdiv double %72, %73
%75 = fsub double %68, %74
%76 = fcmp ogt double %75, 0x404FF33340000000
br i1 %76, label %77, label %83
77: ; preds = %65
store i32 0, i32* %9
%78 = load i32, i32* %8
%79 = icmp sge i32 %78, 1
br i1 %79, label %80, label %82
80: ; preds = %77
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0))
br label %82
82: ; preds = %80, %77
br label %83
83: ; preds = %82, %65
br label %84
84: ; preds = %83, %64
br label %85
85: ; preds = %84, %55
br label %86
86: ; preds = %85, %45
br label %87
87: ; preds = %86, %36
br label %88
88: ; preds = %87, %27
br label %89
89: ; preds = %88, %17
%90 = load i32, i32* %8
%91 = icmp sge i32 %90, 1
br i1 %91, label %92, label %100
92: ; preds = %89
%93 = load i32, i32* %9
%94 = icmp eq i32 %93, 0
br i1 %94, label %95, label %100
95: ; preds = %92
%96 = load i32, i32* %5
%97 = load i32, i32* %6
%98 = load i32, i32* %7
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.7, i64 0, i64 0), i32 %96, i32 %97, i32 %98)
br label %100
100: ; preds = %95, %92, %89
%101 = load i32, i32* %9
ret i32 %101
}

LLVM IR (-O2):
@.str.7 = [45 x i8] c" Ignoring TF M%u from 2^%d to 2^%d!\0A\00"
@str = [32 x i8] c"WARNING: exponent is not prime!\00"
@str.8 = [42 x i8] c"WARNING: k_max > 2^63.9 is not supported!\00"
@str.9 = [40 x i8] c"WARNING: bit_max > 95 is not supported!\00"
@str.10 = [48 x i8] c"WARNING: bit_min >= bit_max doesn't make sense!\00"
@str.11 = [40 x i8] c"WARNING: bit_min > 94 is not supported!\00"
@str.12 = [41 x i8] c"WARNING: bit_min < 1 doesn't make sense!\00"
@str.13 = [47 x i8] c"WARNING: exponents < 100000 are not supported!\00"
define i32 @valid_assignment(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp ult i32 %0, 100000
br i1 %5, label %6, label %8
6: ; preds = %4
%7 = icmp sgt i32 %3, 0
br i1 %7, label %40, label %44
8: ; preds = %4
%9 = tail call i32 @isprime(i32 %0)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = icmp sgt i32 %3, 0
br i1 %12, label %40, label %44
13: ; preds = %8
%14 = icmp slt i32 %1, 1
br i1 %14, label %15, label %17
15: ; preds = %13
%16 = icmp sgt i32 %3, 0
br i1 %16, label %40, label %44
17: ; preds = %13
%18 = icmp ugt i32 %1, 94
br i1 %18, label %19, label %21
19: ; preds = %17
%20 = icmp sgt i32 %3, 0
br i1 %20, label %40, label %44
21: ; preds = %17
%22 = icmp slt i32 %1, %2
br i1 %22, label %25, label %23
23: ; preds = %21
%24 = icmp sgt i32 %3, 0
br i1 %24, label %40, label %44
25: ; preds = %21
%26 = icmp sgt i32 %2, 95
br i1 %26, label %27, label %29
27: ; preds = %25
%28 = icmp sgt i32 %3, 0
br i1 %28, label %40, label %44
29: ; preds = %25
%30 = add nsw i32 %2, -1
%31 = sitofp i32 %30 to double
%32 = uitofp i32 %0 to float
%33 = tail call double @log(float %32)
%34 = tail call double @log(float 2.000000e+00)
%35 = fdiv double %33, %34
%36 = fsub double %31, %35
%37 = fcmp ogt double %36, 0x404FF33340000000
br i1 %37, label %38, label %44
38: ; preds = %29
%39 = icmp sgt i32 %3, 0
br i1 %39, label %40, label %44
40: ; preds = %38, %27, %23, %19, %15, %11, %6
%41 = phi i8* [ getelementptr inbounds ([47 x i8], [47 x i8]* @str.13, i64 0, i64 0), %6 ], [ getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0), %11 ], [ getelementptr inbounds ([41 x i8], [41 x i8]* @str.12, i64 0, i64 0), %15 ], [ getelementptr inbounds ([40 x i8], [40 x i8]* @str.11, i64 0, i64 0), %19 ], [ getelementptr inbounds ([48 x i8], [48 x i8]* @str.10, i64 0, i64 0), %23 ], [ getelementptr inbounds ([40 x i8], [40 x i8]* @str.9, i64 0, i64 0), %27 ], [ getelementptr inbounds ([42 x i8], [42 x i8]* @str.8, i64 0, i64 0), %38 ]
%42 = tail call i32 @puts(i8* dereferenceable(1) %41)
%43 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.7, i64 0, i64 0), i32 %0, i32 %1, i32 %2)
br label %44
44: ; preds = %29, %6, %15, %23, %38, %27, %19, %11, %40
%45 = phi i32 [ 0, %40 ], [ 0, %6 ], [ 0, %15 ], [ 0, %23 ], [ 1, %29 ], [ 0, %38 ], [ 0, %27 ], [ 0, %19 ], [ 0, %11 ]
ret i32 %45
}