#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 MUX2way(int, int, int);
int get_bit(int, int);
int MUX4way(int A, int B, int C, int D, int select) {
  int output;
  int Atemp, Btemp, sel;
  sel = get_bit(select, 0);
  Atemp = MUX2way(A, B, sel);
  Btemp = MUX2way(C, D, sel);
  sel = get_bit(select, 1);
  output = MUX2way(Atemp, Btemp, sel);
  return output;
}


x86 assembly (clang, -O0):
<MUX4way>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
mov    -0x14(%rbp),%edi
xor    %esi,%esi
call   1040 <get_bit@plt>
mov    %eax,-0x24(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x24(%rbp),%edx
call   1030 <MUX2way@plt>
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x24(%rbp),%edx
call   1030 <MUX2way@plt>
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
mov    $0x1,%esi
call   1040 <get_bit@plt>
mov    %eax,-0x24(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
call   1030 <MUX2way@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MUX4way>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%r13d
mov    %ecx,%r14d
mov    %edx,%r15d
mov    %esi,%r12d
mov    %edi,%ebp
mov    %r8d,%edi
xor    %esi,%esi
call   1040 <get_bit@plt>
mov    %eax,%ebx
mov    %ebp,%edi
mov    %r12d,%esi
mov    %eax,%edx
call   1030 <MUX2way@plt>
mov    %eax,%ebp
mov    %r15d,%edi
mov    %r14d,%esi
mov    %ebx,%edx
call   1030 <MUX2way@plt>
mov    %eax,%ebx
mov    %r13d,%edi
mov    $0x1,%esi
call   1040 <get_bit@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    %eax,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <MUX2way@plt>

LLVM IR (-O0):
define i32 @MUX4way(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%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* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%15 = load i32, i32* %10
%16 = call i32 @get_bit(i32 %15, i32 0)
store i32 %16, i32* %14
%17 = load i32, i32* %6
%18 = load i32, i32* %7
%19 = load i32, i32* %14
%20 = call i32 @MUX2way(i32 %17, i32 %18, i32 %19)
store i32 %20, i32* %12
%21 = load i32, i32* %8
%22 = load i32, i32* %9
%23 = load i32, i32* %14
%24 = call i32 @MUX2way(i32 %21, i32 %22, i32 %23)
store i32 %24, i32* %13
%25 = load i32, i32* %10
%26 = call i32 @get_bit(i32 %25, i32 1)
store i32 %26, i32* %14
%27 = load i32, i32* %12
%28 = load i32, i32* %13
%29 = load i32, i32* %14
%30 = call i32 @MUX2way(i32 %27, i32 %28, i32 %29)
store i32 %30, i32* %11
%31 = load i32, i32* %11
ret i32 %31
}

LLVM IR (-O2):
define i32 @MUX4way(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = tail call i32 @get_bit(i32 %4, i32 0)
%7 = tail call i32 @MUX2way(i32 %0, i32 %1, i32 %6)
%8 = tail call i32 @MUX2way(i32 %2, i32 %3, i32 %6)
%9 = tail call i32 @get_bit(i32 %4, i32 1)
%10 = tail call i32 @MUX2way(i32 %7, i32 %8, i32 %9)
ret i32 %10
}