#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 parity_counter(int, int);
void rsc_tail(int tail_p[], int g[], int max_states, int mm) {
  int state;
  for (state = 0; state < max_states; state++) {
    tail_p[state] = parity_counter(g[0] & state, mm);
  }
  return;
}


x86 assembly (clang, -O0):
<rsc_tail>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1165 <rsc_tail+0x55>
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
and    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1030 <parity_counter@plt>
mov    %eax,%edx
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112d <rsc_tail+0x1d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rsc_tail>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %edx,%edx
jle    114a <rsc_tail+0x3a>
mov    %ecx,%r14d
mov    %rsi,%r15
mov    %rdi,%r12
mov    %edx,%ebx
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    (%r15),%edi
and    %ebp,%edi
mov    %r14d,%esi
call   1030 <parity_counter@plt>
mov    %eax,(%r12,%rbp,4)
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1130 <rsc_tail+0x20>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @rsc_tail(i32* %0, i32* %1, i32 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i32 0, i32* %9
br label %10
10: ; preds = %26, %4
%11 = load i32, i32* %9
%12 = load i32, i32* %7
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %29
14: ; preds = %10
%15 = load i32*, i32** %6
%16 = getelementptr inbounds i32, i32* %15, i64 0
%17 = load i32, i32* %16
%18 = load i32, i32* %9
%19 = and i32 %17, %18
%20 = load i32, i32* %8
%21 = call i32 @parity_counter(i32 %19, i32 %20)
%22 = load i32*, i32** %5
%23 = load i32, i32* %9
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* %22, i64 %24
store i32 %21, i32* %25
br label %26
26: ; preds = %14
%27 = load i32, i32* %9
%28 = add nsw i32 %27, 1
store i32 %28, i32* %9
br label %10
29: ; preds = %10
ret void
}

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