#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 uint8_t;

/* Variables and functions */
int GF_mul_manual(int, int);
int /*<<< orphan*/ assert(int);
void gen_GF_log_ilog(uint8_t *GF_log, uint8_t *GF_ilog) {
  uint8_t gen = 1, i;
  assert(GF_log && GF_ilog);
  for (i = 0; i < 0xff; i++) {
    GF_log[gen] = i;
    GF_ilog[i] = gen;
    gen = GF_mul_manual(gen, (0x03));
  }
  GF_ilog[0xff] = gen;
  GF_log[0x00] = 0x00;
}


x86 assembly (clang, -O0):
<gen_GF_log_ilog>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x8(%rbp)
mov    %al,-0x19(%rbp)
je     1152 <gen_GF_log_ilog+0x32>
cmpq   $0x0,-0x10(%rbp)
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0xff,-0x18(%rbp)
jge    11ad <gen_GF_log_ilog+0x8d>
mov    -0x18(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%edi
mov    $0x3,%esi
call   1040 <GF_mul_manual@plt>
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1166 <gen_GF_log_ilog+0x46>
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x3fc(%rax)
mov    -0x8(%rbp),%rax
movl   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen_GF_log_ilog>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
test   %rdi,%rdi
setne  %al
test   %rsi,%rsi
setne  %cl
and    %al,%cl
movzbl %cl,%edi
call   1030 <assert@plt>
mov    $0x1,%eax
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movslq %eax,%rdi
mov    %ebx,(%r15,%rdi,4)
mov    %edi,(%r14,%rbx,4)
mov    $0x3,%esi
call   1040 <GF_mul_manual@plt>
add    $0x1,%rbx
cmp    $0xff,%rbx
jne    1150 <gen_GF_log_ilog+0x30>
mov    %eax,0x3fc(%r14)
movl   $0x0,(%r15)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @gen_GF_log_ilog(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
store i32 1, i32* %5
%7 = load i32*, i32** %3
%8 = icmp ne i32* %7, null
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i32*, i32** %4
%11 = icmp ne i32* %10, null
br label %12
12: ; preds = %9, %2
%13 = phi i1 [ false, %2 ], [ %11, %9 ]
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
store i32 0, i32* %6
br label %16
16: ; preds = %32, %12
%17 = load i32, i32* %6
%18 = icmp slt i32 %17, 255
br i1 %18, label %19, label %35
19: ; preds = %16
%20 = load i32, i32* %6
%21 = load i32*, i32** %3
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %21, i64 %23
store i32 %20, i32* %24
%25 = load i32, i32* %5
%26 = load i32*, i32** %4
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i32, i32* %26, i64 %28
store i32 %25, i32* %29
%30 = load i32, i32* %5
%31 = call i32 @GF_mul_manual(i32 %30, i32 3)
store i32 %31, i32* %5
br label %32
32: ; preds = %19
%33 = load i32, i32* %6
%34 = add nsw i32 %33, 1
store i32 %34, i32* %6
br label %16
35: ; preds = %16
%36 = load i32, i32* %5
%37 = load i32*, i32** %4
%38 = getelementptr inbounds i32, i32* %37, i64 255
store i32 %36, i32* %38
%39 = load i32*, i32** %3
%40 = getelementptr inbounds i32, i32* %39, i64 0
store i32 0, i32* %40
ret void
}

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