#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 /*<<< orphan*/ GF_inv(int);
int /*<<< orphan*/ GF_log(int);
int GF_mul(int, int /*<<< orphan*/);
int GF_mulX(int);
int GF_pow(int /*<<< orphan*/);
int GF_primitives(unsigned char *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, const char *argv[]) {
  int i;
  int nprimitives;
  unsigned char primitives[256];
  printf("pow(log(0x56)) == 0x%02X\n", GF_pow(GF_log(0x56)));
  printf("mul(0x77, inv(0x77)) == %d\n", GF_mul(0x77, GF_inv(0x77)));
  nprimitives = GF_primitives(primitives);
  printf("\nPrimitives:\n");
  for (i = 0; i < nprimitives; i++) {
    if (i % 8 == 0)
      printf("\n");
    printf("0x%02x ", primitives[i]);
  }
  printf("\nTotal: %d\n", nprimitives);
  printf("%02X\n", GF_mulX(0x88));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x56,%edi
call   1030 <GF_log@plt>
mov    %eax,%edi
call   1090 <GF_pow@plt>
mov    %eax,%esi
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x77,%edi
call   1040 <GF_inv@plt>
mov    %eax,%esi
mov    $0x77,%edi
call   1060 <GF_mul@plt>
mov    %eax,%esi
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x120(%rbp),%rdi
call   1070 <GF_primitives@plt>
mov    %eax,-0x18(%rbp)
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    124a <main+0xda>
mov    -0x14(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1222 <main+0xb2>
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movslq -0x14(%rbp),%rax
movzbl -0x120(%rbp,%rax,1),%esi
ff
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11f4 <main+0x84>
mov    -0x18(%rbp),%esi
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x88,%edi
call   1080 <GF_mulX@plt>
mov    %eax,%esi
lea    0xda6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    $0x56,%edi
call   1040 <GF_log@plt>
mov    %eax,%edi
call   10b0 <GF_pow@plt>
lea    0xe4b(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x77,%edi
call   1060 <GF_inv@plt>
mov    $0x77,%edi
mov    %eax,%esi
call   1080 <GF_mul@plt>
lea    0xe3f(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rsp,%rdi
call   1090 <GF_primitives@plt>
mov    %eax,%r14d
lea    0xe54(%rip),%rdi
call   1050 <puts@plt>
test   %r14d,%r14d
jle    1238 <main+0xa8>
mov    %r14d,%ebp
lea    0xe2c(%rip),%r15
xor    %ebx,%ebx
jmp    1227 <main+0x97>
xchg   %ax,%ax
movzbl (%rsp,%rbx,1),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
je     1238 <main+0xa8>
test   $0x7,%bl
jne    1210 <main+0x80>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1210 <main+0x80>
lea    0xdff(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x88,%edi
call   10a0 <GF_mulX@plt>
lea    0xdba(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"pow(log(0x56)) == 0x%02X\0A\00"
@.str.1 = [28 x i8] c"mul(0x77, inv(0x77)) == %d\0A\00"
@.str.2 = [14 x i8] c"\0APrimitives:\0A\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [8 x i8] c"0x%02x \00"
@.str.5 = [12 x i8] c"\0ATotal: %d\0A\00"
@.str.6 = [6 x i8] c"%02X\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca [256 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 @GF_log(i32 86)
%10 = call i32 @GF_pow(i32 %9)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = call i32 @GF_inv(i32 119)
%13 = call i32 @GF_mul(i32 119, i32 %12)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%16 = call i32 @GF_primitives(i8* %15)
store i32 %16, i32* %7
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %6
br label %18
18: ; preds = %35, %2
%19 = load i32, i32* %6
%20 = load i32, i32* %7
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %38
22: ; preds = %18
%23 = load i32, i32* %6
%24 = srem i32 %23, 8
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %28
28: ; preds = %26, %22
%29 = load i32, i32* %6
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 %30
%32 = load i8, i8* %31
%33 = zext i8 %32 to i32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %33)
br label %35
35: ; preds = %28
%36 = load i32, i32* %6
%37 = add nsw i32 %36, 1
store i32 %37, i32* %6
br label %18
38: ; preds = %18
%39 = load i32, i32* %7
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %39)
%41 = call i32 @GF_mulX(i32 136)
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 %41)
ret i32 0
}

LLVM IR (-O2):
@.str = [26 x i8] c"pow(log(0x56)) == 0x%02X\0A\00"
@.str.1 = [28 x i8] c"mul(0x77, inv(0x77)) == %d\0A\00"
@.str.4 = [8 x i8] c"0x%02x \00"
@.str.5 = [12 x i8] c"\0ATotal: %d\0A\00"
@.str.6 = [6 x i8] c"%02X\0A\00"
@str = [13 x i8] c"\0APrimitives:\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @GF_log(i32 86)
%6 = tail call i32 @GF_pow(i32 %5)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = tail call i32 @GF_inv(i32 119)
%9 = tail call i32 @GF_mul(i32 119, i32 %8)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = call i32 @GF_primitives(i8* %4)
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%13 = icmp sgt i32 %11, 0
br i1 %13, label %14, label %29
14: ; preds = %2
%15 = zext i32 %11 to i64
br label %16
16: ; preds = %14, %22
%17 = phi i64 [ 0, %14 ], [ %27, %22 ]
%18 = and i64 %17, 7
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = call i32 @putchar(i32 10)
br label %22
22: ; preds = %20, %16
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %17
%24 = load i8, i8* %23
%25 = zext i8 %24 to i32
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %25)
%27 = add nuw nsw i64 %17, 1
%28 = icmp eq i64 %27, %15
br i1 %28, label %29, label %16
29: ; preds = %22, %2
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %11)
%31 = call i32 @GF_mulX(i32 136)
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 %31)
ret i32 0
}