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


x86 assembly (clang, -O0):
<full_adder>:
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)
mov    -0x4(%rbp),%eax
and    -0x8(%rbp),%eax
mov    -0x10(%rbp),%ecx
and    -0xc(%rbp),%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_adder>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r14d
mov    %esi,%ebp
mov    %edi,%r15d
mov    $0x8,%edi
call   1030 <malloc@plt>
mov    %rax,%r12
mov    %r15d,%edi
mov    %ebp,%esi
call   1040 <exor@plt>
mov    %eax,%ebx
mov    %eax,%edi
mov    %r14d,%esi
call   1040 <exor@plt>
and    %r15d,%ebp
and    %r14d,%ebx
or     %ebp,%ebx
mov    %eax,(%r12)
mov    %ebx,0x4(%r12)
mov    %r12,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32* @full_adder(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 = load i32, i32* %5
%20 = and i32 %18, %19
%21 = load i32, i32* %7
%22 = load i32, i32* %6
%23 = and i32 %21, %22
%24 = or i32 %20, %23
store i32 %24, i32* %9
%25 = load i32, i32* %8
%26 = load i32*, i32** %10
%27 = getelementptr inbounds i32, i32* %26, i64 0
store i32 %25, i32* %27
%28 = load i32, i32* %9
%29 = load i32*, i32** %10
%30 = getelementptr inbounds i32, i32* %29, i64 1
store i32 %28, i32* %30
%31 = load i32*, i32** %10
ret i32* %31
}

LLVM IR (-O2):
define noalias i32* @full_adder(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 = and i32 %1, %0
%8 = and i32 %5, %2
%9 = or i32 %8, %7
store i32 %6, i32* %4
%10 = getelementptr inbounds i32, i32* %4, i64 1
store i32 %9, i32* %10
ret i32* %4
}