#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 */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ emit_adcimm(int /*<<< orphan*/, int);
int /*<<< orphan*/ emit_cmp(int, int);
int /*<<< orphan*/ emit_mov(int, int);
int /*<<< orphan*/ emit_movimm(int /*<<< orphan*/, int);
int /*<<< orphan*/ emit_sbb(int, int);
void emit_set_if_carry64_32(int u1, int l1, int u2, int l2, int rt) {
  assert(u1 != rt);
  assert(u2 != rt);
  emit_cmp(l1, l2);
  emit_mov(u1, rt);
  emit_sbb(u2, rt);
  emit_movimm(0, rt);
  emit_adcimm(0, rt);
}


x86 assembly (clang, -O0):
<emit_set_if_carry64_32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x14(%rbp),%eax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0xc(%rbp),%eax
cmp    -0x14(%rbp),%eax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1040 <emit_cmp@plt>
mov    -0x4(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1050 <emit_mov@plt>
mov    -0xc(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1070 <emit_sbb@plt>
mov    -0x14(%rbp),%esi
xor    %edi,%edi
call   1080 <emit_movimm@plt>
mov    -0x14(%rbp),%esi
xor    %edi,%edi
call   1030 <emit_adcimm@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<emit_set_if_carry64_32>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8d,%ebx
mov    %ecx,%r14d
mov    %edx,%r12d
mov    %esi,%r15d
mov    %edi,%ebp
xor    %edi,%edi
cmp    %r8d,%ebp
setne  %dil
call   1060 <assert@plt>
xor    %edi,%edi
cmp    %ebx,%r12d
setne  %dil
call   1060 <assert@plt>
mov    %r15d,%edi
mov    %r14d,%esi
call   1040 <emit_cmp@plt>
mov    %ebp,%edi
mov    %ebx,%esi
call   1050 <emit_mov@plt>
mov    %r12d,%edi
mov    %ebx,%esi
call   1070 <emit_sbb@plt>
xor    %edi,%edi
mov    %ebx,%esi
call   1080 <emit_movimm@plt>
xor    %edi,%edi
mov    %ebx,%esi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <emit_adcimm@plt>

LLVM IR (-O0):
define void @emit_set_if_carry64_32(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%11 = load i32, i32* %6
%12 = load i32, i32* %10
%13 = icmp ne i32 %11, %12
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = load i32, i32* %8
%17 = load i32, i32* %10
%18 = icmp ne i32 %16, %17
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = load i32, i32* %7
%22 = load i32, i32* %9
%23 = call i32 @emit_cmp(i32 %21, i32 %22)
%24 = load i32, i32* %6
%25 = load i32, i32* %10
%26 = call i32 @emit_mov(i32 %24, i32 %25)
%27 = load i32, i32* %8
%28 = load i32, i32* %10
%29 = call i32 @emit_sbb(i32 %27, i32 %28)
%30 = load i32, i32* %10
%31 = call i32 @emit_movimm(i32 0, i32 %30)
%32 = load i32, i32* %10
%33 = call i32 @emit_adcimm(i32 0, i32 %32)
ret void
}

LLVM IR (-O2):
define void @emit_set_if_carry64_32(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = icmp ne i32 %0, %4
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
%9 = icmp ne i32 %2, %4
%10 = zext i1 %9 to i32
%11 = tail call i32 @assert(i32 %10)
%12 = tail call i32 @emit_cmp(i32 %1, i32 %3)
%13 = tail call i32 @emit_mov(i32 %0, i32 %4)
%14 = tail call i32 @emit_sbb(i32 %2, i32 %4)
%15 = tail call i32 @emit_movimm(i32 0, i32 %4)
%16 = tail call i32 @emit_adcimm(i32 0, i32 %4)
ret void
}