int isin(int n, int maxval) {
  static const int tab[] = {
      0,          104528463,  207911690,  309016994,   406736643,  499999999,
      587785252,  669130606,  743144825,  809016994,   866025403,  913545457,
      951056516,  978147600,  994521895,  1000000000,  994521895,  978147600,
      951056516,  913545457,  866025403,  809016994,   743144825,  669130606,
      587785252,  499999999,  406736643,  309016994,   207911690,  104528463,
      0,          -104528463, -207911690, -309016994,  -406736643, -500000000,
      -587785252, -669130606, -743144825, -809016994,  -866025403, -913545457,
      -951056516, -978147600, -994521895, -1000000000, -994521895, -978147600,
      -951056516, -913545457, -866025403, -809016994,  -743144825, -669130606,
      -587785252, -499999999, -406736643, -309016994,  -207911690, -104528463,
  };
  if (n < 0)
    n += 60;
  return tab[n % 60] / 1000 * maxval / 1000000;
}


x86 assembly (clang, -O0):
<isin>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    111d <isin+0x1d>
mov    -0x4(%rbp),%eax
add    $0x3c,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
movslq %edx,%rcx
lea    0xece(%rip),%rax
mov    (%rax,%rcx,4),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
imul   -0x8(%rbp),%eax
mov    $0xf4240,%ecx
cltd
idiv   %ecx
pop    %rbp
ret

x86 assembly (clang, -O2):
<isin>:
lea    0x3c(%rdi),%eax
test   %edi,%edi
cmovns %edi,%eax
cltq
imul   $0xffffffff88888889,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x5,%ecx
add    %edx,%ecx
imul   $0x3c,%ecx,%ecx
sub    %ecx,%eax
cltq
lea    0xed1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
imul   $0x10624dd3,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rax
add    %ecx,%eax
imul   %esi,%eax
cltq
imul   $0x431bde83,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x32,%rax
add    %ecx,%eax
ret

LLVM IR (-O0):
@isin.tab = internal constant [60 x i32] [i32 0, i32 104528463, i32 207911690, i32 309016994, i32 406736643, i32 499999999, i32 587785252, i32 669130606, i32 743144825, i32 809016994, i32 866025403, i32 913545457, i32 951056516, i32 978147600, i32 994521895, i32 1000000000, i32 994521895, i32 978147600, i32 951056516, i32 913545457, i32 866025403, i32 809016994, i32 743144825, i32 669130606, i32 587785252, i32 499999999, i32 406736643, i32 309016994, i32 207911690, i32 104528463, i32 0, i32 -104528463, i32 -207911690, i32 -309016994, i32 -406736643, i32 -500000000, i32 -587785252, i32 -669130606, i32 -743144825, i32 -809016994, i32 -866025403, i32 -913545457, i32 -951056516, i32 -978147600, i32 -994521895, i32 -1000000000, i32 -994521895, i32 -978147600, i32 -951056516, i32 -913545457, i32 -866025403, i32 -809016994, i32 -743144825, i32 -669130606, i32 -587785252, i32 -499999999, i32 -406736643, i32 -309016994, i32 -207911690, i32 -104528463]
define i32 @isin(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = load i32, i32* %3
%9 = add nsw i32 %8, 60
store i32 %9, i32* %3
br label %10
10: ; preds = %7, %2
%11 = load i32, i32* %3
%12 = srem i32 %11, 60
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [60 x i32], [60 x i32]* @isin.tab, i64 0, i64 %13
%15 = load i32, i32* %14
%16 = sdiv i32 %15, 1000
%17 = load i32, i32* %4
%18 = mul nsw i32 %16, %17
%19 = sdiv i32 %18, 1000000
ret i32 %19
}

LLVM IR (-O2):
@isin.tab = internal unnamed_addr constant [60 x i32] [i32 0, i32 104528463, i32 207911690, i32 309016994, i32 406736643, i32 499999999, i32 587785252, i32 669130606, i32 743144825, i32 809016994, i32 866025403, i32 913545457, i32 951056516, i32 978147600, i32 994521895, i32 1000000000, i32 994521895, i32 978147600, i32 951056516, i32 913545457, i32 866025403, i32 809016994, i32 743144825, i32 669130606, i32 587785252, i32 499999999, i32 406736643, i32 309016994, i32 207911690, i32 104528463, i32 0, i32 -104528463, i32 -207911690, i32 -309016994, i32 -406736643, i32 -500000000, i32 -587785252, i32 -669130606, i32 -743144825, i32 -809016994, i32 -866025403, i32 -913545457, i32 -951056516, i32 -978147600, i32 -994521895, i32 -1000000000, i32 -994521895, i32 -978147600, i32 -951056516, i32 -913545457, i32 -866025403, i32 -809016994, i32 -743144825, i32 -669130606, i32 -587785252, i32 -499999999, i32 -406736643, i32 -309016994, i32 -207911690, i32 -104528463]
define i32 @isin(i32 %0, i32 %1) {
%3 = icmp slt i32 %0, 0
%4 = add nsw i32 %0, 60
%5 = select i1 %3, i32 %4, i32 %0
%6 = srem i32 %5, 60
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds [60 x i32], [60 x i32]* @isin.tab, i64 0, i64 %7
%9 = load i32, i32* %8
%10 = sdiv i32 %9, 1000
%11 = mul nsw i32 %10, %1
%12 = sdiv i32 %11, 1000000
ret i32 %12
}