#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 MUX8way(int A, int B, int C, int D, int E, int F, int G, int H,
            int select) {
  int output, sel;
  int Atemp, Btemp, Ctemp, Dtemp;
  sel = get_bit(select, 0);
  Atemp = MUX2way(A, B, sel);
  Btemp = MUX2way(C, D, sel);
  Ctemp = MUX2way(E, F, sel);
  Dtemp = MUX2way(G, H, sel);
  sel = get_bit(select, 1);
  Atemp = MUX2way(Atemp, Btemp, sel);
  Btemp = MUX2way(Ctemp, Dtemp, sel);
  sel = get_bit(select, 2);
  output = MUX2way(Atemp, Btemp, sel);
  return output;
}


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

x86 assembly (clang, -O2):
<MUX8way>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9d,0x14(%rsp)
mov    %r8d,0x8(%rsp)
mov    %ecx,%ebp
mov    %edx,%ebx
mov    %esi,%r15d
mov    %edi,%r12d
mov    0x50(%rsp),%eax
mov    %eax,0x10(%rsp)
mov    0x58(%rsp),%eax
mov    %eax,0xc(%rsp)
mov    0x60(%rsp),%r14d
mov    %r14d,%edi
xor    %esi,%esi
call   1040 <get_bit@plt>
mov    %eax,%r13d
mov    %r12d,%edi
mov    %r15d,%esi
mov    %eax,%edx
call   1030 <MUX2way@plt>
mov    %eax,0x4(%rsp)
mov    %ebx,%edi
mov    %ebp,%esi
mov    %r13d,%edx
call   1030 <MUX2way@plt>
mov    %eax,%r15d
mov    0x8(%rsp),%edi
mov    0x14(%rsp),%esi
mov    %r13d,%edx
call   1030 <MUX2way@plt>
mov    %eax,%r12d
mov    0x10(%rsp),%edi
mov    0xc(%rsp),%esi
mov    %r13d,%edx
call   1030 <MUX2way@plt>
mov    %eax,%r13d
mov    %r14d,%edi
mov    $0x1,%esi
call   1040 <get_bit@plt>
mov    %eax,%ebx
mov    0x4(%rsp),%edi
mov    %r15d,%esi
mov    %eax,%edx
call   1030 <MUX2way@plt>
mov    %eax,%ebp
mov    %r12d,%edi
mov    %r13d,%esi
mov    %ebx,%edx
call   1030 <MUX2way@plt>
mov    %eax,%ebx
mov    %r14d,%edi
mov    $0x2,%esi
call   1040 <get_bit@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    %eax,%edx
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <MUX2way@plt>

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

LLVM IR (-O2):
define i32 @MUX8way(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7, i32 %8) {
%10 = tail call i32 @get_bit(i32 %8, i32 0)
%11 = tail call i32 @MUX2way(i32 %0, i32 %1, i32 %10)
%12 = tail call i32 @MUX2way(i32 %2, i32 %3, i32 %10)
%13 = tail call i32 @MUX2way(i32 %4, i32 %5, i32 %10)
%14 = tail call i32 @MUX2way(i32 %6, i32 %7, i32 %10)
%15 = tail call i32 @get_bit(i32 %8, i32 1)
%16 = tail call i32 @MUX2way(i32 %11, i32 %12, i32 %15)
%17 = tail call i32 @MUX2way(i32 %13, i32 %14, i32 %15)
%18 = tail call i32 @get_bit(i32 %8, i32 2)
%19 = tail call i32 @MUX2way(i32 %16, i32 %17, i32 %18)
ret i32 %19
}