#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 const gAnd(int const, int const);
int gNot(int const);
int gOr4Way(int, int, int, int);
void mux4Way16(const int s1, const int s0, const int *a, const int *b,
               const int *c, const int *d, int *out) {
  int notS0 = gNot(s0);
  int notS1 = gNot(s1);
  int i = 0;
  for (i = 0; i < 16; i++) {
    int bitA = gAnd(gAnd(notS0, notS1), a[i]);
    int bitB = gAnd(gAnd(s0, notS1), b[i]);
    int bitC = gAnd(gAnd(notS0, s1), c[i]);
    int bitD = gAnd(gAnd(s0, s1), d[i]);
    out[i] = gOr4Way(bitA, bitB, bitC, bitD);
  }
}


x86 assembly (clang, -O0):
<mux4Way16>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <gNot@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <gNot@plt>
mov    %eax,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0x10,-0x34(%rbp)
jge    122c <mux4Way16+0xfc>
mov    -0x2c(%rbp),%edi
mov    -0x30(%rbp),%esi
call   1040 <gAnd@plt>
mov    %eax,%edi
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
call   1040 <gAnd@plt>
mov    %eax,-0x38(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x30(%rbp),%esi
call   1040 <gAnd@plt>
mov    %eax,%edi
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
call   1040 <gAnd@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x2c(%rbp),%edi
mov    -0x4(%rbp),%esi
call   1040 <gAnd@plt>
mov    %eax,%edi
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
call   1040 <gAnd@plt>
mov    %eax,-0x40(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x4(%rbp),%esi
call   1040 <gAnd@plt>
mov    %eax,%edi
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
call   1040 <gAnd@plt>
mov    %eax,-0x44(%rbp)
mov    -0x38(%rbp),%edi
mov    -0x3c(%rbp),%esi
mov    -0x40(%rbp),%edx
mov    -0x44(%rbp),%ecx
call   1050 <gOr4Way@plt>
mov    %eax,%edx
mov    0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1176 <mux4Way16+0x46>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mux4Way16>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r9,0x30(%rsp)
mov    %r8,0x28(%rsp)
mov    %rcx,0x20(%rsp)
mov    %rdx,0x18(%rsp)
mov    %edi,%ebx
mov    %esi,0x14(%rsp)
mov    %esi,%edi
call   1030 <gNot@plt>
mov    %eax,0xc(%rsp)
mov    %ebx,0x10(%rsp)
mov    %ebx,%edi
call   1030 <gNot@plt>
mov    %eax,0x8(%rsp)
xor    %ebx,%ebx
mov    0x14(%rsp),%r14d
nopl   0x0(%rax)
mov    0xc(%rsp),%r15d
mov    %r15d,%edi
mov    0x8(%rsp),%ebp
mov    %ebp,%esi
call   1040 <gAnd@plt>
mov    0x18(%rsp),%rcx
mov    (%rcx,%rbx,4),%esi
mov    %eax,%edi
call   1040 <gAnd@plt>
mov    %eax,%r12d
mov    %r14d,%edi
mov    %ebp,%esi
call   1040 <gAnd@plt>
mov    0x20(%rsp),%rcx
mov    (%rcx,%rbx,4),%esi
mov    %eax,%edi
call   1040 <gAnd@plt>
mov    %eax,%r13d
mov    %r15d,%edi
mov    0x10(%rsp),%r15d
mov    %r15d,%esi
call   1040 <gAnd@plt>
mov    0x28(%rsp),%rcx
mov    (%rcx,%rbx,4),%esi
mov    %eax,%edi
call   1040 <gAnd@plt>
mov    %eax,%ebp
mov    %r14d,%edi
mov    %r15d,%esi
call   1040 <gAnd@plt>
mov    0x30(%rsp),%rcx
mov    (%rcx,%rbx,4),%esi
mov    %eax,%edi
call   1040 <gAnd@plt>
mov    %r12d,%edi
mov    %r13d,%esi
mov    %ebp,%edx
mov    %eax,%ecx
call   1050 <gOr4Way@plt>
mov    0x70(%rsp),%rcx
mov    %eax,(%rcx,%rbx,4)
add    $0x1,%rbx
cmp    $0x10,%rbx
jne    1180 <mux4Way16+0x50>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @mux4Way16(i32 %0, i32 %1, i32* %2, i32* %3, i32* %4, i32* %5, i32* %6) {
%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
store i32 %0, i32* %8
store i32 %1, i32* %9
store i32* %2, i32** %10
store i32* %3, i32** %11
store i32* %4, i32** %12
store i32* %5, i32** %13
store i32* %6, i32** %14
%22 = load i32, i32* %9
%23 = call i32 @gNot(i32 %22)
store i32 %23, i32* %15
%24 = load i32, i32* %8
%25 = call i32 @gNot(i32 %24)
store i32 %25, i32* %16
store i32 0, i32* %17
store i32 0, i32* %17
br label %26
26: ; preds = %75, %7
%27 = load i32, i32* %17
%28 = icmp slt i32 %27, 16
br i1 %28, label %29, label %78
29: ; preds = %26
%30 = load i32, i32* %15
%31 = load i32, i32* %16
%32 = call i32 @gAnd(i32 %30, i32 %31)
%33 = load i32*, i32** %10
%34 = load i32, i32* %17
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i32, i32* %33, i64 %35
%37 = load i32, i32* %36
%38 = call i32 @gAnd(i32 %32, i32 %37)
store i32 %38, i32* %18
%39 = load i32, i32* %9
%40 = load i32, i32* %16
%41 = call i32 @gAnd(i32 %39, i32 %40)
%42 = load i32*, i32** %11
%43 = load i32, i32* %17
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i32, i32* %42, i64 %44
%46 = load i32, i32* %45
%47 = call i32 @gAnd(i32 %41, i32 %46)
store i32 %47, i32* %19
%48 = load i32, i32* %15
%49 = load i32, i32* %8
%50 = call i32 @gAnd(i32 %48, i32 %49)
%51 = load i32*, i32** %12
%52 = load i32, i32* %17
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i32, i32* %51, i64 %53
%55 = load i32, i32* %54
%56 = call i32 @gAnd(i32 %50, i32 %55)
store i32 %56, i32* %20
%57 = load i32, i32* %9
%58 = load i32, i32* %8
%59 = call i32 @gAnd(i32 %57, i32 %58)
%60 = load i32*, i32** %13
%61 = load i32, i32* %17
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i32, i32* %60, i64 %62
%64 = load i32, i32* %63
%65 = call i32 @gAnd(i32 %59, i32 %64)
store i32 %65, i32* %21
%66 = load i32, i32* %18
%67 = load i32, i32* %19
%68 = load i32, i32* %20
%69 = load i32, i32* %21
%70 = call i32 @gOr4Way(i32 %66, i32 %67, i32 %68, i32 %69)
%71 = load i32*, i32** %14
%72 = load i32, i32* %17
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i32, i32* %71, i64 %73
store i32 %70, i32* %74
br label %75
75: ; preds = %29
%76 = load i32, i32* %17
%77 = add nsw i32 %76, 1
store i32 %77, i32* %17
br label %26
78: ; preds = %26
ret void
}

LLVM IR (-O2):
define void @mux4Way16(i32 %0, i32 %1, i32* nocapture %2, i32* nocapture %3, i32* nocapture %4, i32* nocapture %5, i32* nocapture writeonly %6) {
%8 = tail call i32 @gNot(i32 %1)
%9 = tail call i32 @gNot(i32 %0)
br label %10
10: ; preds = %7, %10
%11 = phi i64 [ 0, %7 ], [ %30, %10 ]
%12 = tail call i32 @gAnd(i32 %8, i32 %9)
%13 = getelementptr inbounds i32, i32* %2, i64 %11
%14 = load i32, i32* %13
%15 = tail call i32 @gAnd(i32 %12, i32 %14)
%16 = tail call i32 @gAnd(i32 %1, i32 %9)
%17 = getelementptr inbounds i32, i32* %3, i64 %11
%18 = load i32, i32* %17
%19 = tail call i32 @gAnd(i32 %16, i32 %18)
%20 = tail call i32 @gAnd(i32 %8, i32 %0)
%21 = getelementptr inbounds i32, i32* %4, i64 %11
%22 = load i32, i32* %21
%23 = tail call i32 @gAnd(i32 %20, i32 %22)
%24 = tail call i32 @gAnd(i32 %1, i32 %0)
%25 = getelementptr inbounds i32, i32* %5, i64 %11
%26 = load i32, i32* %25
%27 = tail call i32 @gAnd(i32 %24, i32 %26)
%28 = tail call i32 @gOr4Way(i32 %15, i32 %19, i32 %23, i32 %27)
%29 = getelementptr inbounds i32, i32* %6, i64 %11
store i32 %28, i32* %29
%30 = add nuw nsw i64 %11, 1
%31 = icmp eq i64 %30, 16
br i1 %31, label %32, label %10
32: ; preds = %10
ret void
}