unsigned QvalToIangle(unsigned qV) {
  unsigned s, ip, fp;
  unsigned ia;
  s = 0;
  if (qV & 0x80000000) {
    qV &= 0x7FFFFFFF;
    s = 1;
  }
  if (qV >= 94388224) {
    qV %= 23592960;
  }
  ip = qV >> 7;
  ia = ip * 2912;
  fp = ia & 0x0000FFFF;
  ia = ia >> 16;
  if (fp >= 0x8000)
    ia++;
  if (s == 1)
    ia = -ia;
  return ia;
}


x86 assembly (clang, -O0):
<QvalToIangle>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x80000000,%eax
cmp    $0x0,%eax
je     1131 <QvalToIangle+0x31>
mov    -0x4(%rbp),%eax
and    $0x7fffffff,%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
cmpl   $0x5a04000,-0x4(%rbp)
jb     114d <QvalToIangle+0x4d>
mov    -0x4(%rbp),%eax
mov    $0x1680000,%ecx
xor    %edx,%edx
div    %ecx
mov    %edx,-0x4(%rbp)
mov    -0x4(%rbp),%eax
shr    $0x7,%eax
mov    %eax,-0xc(%rbp)
imul   $0xb60,-0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
and    $0xffff,%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
shr    $0x10,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x8000,-0x10(%rbp)
jb     118a <QvalToIangle+0x8a>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    119c <QvalToIangle+0x9c>
xor    %eax,%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<QvalToIangle>:
mov    %edi,%eax
and    $0x7fffffff,%eax
cmp    $0x5a04000,%eax
jb     1126 <QvalToIangle+0x26>
mov    %eax,%ecx
shr    $0x13,%ecx
imul   $0x5b05b06,%rcx,%rcx
shr    $0x20,%rcx
imul   $0x1680000,%ecx,%ecx
sub    %ecx,%eax
shr    $0x7,%eax
imul   $0xb60,%eax,%ecx
mov    %ecx,%eax
shr    $0x10,%eax
shr    $0xf,%ecx
and    $0x1,%ecx
add    %eax,%ecx
mov    %ecx,%eax
neg    %eax
test   %edi,%edi
cmovns %ecx,%eax
ret

LLVM IR (-O0):
define i32 @QvalToIangle(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
%7 = load i32, i32* %2
%8 = and i32 %7, -2147483648
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = load i32, i32* %2
%12 = and i32 %11, 2147483647
store i32 %12, i32* %2
store i32 1, i32* %3
br label %13
13: ; preds = %10, %1
%14 = load i32, i32* %2
%15 = icmp uge i32 %14, 94388224
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = load i32, i32* %2
%18 = urem i32 %17, 23592960
store i32 %18, i32* %2
br label %19
19: ; preds = %16, %13
%20 = load i32, i32* %2
%21 = lshr i32 %20, 7
store i32 %21, i32* %4
%22 = load i32, i32* %4
%23 = mul i32 %22, 2912
store i32 %23, i32* %6
%24 = load i32, i32* %6
%25 = and i32 %24, 65535
store i32 %25, i32* %5
%26 = load i32, i32* %6
%27 = lshr i32 %26, 16
store i32 %27, i32* %6
%28 = load i32, i32* %5
%29 = icmp uge i32 %28, 32768
br i1 %29, label %30, label %33
30: ; preds = %19
%31 = load i32, i32* %6
%32 = add i32 %31, 1
store i32 %32, i32* %6
br label %33
33: ; preds = %30, %19
%34 = load i32, i32* %3
%35 = icmp eq i32 %34, 1
br i1 %35, label %36, label %39
36: ; preds = %33
%37 = load i32, i32* %6
%38 = sub i32 0, %37
store i32 %38, i32* %6
br label %39
39: ; preds = %36, %33
%40 = load i32, i32* %6
ret i32 %40
}

LLVM IR (-O2):
define i32 @QvalToIangle(i32 %0) {
%2 = icmp sgt i32 %0, -1
%3 = and i32 %0, 2147483647
%4 = icmp ugt i32 %3, 94388223
%5 = urem i32 %3, 23592960
%6 = select i1 %4, i32 %5, i32 %3
%7 = lshr i32 %6, 7
%8 = mul nuw nsw i32 %7, 2912
%9 = lshr i32 %8, 16
%10 = lshr i32 %8, 15
%11 = and i32 %10, 1
%12 = add nuw nsw i32 %11, %9
%13 = sub nsw i32 0, %12
%14 = select i1 %2, i32 %12, i32 %13
ret i32 %14
}