#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 */

/* Variables and functions */
char ularith_gt_2ul_2ul(unsigned long const, unsigned long const, unsigned long,
                        unsigned long);
char ularith_sub_2ul_2ul_cy(unsigned long *r1, unsigned long *r2,
                            const unsigned long a1, const unsigned long a2) {
  char cy;
  unsigned long u1 = *r1 - a1, u2 = *r2 - a2;
  if (a1 > *r1)
    u2--;
  cy = ularith_gt_2ul_2ul(a1, a2, *r1, *r2);
  *r1 = u1;
  *r2 = u2;
  return cy;
}


x86 assembly (clang, -O0):
<ularith_sub_2ul_2ul_cy>:
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    -0x8(%rbp),%rax
mov    (%rax),%rax
sub    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
sub    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%rcx
cmp    (%rcx),%rax
jbe    1163 <ularith_sub_2ul_2ul_cy+0x53>
mov    -0x38(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x8(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
call   1030 <ularith_gt_2ul_2ul@plt>
mov    %al,-0x21(%rbp)
mov    -0x30(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x38(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
movsbl -0x21(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ularith_sub_2ul_2ul_cy>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r8
mov    %rsi,%r14
mov    %rdi,%r15
mov    (%rdi),%rdx
mov    (%rsi),%rax
mov    %rdx,%r12
sub    %r8,%r12
mov    %rax,%rbx
sbb    %rcx,%rbx
mov    %r8,%rdi
mov    %rcx,%rsi
mov    %rax,%rcx
call   1030 <ularith_gt_2ul_2ul@plt>
mov    %r12,(%r15)
mov    %rbx,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define signext i8 @ularith_sub_2ul_2ul_cy(i64* %0, i64* %1, i64 %2, i64 %3) {
%5 = alloca i64*
%6 = alloca i64*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i8
%10 = alloca i64
%11 = alloca i64
store i64* %0, i64** %5
store i64* %1, i64** %6
store i64 %2, i64* %7
store i64 %3, i64* %8
%12 = load i64*, i64** %5
%13 = load i64, i64* %12
%14 = load i64, i64* %7
%15 = sub i64 %13, %14
store i64 %15, i64* %10
%16 = load i64*, i64** %6
%17 = load i64, i64* %16
%18 = load i64, i64* %8
%19 = sub i64 %17, %18
store i64 %19, i64* %11
%20 = load i64, i64* %7
%21 = load i64*, i64** %5
%22 = load i64, i64* %21
%23 = icmp ugt i64 %20, %22
br i1 %23, label %24, label %27
24: ; preds = %4
%25 = load i64, i64* %11
%26 = add i64 %25, -1
store i64 %26, i64* %11
br label %27
27: ; preds = %24, %4
%28 = load i64, i64* %7
%29 = load i64, i64* %8
%30 = load i64*, i64** %5
%31 = load i64, i64* %30
%32 = load i64*, i64** %6
%33 = load i64, i64* %32
%34 = call signext i8 @ularith_gt_2ul_2ul(i64 %28, i64 %29, i64 %31, i64 %33)
store i8 %34, i8* %9
%35 = load i64, i64* %10
%36 = load i64*, i64** %5
store i64 %35, i64* %36
%37 = load i64, i64* %11
%38 = load i64*, i64** %6
store i64 %37, i64* %38
%39 = load i8, i8* %9
ret i8 %39
}

LLVM IR (-O2):
define signext i8 @ularith_sub_2ul_2ul_cy(i64* nocapture %0, i64* nocapture %1, i64 %2, i64 %3) {
%5 = load i64, i64* %0
%6 = load i64, i64* %1
%7 = sub i64 %6, %3
%8 = icmp ult i64 %5, %2
%9 = sext i1 %8 to i64
%10 = add i64 %7, %9
%11 = sub i64 %5, %2
%12 = tail call signext i8 @ularith_gt_2ul_2ul(i64 %2, i64 %3, i64 %5, i64 %6)
store i64 %11, i64* %0
store i64 %10, i64* %1
ret i8 %12
}