#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char const *, ...);
void print_pattern_table(int channel_count, int unused_channels,
                         int *unique_pattern_count, const char *label_prefix,
                         FILE *out) {
  int chn;
  fprintf(out, "%spattern_table:\n", label_prefix);
  for (chn = 0; chn < channel_count; ++chn) {
    int i;
    if (unused_channels & (1 << chn))
      continue;
    for (i = 0; i < unique_pattern_count[chn]; ++i)
      fprintf(out, ".dw %schn%d_ptn%d\n", label_prefix, chn, i);
  }
}


x86 assembly (clang, -O0):
<print_pattern_table>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xec7(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11cb <print_pattern_table+0xbb>
mov    -0x8(%rbp),%eax
mov    -0x24(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1172 <print_pattern_table+0x62>
jmp    11bd <print_pattern_table+0xad>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    -0x10(%rbp),%rcx
movslq -0x24(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jge    11b8 <print_pattern_table+0xa8>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%r8d
lea    0xe6f(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1179 <print_pattern_table+0x69>
jmp    11bd <print_pattern_table+0xad>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1147 <print_pattern_table+0x37>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_pattern_table>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,%rbx
mov    %esi,0xc(%rsp)
mov    %edi,%ebp
lea    0xecc(%rip),%rsi
mov    %r8,%rdi
mov    %rcx,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
test   %ebp,%ebp
jle    11a1 <print_pattern_table+0x91>
mov    %ebp,%eax
mov    %rax,0x10(%rsp)
lea    0xebf(%rip),%r13
xor    %ebp,%ebp
jmp    116b <print_pattern_table+0x5b>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbp
cmp    0x10(%rsp),%rbp
je     11a1 <print_pattern_table+0x91>
mov    0xc(%rsp),%eax
bt     %ebp,%eax
jb     1160 <print_pattern_table+0x50>
cmpl   $0x0,(%rbx,%rbp,4)
jle    1160 <print_pattern_table+0x50>
xor    %r12d,%r12d
nopl   (%rax)
mov    %r14,%rdi
mov    %r13,%rsi
mov    %r15,%rdx
mov    %ebp,%ecx
mov    %r12d,%r8d
xor    %eax,%eax
call   1030 <fprintf@plt>
add    $0x1,%r12d
cmp    (%rbx,%rbp,4),%r12d
jl     1180 <print_pattern_table+0x70>
jmp    1160 <print_pattern_table+0x50>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"%spattern_table:\0A\00"
@.str.1 = [19 x i8] c".dw %schn%d_ptn%d\0A\00"
define void @print_pattern_table(i32 %0, i32 %1, i32* %2, i8* %3, i32* %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i8*
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i32
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32* %2, i32** %8
store i8* %3, i8** %9
store i32* %4, i32** %10
%13 = load i32*, i32** %10
%14 = load i8*, i8** %9
%15 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %13, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %14)
store i32 0, i32* %11
br label %16
16: ; preds = %46, %5
%17 = load i32, i32* %11
%18 = load i32, i32* %6
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %49
20: ; preds = %16
%21 = load i32, i32* %7
%22 = load i32, i32* %11
%23 = shl i32 1, %22
%24 = and i32 %21, %23
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %20
br label %46
27: ; preds = %20
store i32 0, i32* %12
br label %28
28: ; preds = %42, %27
%29 = load i32, i32* %12
%30 = load i32*, i32** %8
%31 = load i32, i32* %11
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %30, i64 %32
%34 = load i32, i32* %33
%35 = icmp slt i32 %29, %34
br i1 %35, label %36, label %45
36: ; preds = %28
%37 = load i32*, i32** %10
%38 = load i8*, i8** %9
%39 = load i32, i32* %11
%40 = load i32, i32* %12
%41 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %37, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %38, i32 %39, i32 %40)
br label %42
42: ; preds = %36
%43 = load i32, i32* %12
%44 = add nsw i32 %43, 1
store i32 %44, i32* %12
br label %28
45: ; preds = %28
br label %46
46: ; preds = %45, %26
%47 = load i32, i32* %11
%48 = add nsw i32 %47, 1
store i32 %48, i32* %11
br label %16
49: ; preds = %16
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"%spattern_table:\0A\00"
@.str.1 = [19 x i8] c".dw %schn%d_ptn%d\0A\00"
define void @print_pattern_table(i32 %0, i32 %1, i32* nocapture %2, i8* %3, i32* nocapture %4) {
%6 = tail call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %4, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %3)
%7 = icmp sgt i32 %0, 0
br i1 %7, label %8, label %29
8: ; preds = %5
%9 = zext i32 %0 to i64
br label %10
10: ; preds = %8, %26
%11 = phi i64 [ 0, %8 ], [ %27, %26 ]
%12 = trunc i64 %11 to i32
%13 = shl nuw i32 1, %12
%14 = and i32 %13, %1
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %26
16: ; preds = %10
%17 = getelementptr inbounds i32, i32* %2, i64 %11
%18 = load i32, i32* %17
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %26
20: ; preds = %16, %20
%21 = phi i32 [ %23, %20 ], [ 0, %16 ]
%22 = tail call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %4, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %3, i32 %12, i32 %21)
%23 = add nuw nsw i32 %21, 1
%24 = load i32, i32* %17
%25 = icmp slt i32 %23, %24
br i1 %25, label %20, label %26
26: ; preds = %20, %16, %10
%27 = add nuw nsw i64 %11, 1
%28 = icmp eq i64 %27, %9
br i1 %28, label %29, label %10
29: ; preds = %26, %5
ret void
}