#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*/ fullAdder(int const, int const, int, int *, int *);
void add16(const int *a, const int *b, int *sum) {
  int carry = 0;
  int i;
  for (i = 15; i >= 0; i--) {
    fullAdder(a[i], b[i], carry, &sum[i], &carry);
  }
}


x86 assembly (clang, -O0):
<add16>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0xf,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jl     117b <add16+0x6b>
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%rcx
movslq -0x20(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rcx
lea    -0x1c(%rbp),%r8
call   1030 <fullAdder@plt>
mov    -0x20(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
jmp    1132 <add16+0x22>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add16>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r13
movl   $0x0,0xc(%rsp)
mov    0x3c(%rdi),%edi
mov    0x3c(%rsi),%esi
lea    0x3c(%rdx),%rcx
lea    0xc(%rsp),%r12
xor    %edx,%edx
mov    %r12,%r8
call   1030 <fullAdder@plt>
mov    $0x38,%ebx
nopl   0x0(%rax)
mov    0xc(%rsp),%edx
mov    0x0(%r13,%rbx,1),%edi
mov    (%r15,%rbx,1),%esi
lea    (%r14,%rbx,1),%rcx
mov    %r12,%r8
call   1030 <fullAdder@plt>
add    $0xfffffffffffffffc,%rbx
cmp    $0xfffffffffffffffc,%rbx
jne    1150 <add16+0x40>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @add16(i32* %0, i32* %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
store i32 0, i32* %7
store i32 15, i32* %8
br label %9
9: ; preds = %29, %3
%10 = load i32, i32* %8
%11 = icmp sge i32 %10, 0
br i1 %11, label %12, label %32
12: ; preds = %9
%13 = load i32*, i32** %4
%14 = load i32, i32* %8
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i32, i32* %13, i64 %15
%17 = load i32, i32* %16
%18 = load i32*, i32** %5
%19 = load i32, i32* %8
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %18, i64 %20
%22 = load i32, i32* %21
%23 = load i32, i32* %7
%24 = load i32*, i32** %6
%25 = load i32, i32* %8
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %24, i64 %26
%28 = call i32 @fullAdder(i32 %17, i32 %22, i32 %23, i32* %27, i32* %7)
br label %29
29: ; preds = %12
%30 = load i32, i32* %8
%31 = add nsw i32 %30, -1
store i32 %31, i32* %8
br label %9
32: ; preds = %9
ret void
}

LLVM IR (-O2):
define void @add16(i32* nocapture %0, i32* nocapture %1, i32* %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%6 = getelementptr inbounds i32, i32* %0, i64 15
%7 = load i32, i32* %6
%8 = getelementptr inbounds i32, i32* %1, i64 15
%9 = load i32, i32* %8
%10 = getelementptr inbounds i32, i32* %2, i64 15
%11 = call i32 @fullAdder(i32 %7, i32 %9, i32 0, i32* %10, i32* %4)
br label %12
12: ; preds = %3, %12
%13 = phi i64 [ 15, %3 ], [ %14, %12 ]
%14 = add nsw i64 %13, -1
%15 = load i32, i32* %4
%16 = getelementptr inbounds i32, i32* %0, i64 %14
%17 = load i32, i32* %16
%18 = getelementptr inbounds i32, i32* %1, i64 %14
%19 = load i32, i32* %18
%20 = getelementptr inbounds i32, i32* %2, i64 %14
%21 = call i32 @fullAdder(i32 %17, i32 %19, i32 %15, i32* %20, i32* %4)
%22 = icmp eq i64 %14, 0
br i1 %22, label %23, label %12
23: ; preds = %12
ret void
}