#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 const mp_limb_t;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
unsigned long mpn_divmod_1(unsigned long const *, unsigned long const *, int,
                           unsigned long const);
void ularith_div_2ul_ul_ul(unsigned long *q, unsigned long *r,
                           const 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);
  q[0] = A[0];
}


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

x86 assembly (clang, -O2):
<ularith_div_2ul_ul_ul>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %r8,%r14
mov    %rcx,%rbx
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%r13
xor    %edi,%edi
cmp    %r8,%rcx
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)
mov    (%rsp),%rax
mov    %rax,0x0(%r13)
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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