#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 unsigned long mp_limb_t;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
unsigned long mpn_divmod_1(unsigned long *, unsigned long *, int,
                           unsigned long const);
void ularith_div_2ul_ul_ul_r(unsigned long *r, unsigned long a1,
                             const unsigned long a2, const unsigned long b) {
  assert(a2 < b);
  mp_limb_t A[2] = {a1, a2};
  assert(sizeof(unsigned long) == sizeof(mp_limb_t));
  r[0] = mpn_divmod_1(A, A, 2, b);
}


x86 assembly (clang, -O0):
<ularith_div_2ul_ul_ul_r>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
setb   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    $0x1,%edi
call   1030 <assert@plt>
lea    -0x30(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    -0x20(%rbp),%rcx
mov    $0x2,%edx
call   1040 <mpn_divmod_1@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ularith_div_2ul_ul_ul_r>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%r14
mov    %rdx,%rbx
mov    %rsi,%r15
mov    %rdi,%r12
xor    %edi,%edi
cmp    %rcx,%rdx
setb   %dil
call   1030 <assert@plt>
mov    %r15,(%rsp)
mov    %rbx,0x8(%rsp)
mov    $0x1,%edi
call   1030 <assert@plt>
mov    %rsp,%rdi
mov    %rdi,%rsi
mov    $0x2,%edx
mov    %r14,%rcx
call   1040 <mpn_divmod_1@plt>
mov    %rax,(%r12)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @ularith_div_2ul_ul_ul_r(i64* %0, i64 %1, i64 %2, i64 %3) {
%5 = alloca i64*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca [2 x i64]
store i64* %0, i64** %5
store i64 %1, i64* %6
store i64 %2, i64* %7
store i64 %3, i64* %8
%10 = load i64, i64* %7
%11 = load i64, i64* %8
%12 = icmp ult i64 %10, %11
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = getelementptr inbounds [2 x i64], [2 x i64]* %9, i64 0, i64 0
%16 = load i64, i64* %6
store i64 %16, i64* %15
%17 = getelementptr inbounds i64, i64* %15, i64 1
%18 = load i64, i64* %7
store i64 %18, i64* %17
%19 = call i32 @assert(i32 1)
%20 = getelementptr inbounds [2 x i64], [2 x i64]* %9, i64 0, i64 0
%21 = getelementptr inbounds [2 x i64], [2 x i64]* %9, i64 0, i64 0
%22 = load i64, i64* %8
%23 = call i64 @mpn_divmod_1(i64* %20, i64* %21, i32 2, i64 %22)
%24 = load i64*, i64** %5
%25 = getelementptr inbounds i64, i64* %24, i64 0
store i64 %23, i64* %25
ret void
}

LLVM IR (-O2):
define void @ularith_div_2ul_ul_ul_r(i64* nocapture writeonly %0, i64 %1, i64 %2, i64 %3) {
%5 = alloca [2 x i64]
%6 = icmp ult i64 %2, %3
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
%9 = bitcast [2 x i64]* %5 to i8*
%10 = getelementptr inbounds [2 x i64], [2 x i64]* %5, i64 0, i64 0
store i64 %1, i64* %10
%11 = getelementptr inbounds [2 x i64], [2 x i64]* %5, i64 0, i64 1
store i64 %2, i64* %11
%12 = tail call i32 @assert(i32 1)
%13 = call i64 @mpn_divmod_1(i64* %10, i64* %10, i32 2, i64 %3)
store i64 %13, i64* %0
ret void
}