#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_add_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 (u1 < *r1)
    u2++;
  cy = ularith_gt_2ul_2ul(a1, a2, u1, u2);
  *r1 = u1;
  *r2 = u2;
  return cy;
}


x86 assembly (clang, -O0):
<ularith_add_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
add    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
add    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x8(%rbp),%rcx
cmp    (%rcx),%rax
jae    1163 <ularith_add_2ul_2ul_cy+0x53>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x38(%rbp),%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_add_2ul_2ul_cy>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
mov    (%rdi),%r12
add    %rdx,%r12
mov    (%rsi),%rbx
adc    %rcx,%rbx
mov    %rdx,%rdi
mov    %rcx,%rsi
mov    %r12,%rdx
mov    %rbx,%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_add_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 = add i64 %13, %14
store i64 %15, i64* %10
%16 = load i64*, i64** %6
%17 = load i64, i64* %16
%18 = load i64, i64* %8
%19 = add i64 %17, %18
store i64 %19, i64* %11
%20 = load i64, i64* %10
%21 = load i64*, i64** %5
%22 = load i64, i64* %21
%23 = icmp ult 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* %10
%31 = load i64, i64* %11
%32 = call signext i8 @ularith_gt_2ul_2ul(i64 %28, i64 %29, i64 %30, i64 %31)
store i8 %32, i8* %9
%33 = load i64, i64* %10
%34 = load i64*, i64** %5
store i64 %33, i64* %34
%35 = load i64, i64* %11
%36 = load i64*, i64** %6
store i64 %35, i64* %36
%37 = load i8, i8* %9
ret i8 %37
}

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