#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 */
struct cpu {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ cpu_set_r8(struct cpu *, int /*<<< orphan*/, unsigned char);
void cpu_sbc_flags(struct cpu *cpu, unsigned char a, unsigned char b,
                   signed int t) {
  unsigned int carries = (t & 0x1FFFF) ^ a ^ b;
  unsigned char z = (t & 0xFF) ? 0 : ((unsigned char)(0x80));
  unsigned char n = ((unsigned char)(0x40));
  unsigned char h = carries & 0x10 ? 0 : ((unsigned char)(0x20));
  unsigned char c = carries & 0x100 ? 0 : ((unsigned char)(0x10));
  cpu_set_r8(cpu, (0), z | n | h | c);
}


x86 assembly (clang, -O0):
<cpu_sbc_flags>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dl,%al
mov    %sil,%dl
mov    %rdi,-0x8(%rbp)
mov    %dl,-0x9(%rbp)
mov    %al,-0xa(%rbp)
mov    %ecx,-0x10(%rbp)
mov    -0x10(%rbp),%eax
and    $0x1ffff,%eax
movzbl -0x9(%rbp),%ecx
xor    %ecx,%eax
movzbl -0xa(%rbp),%ecx
xor    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%edx
and    $0xff,%edx
mov    $0x80,%eax
xor    %ecx,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,-0x15(%rbp)
movb   $0x40,-0x16(%rbp)
mov    -0x14(%rbp),%edx
and    $0x10,%edx
mov    $0x20,%eax
xor    %ecx,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,-0x17(%rbp)
mov    -0x14(%rbp),%edx
and    $0x100,%edx
mov    $0x10,%eax
xor    %ecx,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
movzbl -0x15(%rbp),%eax
movzbl -0x16(%rbp),%ecx
or     %ecx,%eax
movzbl -0x17(%rbp),%ecx
or     %ecx,%eax
movzbl -0x18(%rbp),%ecx
or     %ecx,%eax
xor    %esi,%esi
movzbl %al,%edx
call   1030 <cpu_set_r8@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cpu_sbc_flags>:
xor    %edx,%esi
xor    %ecx,%esi
xor    %eax,%eax
test   %cl,%cl
sete   %al
and    $0x10,%esi
shr    $0x4,%ecx
and    $0x10,%ecx
shl    $0x7,%eax
or     %ecx,%eax
lea    (%rax,%rsi,2),%eax
or     $0x40,%al
xor    $0x30,%al
movzbl %al,%edx
xor    %esi,%esi
jmp    1030 <cpu_set_r8@plt>

LLVM IR (-O0):
%struct.cpu = type { i32 }
define void @cpu_sbc_flags(%struct.cpu* %0, i8 zeroext %1, i8 zeroext %2, i32 %3) {
%5 = alloca %struct.cpu*
%6 = alloca i8
%7 = alloca i8
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8
%11 = alloca i8
%12 = alloca i8
%13 = alloca i8
store %struct.cpu* %0, %struct.cpu** %5
store i8 %1, i8* %6
store i8 %2, i8* %7
store i32 %3, i32* %8
%14 = load i32, i32* %8
%15 = and i32 %14, 131071
%16 = load i8, i8* %6
%17 = zext i8 %16 to i32
%18 = xor i32 %15, %17
%19 = load i8, i8* %7
%20 = zext i8 %19 to i32
%21 = xor i32 %18, %20
store i32 %21, i32* %9
%22 = load i32, i32* %8
%23 = and i32 %22, 255
%24 = icmp ne i32 %23, 0
%25 = zext i1 %24 to i64
%26 = select i1 %24, i32 0, i32 128
%27 = trunc i32 %26 to i8
store i8 %27, i8* %10
store i8 64, i8* %11
%28 = load i32, i32* %9
%29 = and i32 %28, 16
%30 = icmp ne i32 %29, 0
%31 = zext i1 %30 to i64
%32 = select i1 %30, i32 0, i32 32
%33 = trunc i32 %32 to i8
store i8 %33, i8* %12
%34 = load i32, i32* %9
%35 = and i32 %34, 256
%36 = icmp ne i32 %35, 0
%37 = zext i1 %36 to i64
%38 = select i1 %36, i32 0, i32 16
%39 = trunc i32 %38 to i8
store i8 %39, i8* %13
%40 = load %struct.cpu*, %struct.cpu** %5
%41 = load i8, i8* %10
%42 = zext i8 %41 to i32
%43 = load i8, i8* %11
%44 = zext i8 %43 to i32
%45 = or i32 %42, %44
%46 = load i8, i8* %12
%47 = zext i8 %46 to i32
%48 = or i32 %45, %47
%49 = load i8, i8* %13
%50 = zext i8 %49 to i32
%51 = or i32 %48, %50
%52 = trunc i32 %51 to i8
%53 = call i32 @cpu_set_r8(%struct.cpu* %40, i32 0, i8 zeroext %52)
ret void
}

LLVM IR (-O2):
%struct.cpu = type { i32 }
define void @cpu_sbc_flags(%struct.cpu* %0, i8 zeroext %1, i8 zeroext %2, i32 %3) {
%5 = and i32 %3, 16
%6 = xor i8 %2, %1
%7 = zext i8 %6 to i32
%8 = xor i32 %5, %7
%9 = and i32 %3, 255
%10 = icmp eq i32 %9, 0
%11 = shl nuw nsw i32 %8, 1
%12 = and i32 %11, 32
%13 = lshr i32 %3, 4
%14 = and i32 %13, 16
%15 = select i1 %10, i32 192, i32 64
%16 = or i32 %15, %14
%17 = or i32 %16, %12
%18 = trunc i32 %17 to i8
%19 = xor i8 %18, 48
%20 = tail call i32 @cpu_set_r8(%struct.cpu* %0, i32 0, i8 zeroext %19)
ret void
}