#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, int, int, int *, int *);
int get_bit(int, int);
int fullAdder32(int reg_a, int reg_b, int carryIn, int *carryOut) {
  int output, temp_out;
  int bit_a, bit_b, sum_bit, i;
  output = 0;
  for (i = 0; i < 32; i++) {
    bit_a = get_bit(reg_a, i);
    bit_b = get_bit(reg_b, i);
    fullAdder(bit_a, bit_b, carryIn, &temp_out, carryOut);
    output = output | (temp_out << i);
    carryIn = *carryOut;
  }
  return output;
}


x86 assembly (clang, -O0):
<fullAdder32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x30(%rbp)
cmpl   $0x20,-0x30(%rbp)
jge    11a8 <fullAdder32+0x88>
mov    -0x4(%rbp),%edi
mov    -0x30(%rbp),%esi
call   1040 <get_bit@plt>
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x30(%rbp),%esi
call   1040 <get_bit@plt>
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x28(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x18(%rbp),%r8
lea    -0x20(%rbp),%rcx
call   1030 <fullAdder@plt>
mov    -0x1c(%rbp),%eax
mov    -0x20(%rbp),%edx
mov    -0x30(%rbp),%ecx
shl    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1143 <fullAdder32+0x23>
mov    -0x1c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fullAdder32>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r13
mov    %edx,%r12d
mov    %esi,(%rsp)
mov    %edi,%r15d
xor    %ebp,%ebp
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    %r15d,%edi
mov    %ebp,%esi
call   1040 <get_bit@plt>
mov    %eax,%r14d
mov    (%rsp),%edi
mov    %ebp,%esi
call   1040 <get_bit@plt>
mov    %r14d,%edi
mov    %eax,%esi
mov    %r12d,%edx
lea    0x4(%rsp),%rcx
mov    %r13,%r8
call   1030 <fullAdder@plt>
mov    0x4(%rsp),%eax
mov    %ebp,%ecx
shl    %cl,%eax
or     %eax,%ebx
mov    0x0(%r13),%r12d
add    $0x1,%ebp
cmp    $0x20,%ebp
jne    1140 <fullAdder32+0x20>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @fullAdder32(i32 %0, i32 %1, i32 %2, i32* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32* %3, i32** %8
store i32 0, i32* %9
store i32 0, i32* %14
br label %15
15: ; preds = %37, %4
%16 = load i32, i32* %14
%17 = icmp slt i32 %16, 32
br i1 %17, label %18, label %40
18: ; preds = %15
%19 = load i32, i32* %5
%20 = load i32, i32* %14
%21 = call i32 @get_bit(i32 %19, i32 %20)
store i32 %21, i32* %11
%22 = load i32, i32* %6
%23 = load i32, i32* %14
%24 = call i32 @get_bit(i32 %22, i32 %23)
store i32 %24, i32* %12
%25 = load i32, i32* %11
%26 = load i32, i32* %12
%27 = load i32, i32* %7
%28 = load i32*, i32** %8
%29 = call i32 @fullAdder(i32 %25, i32 %26, i32 %27, i32* %10, i32* %28)
%30 = load i32, i32* %9
%31 = load i32, i32* %10
%32 = load i32, i32* %14
%33 = shl i32 %31, %32
%34 = or i32 %30, %33
store i32 %34, i32* %9
%35 = load i32*, i32** %8
%36 = load i32, i32* %35
store i32 %36, i32* %7
br label %37
37: ; preds = %18
%38 = load i32, i32* %14
%39 = add nsw i32 %38, 1
store i32 %39, i32* %14
br label %15
40: ; preds = %15
%41 = load i32, i32* %9
ret i32 %41
}

LLVM IR (-O2):
define i32 @fullAdder32(i32 %0, i32 %1, i32 %2, i32* %3) {
%5 = alloca i32
%6 = bitcast i32* %5 to i8*
br label %7
7: ; preds = %4, %7
%8 = phi i32 [ 0, %4 ], [ %18, %7 ]
%9 = phi i32 [ %2, %4 ], [ %17, %7 ]
%10 = phi i32 [ 0, %4 ], [ %16, %7 ]
%11 = call i32 @get_bit(i32 %0, i32 %8)
%12 = call i32 @get_bit(i32 %1, i32 %8)
%13 = call i32 @fullAdder(i32 %11, i32 %12, i32 %9, i32* %5, i32* %3)
%14 = load i32, i32* %5
%15 = shl i32 %14, %8
%16 = or i32 %15, %10
%17 = load i32, i32* %3
%18 = add nuw nsw i32 %8, 1
%19 = icmp eq i32 %18, 32
br i1 %19, label %20, label %7
20: ; preds = %7
ret i32 %16
}