#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 AND(int, int);
int MUX16way(int, int, int, int, int, int, int, int, int, int, int, int, int,
             int, int, int, int);
int NOT(int);
int OR(int, int);
int XOR(int, int);
int ALU_old(int A_reg, int B_reg, int control_bits) {
  int ALU_AND = AND(A_reg, B_reg);
  int ALU_OR = OR(A_reg, B_reg);
  int ALU_NOT = NOT(A_reg);
  int ALU_XOR = XOR(A_reg, B_reg);
  int ALU_ZERO = 0;
  int ALU_EQUAL_THAN = 0;
  int ALU_LESS_THAN = 0;
  int ALU_GREATER_THAN = 0;
  int ALU_ADD = A_reg + B_reg;
  int ALU_SUB = 0;
  int UND = 0;
  int UND2 = 0;
  int UND3 = 0;
  int UND4 = 0;
  int UND5 = 0;
  int UND6 = 0;
  int result =
      MUX16way(ALU_ADD, ALU_OR, ALU_NOT, ALU_XOR, ALU_ZERO, ALU_EQUAL_THAN,
               ALU_LESS_THAN, ALU_GREATER_THAN, ALU_ADD, ALU_SUB, UND, UND2,
               UND3, UND4, UND5, UND6, control_bits);
  return result;
}


x86 assembly (clang, -O0):
<ALU_old>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xb8,%rsp
mov    %edi,-0x2c(%rbp)
mov    %esi,-0x30(%rbp)
mov    %edx,-0x34(%rbp)
mov    -0x2c(%rbp),%edi
mov    -0x30(%rbp),%esi
call   1040 <AND@plt>
mov    %eax,-0x38(%rbp)
mov    -0x2c(%rbp),%edi
mov    -0x30(%rbp),%esi
call   1060 <OR@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x2c(%rbp),%edi
call   1030 <NOT@plt>
mov    %eax,-0x40(%rbp)
mov    -0x2c(%rbp),%edi
mov    -0x30(%rbp),%esi
call   1050 <XOR@plt>
mov    %eax,-0x44(%rbp)
movl   $0x0,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
movl   $0x0,-0x50(%rbp)
movl   $0x0,-0x54(%rbp)
mov    -0x2c(%rbp),%eax
add    -0x30(%rbp),%eax
mov    %eax,-0x58(%rbp)
movl   $0x0,-0x5c(%rbp)
movl   $0x0,-0x60(%rbp)
movl   $0x0,-0x64(%rbp)
movl   $0x0,-0x68(%rbp)
movl   $0x0,-0x6c(%rbp)
movl   $0x0,-0x70(%rbp)
movl   $0x0,-0x74(%rbp)
mov    -0x58(%rbp),%edi
mov    -0x3c(%rbp),%esi
mov    -0x40(%rbp),%edx
mov    -0x44(%rbp),%ecx
mov    -0x48(%rbp),%r8d
mov    -0x4c(%rbp),%r9d
mov    -0x50(%rbp),%eax
mov    %eax,-0x88(%rbp)
mov    -0x54(%rbp),%eax
mov    %eax,-0x84(%rbp)
mov    -0x58(%rbp),%eax
mov    %eax,-0x80(%rbp)
mov    -0x5c(%rbp),%r13d
mov    -0x60(%rbp),%r12d
mov    -0x64(%rbp),%r15d
mov    -0x68(%rbp),%r14d
mov    -0x6c(%rbp),%ebx
mov    -0x70(%rbp),%r11d
mov    -0x74(%rbp),%r10d
mov    -0x34(%rbp),%eax
mov    %eax,-0x7c(%rbp)
mov    -0x88(%rbp),%eax
mov    %eax,(%rsp)
mov    -0x84(%rbp),%eax
mov    %eax,0x8(%rsp)
mov    -0x80(%rbp),%eax
mov    %eax,0x10(%rsp)
mov    -0x7c(%rbp),%eax
mov    %r13d,0x18(%rsp)
mov    %r12d,0x20(%rsp)
mov    %r15d,0x28(%rsp)
mov    %r14d,0x30(%rsp)
mov    %ebx,0x38(%rsp)
mov    %r11d,0x40(%rsp)
mov    %r10d,0x48(%rsp)
mov    %eax,0x50(%rsp)
call   1070 <MUX16way@plt>
mov    %eax,-0x78(%rbp)
mov    -0x78(%rbp),%eax
add    $0xb8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<ALU_old>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r14d
mov    %esi,%ebx
mov    %edi,%ebp
call   1040 <AND@plt>
mov    %ebp,%edi
mov    %ebx,%esi
call   1060 <OR@plt>
mov    %eax,%r15d
mov    %ebp,%edi
call   1030 <NOT@plt>
mov    %eax,%r12d
mov    %ebp,%edi
mov    %ebx,%esi
call   1050 <XOR@plt>
add    %ebp,%ebx
sub    $0x8,%rsp
mov    %ebx,%edi
mov    %r15d,%esi
mov    %r12d,%edx
mov    %eax,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
push   %r14
push   $0x0
push   $0x0
push   $0x0
push   $0x0
push   $0x0
push   $0x0
push   $0x0
push   %rbx
push   $0x0
push   $0x0
call   1070 <MUX16way@plt>
add    $0x60,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @ALU_old(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
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%24 = load i32, i32* %4
%25 = load i32, i32* %5
%26 = call i32 @AND(i32 %24, i32 %25)
store i32 %26, i32* %7
%27 = load i32, i32* %4
%28 = load i32, i32* %5
%29 = call i32 @OR(i32 %27, i32 %28)
store i32 %29, i32* %8
%30 = load i32, i32* %4
%31 = call i32 @NOT(i32 %30)
store i32 %31, i32* %9
%32 = load i32, i32* %4
%33 = load i32, i32* %5
%34 = call i32 @XOR(i32 %32, i32 %33)
store i32 %34, i32* %10
store i32 0, i32* %11
store i32 0, i32* %12
store i32 0, i32* %13
store i32 0, i32* %14
%35 = load i32, i32* %4
%36 = load i32, i32* %5
%37 = add nsw i32 %35, %36
store i32 %37, i32* %15
store i32 0, i32* %16
store i32 0, i32* %17
store i32 0, i32* %18
store i32 0, i32* %19
store i32 0, i32* %20
store i32 0, i32* %21
store i32 0, i32* %22
%38 = load i32, i32* %15
%39 = load i32, i32* %8
%40 = load i32, i32* %9
%41 = load i32, i32* %10
%42 = load i32, i32* %11
%43 = load i32, i32* %12
%44 = load i32, i32* %13
%45 = load i32, i32* %14
%46 = load i32, i32* %15
%47 = load i32, i32* %16
%48 = load i32, i32* %17
%49 = load i32, i32* %18
%50 = load i32, i32* %19
%51 = load i32, i32* %20
%52 = load i32, i32* %21
%53 = load i32, i32* %22
%54 = load i32, i32* %6
%55 = call i32 @MUX16way(i32 %38, i32 %39, i32 %40, i32 %41, i32 %42, i32 %43, i32 %44, i32 %45, i32 %46, i32 %47, i32 %48, i32 %49, i32 %50, i32 %51, i32 %52, i32 %53, i32 %54)
store i32 %55, i32* %23
%56 = load i32, i32* %23
ret i32 %56
}

LLVM IR (-O2):
define i32 @ALU_old(i32 %0, i32 %1, i32 %2) {
%4 = tail call i32 @AND(i32 %0, i32 %1)
%5 = tail call i32 @OR(i32 %0, i32 %1)
%6 = tail call i32 @NOT(i32 %0)
%7 = tail call i32 @XOR(i32 %0, i32 %1)
%8 = add nsw i32 %1, %0
%9 = tail call i32 @MUX16way(i32 %8, i32 %5, i32 %6, i32 %7, i32 0, i32 0, i32 0, i32 0, i32 %8, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 %2)
ret i32 %9
}