#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 mul_GF(unsigned char, int);
void inv_mixColumn(unsigned char buf[]) {
  int i;
  unsigned char a[4];
  for (i = 0; i < 4; i++) {
    a[i] = buf[i];
  }
  for (i = 0; i < 4; i++) {
    a[i] = mul_GF(buf[(i) % 4], 14) ^ mul_GF(buf[(i + 1) % 4], 11) ^
           mul_GF(buf[(i + 2) % 4], 13) ^ mul_GF(buf[(i + 3) % 4], 9);
  }
  for (i = 0; i < 4; i++) {
    buf[i] = a[i];
  }
  return;
}


x86 assembly (clang, -O0):
<inv_mixColumn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x4,-0xc(%rbp)
jge    114e <inv_mixColumn+0x3e>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
movslq -0xc(%rbp),%rax
mov    %cl,-0x10(%rbp,%rax,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <inv_mixColumn+0x13>
movl   $0x0,-0xc(%rbp)
cmpl   $0x4,-0xc(%rbp)
jge    124a <inv_mixColumn+0x13a>
mov    -0x8(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    -0x48(%rbp),%rax
movslq %edx,%rcx
mov    $0xe,%esi
movzbl (%rax,%rcx,1),%edi
call   1030 <mul_GF@plt>
movzbl %al,%eax
mov    %eax,-0x34(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    -0x40(%rbp),%rax
movslq %edx,%rcx
mov    $0xb,%esi
movzbl (%rax,%rcx,1),%edi
call   1030 <mul_GF@plt>
mov    %al,%cl
mov    -0x34(%rbp),%eax
movzbl %cl,%ecx
xor    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0xc(%rbp),%eax
add    $0x2,%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    -0x30(%rbp),%rax
movslq %edx,%rcx
mov    $0xd,%esi
movzbl (%rax,%rcx,1),%edi
call   1030 <mul_GF@plt>
mov    %al,%cl
mov    -0x24(%rbp),%eax
movzbl %cl,%ecx
xor    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0xc(%rbp),%eax
add    $0x3,%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    -0x20(%rbp),%rax
movslq %edx,%rcx
mov    $0x9,%esi
movzbl (%rax,%rcx,1),%edi
call   1030 <mul_GF@plt>
mov    %al,%cl
mov    -0x14(%rbp),%eax
movzbl %cl,%ecx
xor    %ecx,%eax
mov    %al,%cl
movslq -0xc(%rbp),%rax
mov    %cl,-0x10(%rbp,%rax,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1155 <inv_mixColumn+0x45>
movl   $0x0,-0xc(%rbp)
cmpl   $0x4,-0xc(%rbp)
jge    127c <inv_mixColumn+0x16c>
movslq -0xc(%rbp),%rax
mov    -0x10(%rbp,%rax,1),%dl
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1251 <inv_mixColumn+0x141>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inv_mixColumn>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
movzbl (%rdi),%edi
mov    $0xe,%esi
call   1030 <mul_GF@plt>
mov    %eax,%ebp
movzbl 0x1(%rbx),%edi
mov    $0xb,%esi
call   1030 <mul_GF@plt>
mov    %eax,%r14d
xor    %bpl,%r14b
movzbl 0x2(%rbx),%edi
mov    $0xd,%esi
call   1030 <mul_GF@plt>
mov    %eax,%r15d
movzbl 0x3(%rbx),%edi
mov    $0x9,%esi
call   1030 <mul_GF@plt>
mov    %eax,%ebp
xor    %r15b,%bpl
xor    %r14b,%bpl
movzbl 0x1(%rbx),%edi
mov    $0xe,%esi
call   1030 <mul_GF@plt>
mov    %eax,%r14d
movzbl 0x2(%rbx),%edi
mov    $0xb,%esi
call   1030 <mul_GF@plt>
mov    %eax,%r15d
xor    %r14b,%r15b
movzbl 0x3(%rbx),%edi
mov    $0xd,%esi
call   1030 <mul_GF@plt>
mov    %eax,%r12d
movzbl (%rbx),%edi
mov    $0x9,%esi
call   1030 <mul_GF@plt>
mov    %eax,%r14d
xor    %r12b,%r14b
xor    %r15b,%r14b
movzbl 0x2(%rbx),%edi
mov    $0xe,%esi
call   1030 <mul_GF@plt>
mov    %eax,%r15d
movzbl 0x3(%rbx),%edi
mov    $0xb,%esi
call   1030 <mul_GF@plt>
mov    %eax,%r12d
xor    %r15b,%r12b
movzbl (%rbx),%edi
mov    $0xd,%esi
call   1030 <mul_GF@plt>
mov    %eax,%r13d
movzbl 0x1(%rbx),%edi
mov    $0x9,%esi
call   1030 <mul_GF@plt>
mov    %eax,%r15d
xor    %r13b,%r15b
xor    %r12b,%r15b
movzbl 0x3(%rbx),%edi
mov    $0xe,%esi
call   1030 <mul_GF@plt>
mov    %eax,%r12d
movzbl (%rbx),%edi
mov    $0xb,%esi
call   1030 <mul_GF@plt>
mov    %eax,%r13d
xor    %r12b,%r13b
movzbl 0x1(%rbx),%edi
mov    $0xd,%esi
call   1030 <mul_GF@plt>
mov    %eax,%r12d
movzbl 0x2(%rbx),%edi
mov    $0x9,%esi
call   1030 <mul_GF@plt>
xor    %r12b,%al
xor    %r13b,%al
mov    %bpl,(%rbx)
mov    %r14b,0x1(%rbx)
mov    %r15b,0x2(%rbx)
mov    %al,0x3(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @inv_mixColumn(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca [4 x i8]
store i8* %0, i8** %2
store i32 0, i32* %3
br label %5
5: ; preds = %17, %1
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 4
br i1 %7, label %8, label %20
8: ; preds = %5
%9 = load i8*, i8** %2
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %9, i64 %11
%13 = load i8, i8* %12
%14 = load i32, i32* %3
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 %15
store i8 %13, i8* %16
br label %17
17: ; preds = %8
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
store i32 %19, i32* %3
br label %5
20: ; preds = %5
store i32 0, i32* %3
br label %21
21: ; preds = %67, %20
%22 = load i32, i32* %3
%23 = icmp slt i32 %22, 4
br i1 %23, label %24, label %70
24: ; preds = %21
%25 = load i8*, i8** %2
%26 = load i32, i32* %3
%27 = srem i32 %26, 4
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %25, i64 %28
%30 = load i8, i8* %29
%31 = call zeroext i8 @mul_GF(i8 zeroext %30, i32 14)
%32 = zext i8 %31 to i32
%33 = load i8*, i8** %2
%34 = load i32, i32* %3
%35 = add nsw i32 %34, 1
%36 = srem i32 %35, 4
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %33, i64 %37
%39 = load i8, i8* %38
%40 = call zeroext i8 @mul_GF(i8 zeroext %39, i32 11)
%41 = zext i8 %40 to i32
%42 = xor i32 %32, %41
%43 = load i8*, i8** %2
%44 = load i32, i32* %3
%45 = add nsw i32 %44, 2
%46 = srem i32 %45, 4
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8, i8* %43, i64 %47
%49 = load i8, i8* %48
%50 = call zeroext i8 @mul_GF(i8 zeroext %49, i32 13)
%51 = zext i8 %50 to i32
%52 = xor i32 %42, %51
%53 = load i8*, i8** %2
%54 = load i32, i32* %3
%55 = add nsw i32 %54, 3
%56 = srem i32 %55, 4
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8, i8* %53, i64 %57
%59 = load i8, i8* %58
%60 = call zeroext i8 @mul_GF(i8 zeroext %59, i32 9)
%61 = zext i8 %60 to i32
%62 = xor i32 %52, %61
%63 = trunc i32 %62 to i8
%64 = load i32, i32* %3
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 %65
store i8 %63, i8* %66
br label %67
67: ; preds = %24
%68 = load i32, i32* %3
%69 = add nsw i32 %68, 1
store i32 %69, i32* %3
br label %21
70: ; preds = %21
store i32 0, i32* %3
br label %71
71: ; preds = %83, %70
%72 = load i32, i32* %3
%73 = icmp slt i32 %72, 4
br i1 %73, label %74, label %86
74: ; preds = %71
%75 = load i32, i32* %3
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 %76
%78 = load i8, i8* %77
%79 = load i8*, i8** %2
%80 = load i32, i32* %3
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds i8, i8* %79, i64 %81
store i8 %78, i8* %82
br label %83
83: ; preds = %74
%84 = load i32, i32* %3
%85 = add nsw i32 %84, 1
store i32 %85, i32* %3
br label %71
86: ; preds = %71
ret void
}

LLVM IR (-O2):
define void @inv_mixColumn(i8* nocapture %0) {
%2 = getelementptr inbounds i8, i8* %0, i64 1
%3 = getelementptr inbounds i8, i8* %0, i64 2
%4 = getelementptr inbounds i8, i8* %0, i64 3
%5 = load i8, i8* %0
%6 = tail call zeroext i8 @mul_GF(i8 zeroext %5, i32 14)
%7 = load i8, i8* %2
%8 = tail call zeroext i8 @mul_GF(i8 zeroext %7, i32 11)
%9 = xor i8 %8, %6
%10 = load i8, i8* %3
%11 = tail call zeroext i8 @mul_GF(i8 zeroext %10, i32 13)
%12 = xor i8 %9, %11
%13 = load i8, i8* %4
%14 = tail call zeroext i8 @mul_GF(i8 zeroext %13, i32 9)
%15 = xor i8 %12, %14
%16 = load i8, i8* %2
%17 = tail call zeroext i8 @mul_GF(i8 zeroext %16, i32 14)
%18 = load i8, i8* %3
%19 = tail call zeroext i8 @mul_GF(i8 zeroext %18, i32 11)
%20 = xor i8 %19, %17
%21 = load i8, i8* %4
%22 = tail call zeroext i8 @mul_GF(i8 zeroext %21, i32 13)
%23 = xor i8 %20, %22
%24 = load i8, i8* %0
%25 = tail call zeroext i8 @mul_GF(i8 zeroext %24, i32 9)
%26 = xor i8 %23, %25
%27 = load i8, i8* %3
%28 = tail call zeroext i8 @mul_GF(i8 zeroext %27, i32 14)
%29 = load i8, i8* %4
%30 = tail call zeroext i8 @mul_GF(i8 zeroext %29, i32 11)
%31 = xor i8 %30, %28
%32 = load i8, i8* %0
%33 = tail call zeroext i8 @mul_GF(i8 zeroext %32, i32 13)
%34 = xor i8 %31, %33
%35 = load i8, i8* %2
%36 = tail call zeroext i8 @mul_GF(i8 zeroext %35, i32 9)
%37 = xor i8 %34, %36
%38 = load i8, i8* %4
%39 = tail call zeroext i8 @mul_GF(i8 zeroext %38, i32 14)
%40 = load i8, i8* %0
%41 = tail call zeroext i8 @mul_GF(i8 zeroext %40, i32 11)
%42 = xor i8 %41, %39
%43 = load i8, i8* %2
%44 = tail call zeroext i8 @mul_GF(i8 zeroext %43, i32 13)
%45 = xor i8 %42, %44
%46 = load i8, i8* %3
%47 = tail call zeroext i8 @mul_GF(i8 zeroext %46, i32 9)
%48 = xor i8 %45, %47
store i8 %15, i8* %0
store i8 %26, i8* %2
store i8 %37, i8* %3
store i8 %48, i8* %4
ret void
}