#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 */
unsigned char GF_mulX(unsigned char);
unsigned char GF_mul(unsigned char a, unsigned char b) {
  int bits = 7;
  unsigned char c = 0;
  while (bits--) {
    c ^= a * ((b & 0x80) >> 7);
    c = GF_mulX(c);
    b <<= 1;
  }
  c ^= a * ((b & 0x80) >> 7);
  return c;
}


x86 assembly (clang, -O0):
<GF_mul>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %dil,%cl
mov    %cl,-0x1(%rbp)
mov    %al,-0x2(%rbp)
movl   $0x7,-0x8(%rbp)
movb   $0x0,-0x9(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     117a <GF_mul+0x6a>
movzbl -0x1(%rbp),%ecx
movzbl -0x2(%rbp),%eax
and    $0x80,%eax
sar    $0x7,%eax
imul   %eax,%ecx
movzbl -0x9(%rbp),%eax
xor    %ecx,%eax
mov    %al,-0x9(%rbp)
movzbl -0x9(%rbp),%edi
call   1030 <GF_mulX@plt>
mov    %al,-0x9(%rbp)
movzbl -0x2(%rbp),%eax
shl    $0x1,%eax
mov    %al,-0x2(%rbp)
jmp    112f <GF_mul+0x1f>
movzbl -0x1(%rbp),%ecx
movzbl -0x2(%rbp),%eax
and    $0x80,%eax
sar    $0x7,%eax
imul   %eax,%ecx
movzbl -0x9(%rbp),%eax
xor    %ecx,%eax
mov    %al,-0x9(%rbp)
movzbl -0x9(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GF_mul>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
mov    %ebx,%eax
sar    $0x7,%al
and    %bpl,%al
movzbl %al,%edi
call   1030 <GF_mulX@plt>
lea    (%rbx,%rbx,1),%ecx
sar    $0x7,%cl
and    %bpl,%cl
xor    %al,%cl
movzbl %cl,%edi
call   1030 <GF_mulX@plt>
lea    0x0(,%rbx,4),%ecx
sar    $0x7,%cl
and    %bpl,%cl
xor    %al,%cl
movzbl %cl,%edi
call   1030 <GF_mulX@plt>
lea    0x0(,%rbx,8),%ecx
sar    $0x7,%cl
and    %bpl,%cl
xor    %al,%cl
movzbl %cl,%edi
call   1030 <GF_mulX@plt>
mov    %ebx,%ecx
shl    $0x4,%cl
sar    $0x7,%cl
and    %bpl,%cl
xor    %al,%cl
movzbl %cl,%edi
call   1030 <GF_mulX@plt>
mov    %ebx,%ecx
shl    $0x5,%cl
sar    $0x7,%cl
and    %bpl,%cl
xor    %al,%cl
movzbl %cl,%edi
call   1030 <GF_mulX@plt>
mov    %ebx,%ecx
shl    $0x6,%cl
sar    $0x7,%cl
and    %bpl,%cl
xor    %al,%cl
movzbl %cl,%edi
call   1030 <GF_mulX@plt>
and    $0x1,%bl
neg    %bl
and    %bpl,%bl
xor    %bl,%al
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define zeroext i8 @GF_mul(i8 zeroext %0, i8 zeroext %1) {
%3 = alloca i8
%4 = alloca i8
%5 = alloca i32
%6 = alloca i8
store i8 %0, i8* %3
store i8 %1, i8* %4
store i32 7, i32* %5
store i8 0, i8* %6
br label %7
7: ; preds = %11, %2
%8 = load i32, i32* %5
%9 = add nsw i32 %8, -1
store i32 %9, i32* %5
%10 = icmp ne i32 %8, 0
br i1 %10, label %11, label %29
11: ; preds = %7
%12 = load i8, i8* %3
%13 = zext i8 %12 to i32
%14 = load i8, i8* %4
%15 = zext i8 %14 to i32
%16 = and i32 %15, 128
%17 = ashr i32 %16, 7
%18 = mul nsw i32 %13, %17
%19 = load i8, i8* %6
%20 = zext i8 %19 to i32
%21 = xor i32 %20, %18
%22 = trunc i32 %21 to i8
store i8 %22, i8* %6
%23 = load i8, i8* %6
%24 = call zeroext i8 @GF_mulX(i8 zeroext %23)
store i8 %24, i8* %6
%25 = load i8, i8* %4
%26 = zext i8 %25 to i32
%27 = shl i32 %26, 1
%28 = trunc i32 %27 to i8
store i8 %28, i8* %4
br label %7
29: ; preds = %7
%30 = load i8, i8* %3
%31 = zext i8 %30 to i32
%32 = load i8, i8* %4
%33 = zext i8 %32 to i32
%34 = and i32 %33, 128
%35 = ashr i32 %34, 7
%36 = mul nsw i32 %31, %35
%37 = load i8, i8* %6
%38 = zext i8 %37 to i32
%39 = xor i32 %38, %36
%40 = trunc i32 %39 to i8
store i8 %40, i8* %6
%41 = load i8, i8* %6
ret i8 %41
}

LLVM IR (-O2):
define zeroext i8 @GF_mul(i8 zeroext %0, i8 zeroext %1) {
%3 = icmp slt i8 %1, 0
%4 = select i1 %3, i8 %0, i8 0
%5 = tail call zeroext i8 @GF_mulX(i8 zeroext %4)
%6 = and i8 %1, 64
%7 = icmp eq i8 %6, 0
%8 = select i1 %7, i8 0, i8 %0
%9 = xor i8 %8, %5
%10 = tail call zeroext i8 @GF_mulX(i8 zeroext %9)
%11 = and i8 %1, 32
%12 = icmp eq i8 %11, 0
%13 = select i1 %12, i8 0, i8 %0
%14 = xor i8 %13, %10
%15 = tail call zeroext i8 @GF_mulX(i8 zeroext %14)
%16 = and i8 %1, 16
%17 = icmp eq i8 %16, 0
%18 = select i1 %17, i8 0, i8 %0
%19 = xor i8 %18, %15
%20 = tail call zeroext i8 @GF_mulX(i8 zeroext %19)
%21 = and i8 %1, 8
%22 = icmp eq i8 %21, 0
%23 = select i1 %22, i8 0, i8 %0
%24 = xor i8 %23, %20
%25 = tail call zeroext i8 @GF_mulX(i8 zeroext %24)
%26 = and i8 %1, 4
%27 = icmp eq i8 %26, 0
%28 = select i1 %27, i8 0, i8 %0
%29 = xor i8 %28, %25
%30 = tail call zeroext i8 @GF_mulX(i8 zeroext %29)
%31 = and i8 %1, 2
%32 = icmp eq i8 %31, 0
%33 = select i1 %32, i8 0, i8 %0
%34 = xor i8 %33, %30
%35 = tail call zeroext i8 @GF_mulX(i8 zeroext %34)
%36 = and i8 %1, 1
%37 = icmp eq i8 %36, 0
%38 = select i1 %37, i8 0, i8 %0
%39 = xor i8 %38, %35
ret i8 %39
}