#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 */
typedef scalar_t__ uint8_t;
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ rgph_fastdiv_prepare(int, int *, scalar_t__ *, scalar_t__ *,
                                        size_t, int *);
bool is_fastdiv(uint32_t n, size_t nbits) {
  uint32_t mul;
  uint8_t s1 = 0, s2;
  int inc = 1;
  if (n & (n - 1))
    rgph_fastdiv_prepare(n, &mul, &s1, &s2, nbits, &inc);
  return s1 == 0 && inc == 0;
}


x86 assembly (clang, -O0):
<is_fastdiv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x1,-0x2c(%rbp)
mov    -0x4(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     115e <is_fastdiv+0x4e>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%r8
lea    -0x14(%rbp),%rsi
lea    -0x20(%rbp),%rdx
lea    -0x28(%rbp),%rcx
lea    -0x2c(%rbp),%r9
call   1030 <rgph_fastdiv_prepare@plt>
xor    %eax,%eax
cmpq   $0x0,-0x20(%rbp)
mov    %al,-0x2d(%rbp)
jne    1178 <is_fastdiv+0x68>
cmpl   $0x0,-0x2c(%rbp)
sete   %al
mov    %al,-0x2d(%rbp)
mov    -0x2d(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_fastdiv>:
sub    $0x28,%rsp
movq   $0x0,0x10(%rsp)
movl   $0x1,0xc(%rsp)
lea    -0x1(%rdi),%ecx
xor    %eax,%eax
test   %ecx,%edi
je     1160 <is_fastdiv+0x50>
mov    %rsi,%r8
lea    0x1c(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0x20(%rsp),%rcx
lea    0xc(%rsp),%r9
call   1030 <rgph_fastdiv_prepare@plt>
cmpq   $0x0,0x10(%rsp)
sete   %al
cmpl   $0x0,0xc(%rsp)
sete   %cl
and    %al,%cl
movzbl %cl,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
define i32 @is_fastdiv(i32 %0, i64 %1) {
%3 = alloca i32
%4 = alloca i64
%5 = alloca i32
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
store i32 %0, i32* %3
store i64 %1, i64* %4
store i64 0, i64* %6
store i32 1, i32* %8
%9 = load i32, i32* %3
%10 = load i32, i32* %3
%11 = sub nsw i32 %10, 1
%12 = and i32 %9, %11
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %2
%15 = load i32, i32* %3
%16 = load i64, i64* %4
%17 = call i32 @rgph_fastdiv_prepare(i32 %15, i32* %5, i64* %6, i64* %7, i64 %16, i32* %8)
br label %18
18: ; preds = %14, %2
%19 = load i64, i64* %6
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = load i32, i32* %8
%23 = icmp eq i32 %22, 0
br label %24
24: ; preds = %21, %18
%25 = phi i1 [ false, %18 ], [ %23, %21 ]
%26 = zext i1 %25 to i32
ret i32 %26
}

LLVM IR (-O2):
define i32 @is_fastdiv(i32 %0, i64 %1) {
%3 = alloca i32
%4 = alloca i64
%5 = alloca i64
%6 = alloca i32
%7 = bitcast i32* %3 to i8*
%8 = bitcast i64* %4 to i8*
store i64 0, i64* %4
%9 = bitcast i64* %5 to i8*
%10 = bitcast i32* %6 to i8*
store i32 1, i32* %6
%11 = tail call i32 @llvm.ctpop.i32(i32 %0)
%12 = icmp ult i32 %11, 2
br i1 %12, label %21, label %13
13: ; preds = %2
%14 = call i32 @rgph_fastdiv_prepare(i32 %0, i32* %3, i64* %4, i64* %5, i64 %1, i32* %6)
%15 = load i64, i64* %4
%16 = load i32, i32* %6
%17 = icmp eq i64 %15, 0
%18 = icmp eq i32 %16, 0
%19 = select i1 %17, i1 %18, i1 false
%20 = zext i1 %19 to i32
br label %21
21: ; preds = %13, %2
%22 = phi i32 [ %20, %13 ], [ 0, %2 ]
ret i32 %22
}