void full_adder(char a, char b, char c_in, char *s, char *c) {
  char s1 = xor(a, b);
  *s = xor(c_in, s1);
  *c = or (and(a, b), and(c_in, s1));
}


x86 assembly (clang, -O0):
<full_adder>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dl,%al
mov    %sil,%dl
mov    %dil,%sil
mov    %sil,-0x1(%rbp)
mov    %dl,-0x2(%rbp)
mov    %al,-0x3(%rbp)
mov    %rcx,-0x10(%rbp)
mov    %r8,-0x18(%rbp)
movsbl -0x1(%rbp),%edi
movsbl -0x2(%rbp),%esi
mov    $0x0,%al
call   1040 <xor@plt>
mov    %al,-0x19(%rbp)
movsbl -0x3(%rbp),%edi
movsbl -0x19(%rbp),%esi
mov    $0x0,%al
call   1040 <xor@plt>
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
movsbl -0x1(%rbp),%edi
movsbl -0x2(%rbp),%esi
mov    $0x0,%al
call   1030 <and@plt>
mov    %eax,-0x20(%rbp)
movsbl -0x3(%rbp),%edi
movsbl -0x19(%rbp),%esi
mov    $0x0,%al
call   1030 <and@plt>
mov    -0x20(%rbp),%edi
mov    %eax,%esi
mov    $0x0,%al
call   1050 <or@plt>
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<full_adder>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r14
mov    %rcx,%r15
mov    %edx,%r12d
mov    %esi,%r13d
mov    %edi,%ebp
xor    %eax,%eax
call   1040 <xor@plt>
movsbl %al,%ebx
mov    %r12d,%edi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <xor@plt>
mov    %al,(%r15)
mov    %ebp,%edi
mov    %r13d,%esi
xor    %eax,%eax
call   1030 <and@plt>
mov    %eax,%ebp
mov    %r12d,%edi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <and@plt>
mov    %ebp,%edi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <or@plt>
mov    %al,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @full_adder(i8 signext %0, i8 signext %1, i8 signext %2, i8* %3, i8* %4) {
%6 = alloca i8
%7 = alloca i8
%8 = alloca i8
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8
store i8 %0, i8* %6
store i8 %1, i8* %7
store i8 %2, i8* %8
store i8* %3, i8** %9
store i8* %4, i8** %10
%12 = load i8, i8* %6
%13 = sext i8 %12 to i32
%14 = load i8, i8* %7
%15 = sext i8 %14 to i32
%16 = call i32 (i32, i32, ...) bitcast (i32 (...)* @xor to i32 (i32, i32, ...)*)(i32 %13, i32 %15)
%17 = trunc i32 %16 to i8
store i8 %17, i8* %11
%18 = load i8, i8* %8
%19 = sext i8 %18 to i32
%20 = load i8, i8* %11
%21 = sext i8 %20 to i32
%22 = call i32 (i32, i32, ...) bitcast (i32 (...)* @xor to i32 (i32, i32, ...)*)(i32 %19, i32 %21)
%23 = trunc i32 %22 to i8
%24 = load i8*, i8** %9
store i8 %23, i8* %24
%25 = load i8, i8* %6
%26 = sext i8 %25 to i32
%27 = load i8, i8* %7
%28 = sext i8 %27 to i32
%29 = call i32 (i32, i32, ...) bitcast (i32 (...)* @and to i32 (i32, i32, ...)*)(i32 %26, i32 %28)
%30 = load i8, i8* %8
%31 = sext i8 %30 to i32
%32 = load i8, i8* %11
%33 = sext i8 %32 to i32
%34 = call i32 (i32, i32, ...) bitcast (i32 (...)* @and to i32 (i32, i32, ...)*)(i32 %31, i32 %33)
%35 = call i32 (i32, i32, ...) bitcast (i32 (...)* @or to i32 (i32, i32, ...)*)(i32 %29, i32 %34)
%36 = trunc i32 %35 to i8
%37 = load i8*, i8** %10
store i8 %36, i8* %37
ret void
}

LLVM IR (-O2):
define void @full_adder(i8 signext %0, i8 signext %1, i8 signext %2, i8* nocapture writeonly %3, i8* nocapture writeonly %4) {
%6 = sext i8 %0 to i32
%7 = sext i8 %1 to i32
%8 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @xor to i32 (i32, i32, ...)*)(i32 %6, i32 %7)
%9 = sext i8 %2 to i32
%10 = shl i32 %8, 24
%11 = ashr exact i32 %10, 24
%12 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @xor to i32 (i32, i32, ...)*)(i32 %9, i32 %11)
%13 = trunc i32 %12 to i8
store i8 %13, i8* %3
%14 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @and to i32 (i32, i32, ...)*)(i32 %6, i32 %7)
%15 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @and to i32 (i32, i32, ...)*)(i32 %9, i32 %11)
%16 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @or to i32 (i32, i32, ...)*)(i32 %14, i32 %15)
%17 = trunc i32 %16 to i8
store i8 %17, i8* %4
ret void
}