#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 */
struct gbuf {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ assert(int);
size_t gbuf_offset(struct gbuf const *);
size_t gbuf_roffset(struct gbuf const *);
size_t gbuf_size(struct gbuf const *);
int is_power_of_2(size_t);
int gbuf_isuniform(struct gbuf const *buf, size_t size, size_t align) {
  assert(buf != NULL);
  assert(size != 0);
  assert(is_power_of_2(align));
  return (gbuf_size(buf) % size == 0) && (gbuf_offset(buf) % size == 0) &&
         (gbuf_roffset(buf) % align == 0);
}


x86 assembly (clang, -O0):
<gbuf_isuniform>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x8(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x18(%rbp),%rdi
call   1050 <is_power_of_2@plt>
mov    %eax,%edi
call   1060 <assert@plt>
mov    -0x8(%rbp),%rdi
call   1040 <gbuf_size@plt>
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x10(%rbp)
xor    %eax,%eax
cmp    $0x0,%rdx
mov    %al,-0x19(%rbp)
jne    11f3 <gbuf_isuniform+0xa3>
mov    -0x8(%rbp),%rdi
call   1030 <gbuf_offset@plt>
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x10(%rbp)
xor    %eax,%eax
cmp    $0x0,%rdx
mov    %al,-0x19(%rbp)
jne    11f3 <gbuf_isuniform+0xa3>
mov    -0x8(%rbp),%rdi
call   1070 <gbuf_roffset@plt>
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x18(%rbp)
cmp    $0x0,%rdx
sete   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gbuf_isuniform>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
xor    %edi,%edi
test   %r15,%r15
setne  %dil
call   1060 <assert@plt>
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1060 <assert@plt>
mov    %r14,%rdi
call   1050 <is_power_of_2@plt>
mov    %eax,%edi
call   1060 <assert@plt>
mov    %r15,%rdi
call   1040 <gbuf_size@plt>
mov    %rax,%rcx
or     %rbx,%rcx
shr    $0x20,%rcx
je     11a6 <gbuf_isuniform+0x56>
xor    %edx,%edx
div    %rbx
jmp    11aa <gbuf_isuniform+0x5a>
xor    %edx,%edx
div    %ebx
xor    %ebp,%ebp
test   %rdx,%rdx
jne    1203 <gbuf_isuniform+0xb3>
mov    %r15,%rdi
call   1030 <gbuf_offset@plt>
mov    %rax,%rcx
or     %rbx,%rcx
shr    $0x20,%rcx
je     11d1 <gbuf_isuniform+0x81>
xor    %edx,%edx
div    %rbx
test   %rdx,%rdx
jne    1203 <gbuf_isuniform+0xb3>
jmp    11da <gbuf_isuniform+0x8a>
xor    %edx,%edx
div    %ebx
test   %rdx,%rdx
jne    1203 <gbuf_isuniform+0xb3>
mov    %r15,%rdi
call   1070 <gbuf_roffset@plt>
mov    %rax,%rcx
or     %r14,%rcx
shr    $0x20,%rcx
je     11f5 <gbuf_isuniform+0xa5>
xor    %edx,%edx
div    %r14
jmp    11fa <gbuf_isuniform+0xaa>
xor    %edx,%edx
div    %r14d
xor    %ebp,%ebp
test   %rdx,%rdx
sete   %bpl
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.gbuf = type { i32 }
define i32 @gbuf_isuniform(%struct.gbuf* %0, i64 %1, i64 %2) {
%4 = alloca %struct.gbuf*
%5 = alloca i64
%6 = alloca i64
store %struct.gbuf* %0, %struct.gbuf** %4
store i64 %1, i64* %5
store i64 %2, i64* %6
%7 = load %struct.gbuf*, %struct.gbuf** %4
%8 = icmp ne %struct.gbuf* %7, null
%9 = zext i1 %8 to i32
%10 = call i32 @assert(i32 %9)
%11 = load i64, i64* %5
%12 = icmp ne i64 %11, 0
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = load i64, i64* %6
%16 = call i32 @is_power_of_2(i64 %15)
%17 = call i32 @assert(i32 %16)
%18 = load %struct.gbuf*, %struct.gbuf** %4
%19 = call i64 @gbuf_size(%struct.gbuf* %18)
%20 = load i64, i64* %5
%21 = urem i64 %19, %20
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %35
23: ; preds = %3
%24 = load %struct.gbuf*, %struct.gbuf** %4
%25 = call i64 @gbuf_offset(%struct.gbuf* %24)
%26 = load i64, i64* %5
%27 = urem i64 %25, %26
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %35
29: ; preds = %23
%30 = load %struct.gbuf*, %struct.gbuf** %4
%31 = call i64 @gbuf_roffset(%struct.gbuf* %30)
%32 = load i64, i64* %6
%33 = urem i64 %31, %32
%34 = icmp eq i64 %33, 0
br label %35
35: ; preds = %29, %23, %3
%36 = phi i1 [ false, %23 ], [ false, %3 ], [ %34, %29 ]
%37 = zext i1 %36 to i32
ret i32 %37
}

LLVM IR (-O2):
%struct.gbuf = type { i32 }
define i32 @gbuf_isuniform(%struct.gbuf* %0, i64 %1, i64 %2) {
%4 = icmp ne %struct.gbuf* %0, null
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = icmp ne i64 %1, 0
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = tail call i32 @is_power_of_2(i64 %2)
%11 = tail call i32 @assert(i32 %10)
%12 = tail call i64 @gbuf_size(%struct.gbuf* %0)
%13 = urem i64 %12, %1
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %24
15: ; preds = %3
%16 = tail call i64 @gbuf_offset(%struct.gbuf* %0)
%17 = urem i64 %16, %1
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %24
19: ; preds = %15
%20 = tail call i64 @gbuf_roffset(%struct.gbuf* %0)
%21 = urem i64 %20, %2
%22 = icmp eq i64 %21, 0
%23 = zext i1 %22 to i32
br label %24
24: ; preds = %19, %15, %3
%25 = phi i32 [ 0, %15 ], [ 0, %3 ], [ %23, %19 ]
ret i32 %25
}