#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*/ gAnd(int const, int const);
int gNot(int const);
int gOr(int /*<<< orphan*/, int /*<<< orphan*/);
void mux16(const int s, const int *a, const int *b, int *out) {
  int notS = gNot(s);
  int i = 0;
  for (i = 0; i < 16; i++) {
    out[i] = gOr(gAnd(notS, a[i]), gAnd(s, b[i]));
  }
}


x86 assembly (clang, -O0):
<mux16>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <gNot@plt>
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x28(%rbp)
cmpl   $0x10,-0x28(%rbp)
jge    11b8 <mux16+0x88>
mov    -0x24(%rbp),%edi
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
call   1050 <gAnd@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
call   1050 <gAnd@plt>
mov    -0x2c(%rbp),%edi
mov    %eax,%esi
call   1030 <gOr@plt>
mov    %eax,%edx
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1160 <mux16+0x30>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mux16>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,(%rsp)
mov    %rdx,%r15
mov    %rsi,%r12
mov    %edi,%r13d
call   1040 <gNot@plt>
mov    %eax,%ebx
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r12,%r14,4),%esi
mov    %ebx,%edi
call   1050 <gAnd@plt>
mov    %eax,%ebp
mov    (%r15,%r14,4),%esi
mov    %r13d,%edi
call   1050 <gAnd@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1030 <gOr@plt>
mov    (%rsp),%rcx
mov    %eax,(%rcx,%r14,4)
add    $0x1,%r14
cmp    $0x10,%r14
jne    1160 <mux16+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @mux16(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
store i32 %0, i32* %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32* %3, i32** %8
%11 = load i32, i32* %5
%12 = call i32 @gNot(i32 %11)
store i32 %12, i32* %9
store i32 0, i32* %10
store i32 0, i32* %10
br label %13
13: ; preds = %36, %4
%14 = load i32, i32* %10
%15 = icmp slt i32 %14, 16
br i1 %15, label %16, label %39
16: ; preds = %13
%17 = load i32, i32* %9
%18 = load i32*, i32** %6
%19 = load i32, i32* %10
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %18, i64 %20
%22 = load i32, i32* %21
%23 = call i32 @gAnd(i32 %17, i32 %22)
%24 = load i32, i32* %5
%25 = load i32*, i32** %7
%26 = load i32, i32* %10
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32, i32* %25, i64 %27
%29 = load i32, i32* %28
%30 = call i32 @gAnd(i32 %24, i32 %29)
%31 = call i32 @gOr(i32 %23, i32 %30)
%32 = load i32*, i32** %8
%33 = load i32, i32* %10
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i32, i32* %32, i64 %34
store i32 %31, i32* %35
br label %36
36: ; preds = %16
%37 = load i32, i32* %10
%38 = add nsw i32 %37, 1
store i32 %38, i32* %10
br label %13
39: ; preds = %13
ret void
}

LLVM IR (-O2):
define void @mux16(i32 %0, i32* nocapture %1, i32* nocapture %2, i32* nocapture writeonly %3) {
%5 = tail call i32 @gNot(i32 %0)
br label %6
6: ; preds = %4, %6
%7 = phi i64 [ 0, %4 ], [ %16, %6 ]
%8 = getelementptr inbounds i32, i32* %1, i64 %7
%9 = load i32, i32* %8
%10 = tail call i32 @gAnd(i32 %5, i32 %9)
%11 = getelementptr inbounds i32, i32* %2, i64 %7
%12 = load i32, i32* %11
%13 = tail call i32 @gAnd(i32 %0, i32 %12)
%14 = tail call i32 @gOr(i32 %10, i32 %13)
%15 = getelementptr inbounds i32, i32* %3, i64 %7
store i32 %14, i32* %15
%16 = add nuw nsw i64 %7, 1
%17 = icmp eq i64 %16, 16
br i1 %17, label %18, label %6
18: ; preds = %6
ret void
}