#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 DotProduct(unsigned char *, unsigned char *);
void MixColumn(unsigned char *column) {
  unsigned char row[8] = {0x02, 0x03, 0x01, 0x01, 0x02, 0x03, 0x01, 0x01};
  unsigned char result[4];
  result[0] = DotProduct(row + 0, column);
  result[1] = DotProduct(row + 3, column);
  result[2] = DotProduct(row + 2, column);
  result[3] = DotProduct(row + 1, column);
  column[0] = result[0];
  column[1] = result[1];
  column[2] = result[2];
  column[3] = result[3];
}


x86 assembly (clang, -O0):
<MixColumn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    0xedd(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <DotProduct@plt>
mov    %al,-0x14(%rbp)
lea    -0x10(%rbp),%rdi
add    $0x3,%rdi
mov    -0x8(%rbp),%rsi
call   1030 <DotProduct@plt>
mov    %al,-0x13(%rbp)
lea    -0x10(%rbp),%rdi
add    $0x2,%rdi
mov    -0x8(%rbp),%rsi
call   1030 <DotProduct@plt>
mov    %al,-0x12(%rbp)
lea    -0x10(%rbp),%rdi
add    $0x1,%rdi
mov    -0x8(%rbp),%rsi
call   1030 <DotProduct@plt>
mov    %al,-0x11(%rbp)
mov    -0x14(%rbp),%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
mov    -0x13(%rbp),%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x12(%rbp),%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0x11(%rbp),%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x3(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MixColumn>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
movabs $0x101030201010302,%rax
03 01 01
mov    %rax,(%rsp)
mov    %rsp,%rdi
mov    %rbx,%rsi
call   1030 <DotProduct@plt>
mov    %eax,%ebp
lea    0x3(%rsp),%rdi
mov    %rbx,%rsi
call   1030 <DotProduct@plt>
mov    %eax,%r14d
lea    0x2(%rsp),%rdi
mov    %rbx,%rsi
call   1030 <DotProduct@plt>
mov    %eax,%r15d
lea    0x1(%rsp),%rdi
mov    %rbx,%rsi
call   1030 <DotProduct@plt>
mov    %bpl,(%rbx)
mov    %r14b,0x1(%rbx)
mov    %r15b,0x2(%rbx)
mov    %al,0x3(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.MixColumn.row = [8 x i8] c"\02\03\01\01\02\03\01\01"
define void @MixColumn(i8* %0) {
%2 = alloca i8*
%3 = alloca [8 x i8]
%4 = alloca [4 x i8]
store i8* %0, i8** %2
%5 = bitcast [8 x i8]* %3 to i8*
%6 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds i8, i8* %6, i64 0
%8 = load i8*, i8** %2
%9 = call zeroext i8 @DotProduct(i8* %7, i8* %8)
%10 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
store i8 %9, i8* %10
%11 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%12 = getelementptr inbounds i8, i8* %11, i64 3
%13 = load i8*, i8** %2
%14 = call zeroext i8 @DotProduct(i8* %12, i8* %13)
%15 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 1
store i8 %14, i8* %15
%16 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%17 = getelementptr inbounds i8, i8* %16, i64 2
%18 = load i8*, i8** %2
%19 = call zeroext i8 @DotProduct(i8* %17, i8* %18)
%20 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 2
store i8 %19, i8* %20
%21 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%22 = getelementptr inbounds i8, i8* %21, i64 1
%23 = load i8*, i8** %2
%24 = call zeroext i8 @DotProduct(i8* %22, i8* %23)
%25 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 3
store i8 %24, i8* %25
%26 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%27 = load i8, i8* %26
%28 = load i8*, i8** %2
%29 = getelementptr inbounds i8, i8* %28, i64 0
store i8 %27, i8* %29
%30 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 1
%31 = load i8, i8* %30
%32 = load i8*, i8** %2
%33 = getelementptr inbounds i8, i8* %32, i64 1
store i8 %31, i8* %33
%34 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 2
%35 = load i8, i8* %34
%36 = load i8*, i8** %2
%37 = getelementptr inbounds i8, i8* %36, i64 2
store i8 %35, i8* %37
%38 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 3
%39 = load i8, i8* %38
%40 = load i8*, i8** %2
%41 = getelementptr inbounds i8, i8* %40, i64 3
store i8 %39, i8* %41
ret void
}

LLVM IR (-O2):
define void @MixColumn(i8* %0) {
%2 = alloca i64
%3 = bitcast i64* %2 to i8*
store i64 72342376156300034, i64* %2
%4 = call zeroext i8 @DotProduct(i8* %3, i8* %0)
%5 = getelementptr inbounds i8, i8* %3, i64 3
%6 = call zeroext i8 @DotProduct(i8* %5, i8* %0)
%7 = getelementptr inbounds i8, i8* %3, i64 2
%8 = call zeroext i8 @DotProduct(i8* %7, i8* %0)
%9 = getelementptr inbounds i8, i8* %3, i64 1
%10 = call zeroext i8 @DotProduct(i8* %9, i8* %0)
store i8 %4, i8* %0
%11 = getelementptr inbounds i8, i8* %0, i64 1
store i8 %6, i8* %11
%12 = getelementptr inbounds i8, i8* %0, i64 2
store i8 %8, i8* %12
%13 = getelementptr inbounds i8, i8* %0, i64 3
store i8 %10, i8* %13
ret void
}