#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 exor(int, int);
int *malloc(int);
int *full_subtractor(int x, int y, int z) {
  int temp, diff, borrow;
  int *arr = malloc(sizeof(int) * 2);
  temp = exor(x, y);
  diff = exor(temp, z);
  borrow = (!x & y) | (z & !temp);
  *(arr + 0) = diff;
  *(arr + 1) = borrow;
  return arr;
}


x86 assembly (clang, -O0):
<full_subtractor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    $0x8,%edi
call   1030 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <exor@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1040 <exor@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x4(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
and    -0x8(%rbp),%eax
mov    -0xc(%rbp),%ecx
cmpl   $0x0,-0x10(%rbp)
setne  %dl
xor    $0xff,%dl
and    $0x1,%dl
movzbl %dl,%edx
and    %edx,%ecx
or     %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<full_subtractor>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r14d
mov    %esi,%r15d
mov    %edi,%r12d
mov    $0x8,%edi
call   1030 <malloc@plt>
mov    %rax,%rbx
mov    %r12d,%edi
mov    %r15d,%esi
call   1040 <exor@plt>
mov    %eax,%ebp
mov    %eax,%edi
mov    %r14d,%esi
call   1040 <exor@plt>
xor    %ecx,%ecx
test   %r12d,%r12d
sete   %cl
and    %r15d,%ecx
xor    %edx,%edx
test   %ebp,%ebp
sete   %dl
and    %r14d,%edx
or     %ecx,%edx
mov    %eax,(%rbx)
mov    %edx,0x4(%rbx)
mov    %rbx,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32* @full_subtractor(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%11 = call i32* @malloc(i32 8)
store i32* %11, i32** %10
%12 = load i32, i32* %4
%13 = load i32, i32* %5
%14 = call i32 @exor(i32 %12, i32 %13)
store i32 %14, i32* %7
%15 = load i32, i32* %7
%16 = load i32, i32* %6
%17 = call i32 @exor(i32 %15, i32 %16)
store i32 %17, i32* %8
%18 = load i32, i32* %4
%19 = icmp ne i32 %18, 0
%20 = xor i1 %19, true
%21 = zext i1 %20 to i32
%22 = load i32, i32* %5
%23 = and i32 %21, %22
%24 = load i32, i32* %6
%25 = load i32, i32* %7
%26 = icmp ne i32 %25, 0
%27 = xor i1 %26, true
%28 = zext i1 %27 to i32
%29 = and i32 %24, %28
%30 = or i32 %23, %29
store i32 %30, i32* %9
%31 = load i32, i32* %8
%32 = load i32*, i32** %10
%33 = getelementptr inbounds i32, i32* %32, i64 0
store i32 %31, i32* %33
%34 = load i32, i32* %9
%35 = load i32*, i32** %10
%36 = getelementptr inbounds i32, i32* %35, i64 1
store i32 %34, i32* %36
%37 = load i32*, i32** %10
ret i32* %37
}

LLVM IR (-O2):
define noalias i32* @full_subtractor(i32 %0, i32 %1, i32 %2) {
%4 = tail call i32* @malloc(i32 8)
%5 = tail call i32 @exor(i32 %0, i32 %1)
%6 = tail call i32 @exor(i32 %5, i32 %2)
%7 = icmp eq i32 %0, 0
%8 = zext i1 %7 to i32
%9 = and i32 %8, %1
%10 = icmp eq i32 %5, 0
%11 = zext i1 %10 to i32
%12 = and i32 %11, %2
%13 = or i32 %12, %9
store i32 %6, i32* %4
%14 = getelementptr inbounds i32, i32* %4, i64 1
store i32 %13, i32* %14
ret i32* %4
}