#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 */
char neuron_compute(float *, size_t, char const *);
void layer_compute(float *weights, size_t neuron_num, size_t weights_per_neuron,
                   const char *input, char *output) {
  for (size_t i = 0; i < neuron_num; ++i)
    output[i] = neuron_compute(&weights[i * weights_per_neuron],
                               weights_per_neuron, input);
}


x86 assembly (clang, -O0):
<layer_compute>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1181 <layer_compute+0x71>
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rax
imul   -0x18(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <neuron_compute@plt>
mov    %al,%dl
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1134 <layer_compute+0x24>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<layer_compute>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,(%rsp)
test   %rsi,%rsi
je     115f <layer_compute+0x4f>
mov    %r8,%r15
mov    %rcx,%r12
mov    %rsi,%r13
mov    %rdi,%rbx
mov    (%rsp),%rax
lea    0x0(,%rax,4),%rbp
xor    %r14d,%r14d
nop
mov    %rbx,%rdi
mov    (%rsp),%rsi
mov    %r12,%rdx
call   1030 <neuron_compute@plt>
mov    %al,(%r15,%r14,1)
add    $0x1,%r14
add    %rbp,%rbx
cmp    %r14,%r13
jne    1140 <layer_compute+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @layer_compute(float* %0, i64 %1, i64 %2, i8* %3, i8* %4) {
%6 = alloca float*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i64
store float* %0, float** %6
store i64 %1, i64* %7
store i64 %2, i64* %8
store i8* %3, i8** %9
store i8* %4, i8** %10
store i64 0, i64* %11
br label %12
12: ; preds = %28, %5
%13 = load i64, i64* %11
%14 = load i64, i64* %7
%15 = icmp ult i64 %13, %14
br i1 %15, label %16, label %31
16: ; preds = %12
%17 = load float*, float** %6
%18 = load i64, i64* %11
%19 = load i64, i64* %8
%20 = mul i64 %18, %19
%21 = getelementptr inbounds float, float* %17, i64 %20
%22 = load i64, i64* %8
%23 = load i8*, i8** %9
%24 = call signext i8 @neuron_compute(float* %21, i64 %22, i8* %23)
%25 = load i8*, i8** %10
%26 = load i64, i64* %11
%27 = getelementptr inbounds i8, i8* %25, i64 %26
store i8 %24, i8* %27
br label %28
28: ; preds = %16
%29 = load i64, i64* %11
%30 = add i64 %29, 1
store i64 %30, i64* %11
br label %12
31: ; preds = %12
ret void
}

LLVM IR (-O2):
define void @layer_compute(float* %0, i64 %1, i64 %2, i8* %3, i8* nocapture writeonly %4) {
%6 = icmp eq i64 %1, 0
br i1 %6, label %7, label %8
7: ; preds = %8, %5
ret void
8: ; preds = %5, %8
%9 = phi i64 [ %14, %8 ], [ 0, %5 ]
%10 = mul i64 %9, %2
%11 = getelementptr inbounds float, float* %0, i64 %10
%12 = tail call signext i8 @neuron_compute(float* %11, i64 %2, i8* %3)
%13 = getelementptr inbounds i8, i8* %4, i64 %9
store i8 %12, i8* %13
%14 = add nuw i64 %9, 1
%15 = icmp eq i64 %14, %1
br i1 %15, label %7, label %8
}