#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*/ data;

/* Variables and functions */
int /*<<< orphan*/ gen_logs(unsigned int, int, unsigned int *, unsigned int *);
int /*<<< orphan*/ print_logs(char const *, int, unsigned int *, unsigned int *,
                              int, int);
void test_generate(int generate) {
  struct item {
    const char *name;
    int logmod;
    unsigned int prime_poly;
    int u16;
  };
  struct item data[] = {
      {"0x13", 15, 0x13, 0},    {"0x25", 31, 0x25, 0},
      {"0x43", 63, 0x43, 0},    {"0x89", 127, 0x89, 0},
      {"0x11d", 255, 0x11d, 0}, {"0x12d", 255, 0x12d, 0},
      {"0x163", 255, 0x163, 0},
  };
  int data_size = ((int)(sizeof(data) / sizeof((data)[0])));
  int i;
  unsigned int logt[4096];
  unsigned int alog[8192];
  if (!generate) {
    return;
  }
  for (i = 0; i < data_size; i++) {
    gen_logs(data[i].prime_poly, data[i].logmod, logt, alog);
    print_logs(data[i].name, data[i].logmod, logt, alog, data[i].u16,
               i + 1 == data_size);
  }
}


x86 assembly (clang, -O0):
<test_generate>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0c0,%rsp
mov    %edi,-0x4(%rbp)
lea    -0xb0(%rbp),%rdi
lea    0x2c24(%rip),%rsi
mov    $0xa8,%edx
call   1030 <memcpy@plt>
movl   $0x7,-0xb4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    116f <test_generate+0x3f>
jmp    1256 <test_generate+0x126>
movl   $0x0,-0xb8(%rbp)
mov    -0xb8(%rbp),%eax
cmp    -0xb4(%rbp),%eax
jge    1256 <test_generate+0x126>
movslq -0xb8(%rbp),%rcx
lea    -0xb0(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
mov    0xc(%rax),%edi
movslq -0xb8(%rbp),%rcx
lea    -0xb0(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
mov    0x8(%rax),%esi
lea    -0x40c0(%rbp),%rdx
lea    -0xc0c0(%rbp),%rcx
call   1040 <gen_logs@plt>
movslq -0xb8(%rbp),%rcx
lea    -0xb0(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
mov    (%rax),%rdi
movslq -0xb8(%rbp),%rcx
lea    -0xb0(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
mov    0x8(%rax),%esi
lea    -0x40c0(%rbp),%rdx
lea    -0xc0c0(%rbp),%rcx
movslq -0xb8(%rbp),%r8
lea    -0xb0(%rbp),%rax
imul   $0x18,%r8,%r8
add    %r8,%rax
mov    0x10(%rax),%r8d
mov    -0xb8(%rbp),%eax
add    $0x1,%eax
cmp    -0xb4(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%r9d
call   1050 <print_logs@plt>
mov    -0xb8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb8(%rbp)
jmp    1179 <test_generate+0x49>
add    $0xc0c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_generate>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xc000,%rsp
test   %edi,%edi
je     1198 <test_generate+0x78>
mov    $0x10,%ebx
lea    0x2c31(%rip),%r12
mov    %rsp,%r14
lea    0x4000(%rsp),%r15
nopw   0x0(%rax,%rax,1)
mov    -0x4(%rbx,%r12,1),%edi
mov    -0x8(%rbx,%r12,1),%ebp
mov    %ebp,%esi
mov    %r14,%rdx
mov    %r15,%rcx
call   1030 <gen_logs@plt>
mov    -0x10(%rbx,%r12,1),%rdi
mov    (%rbx,%r12,1),%r8d
xor    %r9d,%r9d
cmp    $0xa0,%rbx
sete   %r9b
mov    %ebp,%esi
mov    %r14,%rdx
mov    %r15,%rcx
call   1040 <print_logs@plt>
add    $0x18,%rbx
cmp    $0xb8,%rbx
jne    1150 <test_generate+0x30>
add    $0xc000,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.item = type { i8*, i32, i32, i32 }
@.str = [5 x i8] c"0x13\00"
@.str.1 = [5 x i8] c"0x25\00"
@.str.2 = [5 x i8] c"0x43\00"
@.str.3 = [5 x i8] c"0x89\00"
@.str.4 = [6 x i8] c"0x11d\00"
@.str.5 = [6 x i8] c"0x12d\00"
@.str.6 = [6 x i8] c"0x163\00"
@__const.test_generate.data = [7 x %struct.item] [%struct.item { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i32 15, i32 19, i32 0 }, %struct.item { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i32 31, i32 37, i32 0 }, %struct.item { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i32 63, i32 67, i32 0 }, %struct.item { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0), i32 127, i32 137, i32 0 }, %struct.item { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i32 0, i32 0), i32 255, i32 285, i32 0 }, %struct.item { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i32 0, i32 0), i32 255, i32 301, i32 0 }, %struct.item { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i32 0, i32 0), i32 255, i32 355, i32 0 }]
define void @test_generate(i32 %0) {
%2 = alloca i32
%3 = alloca [7 x %struct.item]
%4 = alloca i32
%5 = alloca i32
%6 = alloca [4096 x i32]
%7 = alloca [8192 x i32]
store i32 %0, i32* %2
%8 = bitcast [7 x %struct.item]* %3 to i8*
store i32 7, i32* %4
%9 = load i32, i32* %2
%10 = icmp ne i32 %9, 0
br i1 %10, label %12, label %11
11: ; preds = %1
br label %57
12: ; preds = %1
store i32 0, i32* %5
br label %13
13: ; preds = %54, %12
%14 = load i32, i32* %5
%15 = load i32, i32* %4
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %57
17: ; preds = %13
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [7 x %struct.item], [7 x %struct.item]* %3, i64 0, i64 %19
%21 = getelementptr inbounds %struct.item, %struct.item* %20, i32 0, i32 2
%22 = load i32, i32* %21
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [7 x %struct.item], [7 x %struct.item]* %3, i64 0, i64 %24
%26 = getelementptr inbounds %struct.item, %struct.item* %25, i32 0, i32 1
%27 = load i32, i32* %26
%28 = getelementptr inbounds [4096 x i32], [4096 x i32]* %6, i64 0, i64 0
%29 = getelementptr inbounds [8192 x i32], [8192 x i32]* %7, i64 0, i64 0
%30 = call i32 @gen_logs(i32 %22, i32 %27, i32* %28, i32* %29)
%31 = load i32, i32* %5
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [7 x %struct.item], [7 x %struct.item]* %3, i64 0, i64 %32
%34 = getelementptr inbounds %struct.item, %struct.item* %33, i32 0, i32 0
%35 = load i8*, i8** %34
%36 = load i32, i32* %5
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [7 x %struct.item], [7 x %struct.item]* %3, i64 0, i64 %37
%39 = getelementptr inbounds %struct.item, %struct.item* %38, i32 0, i32 1
%40 = load i32, i32* %39
%41 = getelementptr inbounds [4096 x i32], [4096 x i32]* %6, i64 0, i64 0
%42 = getelementptr inbounds [8192 x i32], [8192 x i32]* %7, i64 0, i64 0
%43 = load i32, i32* %5
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [7 x %struct.item], [7 x %struct.item]* %3, i64 0, i64 %44
%46 = getelementptr inbounds %struct.item, %struct.item* %45, i32 0, i32 3
%47 = load i32, i32* %46
%48 = load i32, i32* %5
%49 = add nsw i32 %48, 1
%50 = load i32, i32* %4
%51 = icmp eq i32 %49, %50
%52 = zext i1 %51 to i32
%53 = call i32 @print_logs(i8* %35, i32 %40, i32* %41, i32* %42, i32 %47, i32 %52)
br label %54
54: ; preds = %17
%55 = load i32, i32* %5
%56 = add nsw i32 %55, 1
store i32 %56, i32* %5
br label %13
57: ; preds = %11, %13
ret void
}

LLVM IR (-O2):
%struct.item = type { i8*, i32, i32, i32 }
@.str = [5 x i8] c"0x13\00"
@.str.1 = [5 x i8] c"0x25\00"
@.str.2 = [5 x i8] c"0x43\00"
@.str.3 = [5 x i8] c"0x89\00"
@.str.4 = [6 x i8] c"0x11d\00"
@.str.5 = [6 x i8] c"0x12d\00"
@.str.6 = [6 x i8] c"0x163\00"
@__const.test_generate.data = [7 x %struct.item] [%struct.item { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i32 15, i32 19, i32 0 }, %struct.item { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i32 31, i32 37, i32 0 }, %struct.item { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i32 63, i32 67, i32 0 }, %struct.item { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0), i32 127, i32 137, i32 0 }, %struct.item { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i32 0, i32 0), i32 255, i32 285, i32 0 }, %struct.item { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i32 0, i32 0), i32 255, i32 301, i32 0 }, %struct.item { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i32 0, i32 0), i32 255, i32 355, i32 0 }]
define void @test_generate(i32 %0) {
%2 = alloca [4096 x i32]
%3 = alloca [8192 x i32]
%4 = bitcast [4096 x i32]* %2 to i8*
%5 = bitcast [8192 x i32]* %3 to i8*
%6 = icmp eq i32 %0, 0
br i1 %6, label %26, label %7
7: ; preds = %1
%8 = getelementptr inbounds [4096 x i32], [4096 x i32]* %2, i64 0, i64 0
%9 = getelementptr inbounds [8192 x i32], [8192 x i32]* %3, i64 0, i64 0
br label %10
10: ; preds = %7, %10
%11 = phi i64 [ 0, %7 ], [ %21, %10 ]
%12 = getelementptr inbounds [7 x %struct.item], [7 x %struct.item]* @__const.test_generate.data, i64 0, i64 %11, i32 2
%13 = load i32, i32* %12
%14 = getelementptr inbounds [7 x %struct.item], [7 x %struct.item]* @__const.test_generate.data, i64 0, i64 %11, i32 1
%15 = load i32, i32* %14
%16 = call i32 @gen_logs(i32 %13, i32 %15, i32* %8, i32* %9)
%17 = getelementptr inbounds [7 x %struct.item], [7 x %struct.item]* @__const.test_generate.data, i64 0, i64 %11, i32 0
%18 = load i8*, i8** %17
%19 = getelementptr inbounds [7 x %struct.item], [7 x %struct.item]* @__const.test_generate.data, i64 0, i64 %11, i32 3
%20 = load i32, i32* %19
%21 = add nuw nsw i64 %11, 1
%22 = icmp eq i64 %21, 7
%23 = zext i1 %22 to i32
%24 = call i32 @print_logs(i8* %18, i32 %15, i32* %8, i32* %9, i32 %20, i32 %23)
%25 = icmp eq i64 %21, 7
br i1 %25, label %26, label %10
26: ; preds = %10, %1
ret void
}