#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 */
uint8_t aes_GaloisFieldMultiply(uint8_t fixed, uint8_t variable) {
  uint8_t result = 0;
  while (fixed) {
    result ^= variable & ((fixed & 0x01) * 0xFF);
    variable = (((variable) << 1) ^ (0x1B & (((variable) >> 7) * 0xFF))) & 0xFF;
    fixed >>= 1;
  }
  return result;
}


x86 assembly (clang, -O0):
<aes_GaloisFieldMultiply>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     115f <aes_GaloisFieldMultiply+0x5f>
mov    -0x8(%rbp),%eax
mov    -0x4(%rbp),%ecx
and    $0x1,%ecx
imul   $0xff,%ecx,%ecx
and    %ecx,%eax
xor    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
shl    $0x1,%eax
mov    -0x8(%rbp),%ecx
sar    $0x7,%ecx
imul   $0xff,%ecx,%ecx
and    $0x1b,%ecx
xor    %ecx,%eax
and    $0xff,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1111 <aes_GaloisFieldMultiply+0x11>
mov    -0xc(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<aes_GaloisFieldMultiply>:
xor    %eax,%eax
test   %edi,%edi
je     113d <aes_GaloisFieldMultiply+0x3d>
mov    %edi,%r8d
nopl   0x0(%rax)
mov    %edi,%ecx
and    $0x1,%ecx
mov    %ecx,%edx
shl    $0x8,%edx
sub    %ecx,%edx
and    %esi,%edx
xor    %edx,%eax
lea    (%rsi,%rsi,1),%ecx
shr    $0x7,%esi
neg    %esi
and    $0x1b,%esi
movzbl %cl,%ecx
xor    %esi,%ecx
sar    %r8d
mov    %ecx,%esi
cmp    $0x1,%edi
mov    %r8d,%edi
ja     1110 <aes_GaloisFieldMultiply+0x10>
ret

LLVM IR (-O0):
define i32 @aes_GaloisFieldMultiply(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %9, %2
%7 = load i32, i32* %3
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %27
9: ; preds = %6
%10 = load i32, i32* %4
%11 = load i32, i32* %3
%12 = and i32 %11, 1
%13 = mul nsw i32 %12, 255
%14 = and i32 %10, %13
%15 = load i32, i32* %5
%16 = xor i32 %15, %14
store i32 %16, i32* %5
%17 = load i32, i32* %4
%18 = shl i32 %17, 1
%19 = load i32, i32* %4
%20 = ashr i32 %19, 7
%21 = mul nsw i32 %20, 255
%22 = and i32 27, %21
%23 = xor i32 %18, %22
%24 = and i32 %23, 255
store i32 %24, i32* %4
%25 = load i32, i32* %3
%26 = ashr i32 %25, 1
store i32 %26, i32* %3
br label %6
27: ; preds = %6
%28 = load i32, i32* %5
ret i32 %28
}

LLVM IR (-O2):
define i32 @aes_GaloisFieldMultiply(i32 %0, i32 %1) {
%3 = icmp eq i32 %0, 0
br i1 %3, label %20, label %4
4: ; preds = %2, %4
%5 = phi i32 [ %11, %4 ], [ 0, %2 ]
%6 = phi i32 [ %17, %4 ], [ %1, %2 ]
%7 = phi i32 [ %18, %4 ], [ %0, %2 ]
%8 = and i32 %7, 1
%9 = mul nuw nsw i32 %8, 255
%10 = and i32 %9, %6
%11 = xor i32 %10, %5
%12 = shl i32 %6, 1
%13 = ashr i32 %6, 7
%14 = mul nsw i32 %13, 255
%15 = and i32 %14, 27
%16 = and i32 %12, 254
%17 = xor i32 %15, %16
%18 = ashr i32 %7, 1
%19 = icmp ult i32 %7, 2
br i1 %19, label %20, label %4
20: ; preds = %4, %2
%21 = phi i32 [ 0, %2 ], [ %11, %4 ]
ret i32 %21
}