#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 galois_multiply(unsigned char, int);
void mixcolumns(unsigned char *state0, unsigned char *state1,
                unsigned char *state2, unsigned char *state3) {
  unsigned char temp[4] = {*state0, *state1, *state2, *state3};
  *state0 = galois_multiply(temp[0], 2) ^ galois_multiply(temp[3], 1) ^
            galois_multiply(temp[2], 1) ^ galois_multiply(temp[1], 3);
  *state1 = galois_multiply(temp[1], 2) ^ galois_multiply(temp[0], 1) ^
            galois_multiply(temp[3], 1) ^ galois_multiply(temp[2], 3);
  *state2 = galois_multiply(temp[2], 2) ^ galois_multiply(temp[1], 1) ^
            galois_multiply(temp[0], 1) ^ galois_multiply(temp[3], 3);
  *state3 = galois_multiply(temp[3], 2) ^ galois_multiply(temp[2], 1) ^
            galois_multiply(temp[1], 1) ^ galois_multiply(temp[0], 3);
}


x86 assembly (clang, -O0):
<mixcolumns>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x23(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x22(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x21(%rbp)
mov    $0x2,%esi
movzbl -0x24(%rbp),%edi
call   1030 <galois_multiply@plt>
movzbl %al,%eax
mov    %eax,-0x54(%rbp)
mov    $0x1,%esi
movzbl -0x21(%rbp),%edi
call   1030 <galois_multiply@plt>
mov    %al,%cl
mov    -0x54(%rbp),%eax
movzbl %cl,%ecx
xor    %ecx,%eax
mov    %eax,-0x50(%rbp)
mov    $0x1,%esi
movzbl -0x22(%rbp),%edi
call   1030 <galois_multiply@plt>
mov    %al,%cl
mov    -0x50(%rbp),%eax
movzbl %cl,%ecx
xor    %ecx,%eax
mov    %eax,-0x4c(%rbp)
mov    $0x3,%esi
movzbl -0x23(%rbp),%edi
call   1030 <galois_multiply@plt>
mov    %al,%cl
mov    -0x4c(%rbp),%eax
movzbl %cl,%ecx
xor    %ecx,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
mov    $0x2,%esi
movzbl -0x23(%rbp),%edi
call   1030 <galois_multiply@plt>
movzbl %al,%eax
mov    %eax,-0x48(%rbp)
mov    $0x1,%esi
movzbl -0x24(%rbp),%edi
call   1030 <galois_multiply@plt>
mov    %al,%cl
mov    -0x48(%rbp),%eax
movzbl %cl,%ecx
xor    %ecx,%eax
mov    %eax,-0x44(%rbp)
mov    $0x1,%esi
movzbl -0x21(%rbp),%edi
call   1030 <galois_multiply@plt>
mov    %al,%cl
mov    -0x44(%rbp),%eax
movzbl %cl,%ecx
xor    %ecx,%eax
mov    %eax,-0x40(%rbp)
mov    $0x3,%esi
movzbl -0x22(%rbp),%edi
call   1030 <galois_multiply@plt>
mov    %al,%cl
mov    -0x40(%rbp),%eax
movzbl %cl,%ecx
xor    %ecx,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    $0x2,%esi
movzbl -0x22(%rbp),%edi
call   1030 <galois_multiply@plt>
movzbl %al,%eax
mov    %eax,-0x3c(%rbp)
mov    $0x1,%esi
movzbl -0x23(%rbp),%edi
call   1030 <galois_multiply@plt>
mov    %al,%cl
mov    -0x3c(%rbp),%eax
movzbl %cl,%ecx
xor    %ecx,%eax
mov    %eax,-0x38(%rbp)
mov    $0x1,%esi
movzbl -0x24(%rbp),%edi
call   1030 <galois_multiply@plt>
mov    %al,%cl
mov    -0x38(%rbp),%eax
movzbl %cl,%ecx
xor    %ecx,%eax
mov    %eax,-0x34(%rbp)
mov    $0x3,%esi
movzbl -0x21(%rbp),%edi
call   1030 <galois_multiply@plt>
mov    %al,%cl
mov    -0x34(%rbp),%eax
movzbl %cl,%ecx
xor    %ecx,%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    $0x2,%esi
movzbl -0x21(%rbp),%edi
call   1030 <galois_multiply@plt>
movzbl %al,%eax
mov    %eax,-0x30(%rbp)
mov    $0x1,%esi
movzbl -0x22(%rbp),%edi
call   1030 <galois_multiply@plt>
mov    %al,%cl
mov    -0x30(%rbp),%eax
movzbl %cl,%ecx
xor    %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    $0x1,%esi
movzbl -0x23(%rbp),%edi
call   1030 <galois_multiply@plt>
mov    %al,%cl
mov    -0x2c(%rbp),%eax
movzbl %cl,%ecx
xor    %ecx,%eax
mov    %eax,-0x28(%rbp)
mov    $0x3,%esi
movzbl -0x24(%rbp),%edi
call   1030 <galois_multiply@plt>
mov    %al,%cl
mov    -0x28(%rbp),%eax
movzbl %cl,%ecx
xor    %ecx,%eax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,(%rax)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mixcolumns>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rcx,0x20(%rsp)
mov    %rdx,0x18(%rsp)
mov    %rsi,0x10(%rsp)
mov    %rdi,%r12
movzbl (%rdi),%edi
mov    %edi,0x8(%rsp)
movzbl (%rsi),%ebp
movzbl (%rdx),%ebx
mov    %ebx,0x4(%rsp)
movzbl (%rcx),%r13d
mov    $0x2,%esi
call   1030 <galois_multiply@plt>
mov    %eax,%r14d
mov    %r13d,%edi
mov    $0x1,%esi
call   1030 <galois_multiply@plt>
mov    %eax,%r15d
xor    %r14b,%r15b
mov    %ebx,%edi
mov    $0x1,%esi
call   1030 <galois_multiply@plt>
mov    %eax,%ebx
mov    %ebp,%edi
mov    $0x3,%esi
call   1030 <galois_multiply@plt>
xor    %bl,%al
xor    %r15b,%al
mov    %al,(%r12)
mov    %ebp,%edi
mov    %ebp,%r15d
mov    %ebp,0xc(%rsp)
mov    $0x2,%esi
call   1030 <galois_multiply@plt>
mov    %eax,%r14d
mov    0x8(%rsp),%ebp
mov    %ebp,%edi
mov    $0x1,%esi
call   1030 <galois_multiply@plt>
mov    %eax,%ebx
xor    %r14b,%bl
mov    %r13d,%edi
mov    $0x1,%esi
call   1030 <galois_multiply@plt>
mov    %eax,%r14d
mov    0x4(%rsp),%r12d
mov    %r12d,%edi
mov    $0x3,%esi
call   1030 <galois_multiply@plt>
xor    %r14b,%al
xor    %bl,%al
mov    0x10(%rsp),%rcx
mov    %al,(%rcx)
mov    %r12d,%edi
mov    $0x2,%esi
call   1030 <galois_multiply@plt>
mov    %eax,%r14d
mov    %r15d,%edi
mov    $0x1,%esi
call   1030 <galois_multiply@plt>
mov    %eax,%ebx
xor    %r14b,%bl
mov    %ebp,%edi
mov    %ebp,%r15d
mov    $0x1,%esi
call   1030 <galois_multiply@plt>
mov    %eax,%r14d
mov    %r13d,%edi
mov    $0x3,%esi
call   1030 <galois_multiply@plt>
xor    %r14b,%al
xor    %bl,%al
mov    0x18(%rsp),%rcx
mov    %al,(%rcx)
mov    %r13d,%edi
mov    $0x2,%esi
call   1030 <galois_multiply@plt>
mov    %eax,%r14d
mov    %r12d,%edi
mov    $0x1,%esi
call   1030 <galois_multiply@plt>
mov    %eax,%ebx
xor    %r14b,%bl
mov    0xc(%rsp),%edi
mov    $0x1,%esi
call   1030 <galois_multiply@plt>
mov    %eax,%ebp
mov    %r15d,%edi
mov    $0x3,%esi
call   1030 <galois_multiply@plt>
xor    %bpl,%al
xor    %bl,%al
mov    0x20(%rsp),%rcx
mov    %al,(%rcx)
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @mixcolumns(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca [4 x i8]
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%10 = getelementptr inbounds [4 x i8], [4 x i8]* %9, i64 0, i64 0
%11 = load i8*, i8** %5
%12 = load i8, i8* %11
store i8 %12, i8* %10
%13 = getelementptr inbounds i8, i8* %10, i64 1
%14 = load i8*, i8** %6
%15 = load i8, i8* %14
store i8 %15, i8* %13
%16 = getelementptr inbounds i8, i8* %13, i64 1
%17 = load i8*, i8** %7
%18 = load i8, i8* %17
store i8 %18, i8* %16
%19 = getelementptr inbounds i8, i8* %16, i64 1
%20 = load i8*, i8** %8
%21 = load i8, i8* %20
store i8 %21, i8* %19
%22 = getelementptr inbounds [4 x i8], [4 x i8]* %9, i64 0, i64 0
%23 = load i8, i8* %22
%24 = call zeroext i8 @galois_multiply(i8 zeroext %23, i32 2)
%25 = zext i8 %24 to i32
%26 = getelementptr inbounds [4 x i8], [4 x i8]* %9, i64 0, i64 3
%27 = load i8, i8* %26
%28 = call zeroext i8 @galois_multiply(i8 zeroext %27, i32 1)
%29 = zext i8 %28 to i32
%30 = xor i32 %25, %29
%31 = getelementptr inbounds [4 x i8], [4 x i8]* %9, i64 0, i64 2
%32 = load i8, i8* %31
%33 = call zeroext i8 @galois_multiply(i8 zeroext %32, i32 1)
%34 = zext i8 %33 to i32
%35 = xor i32 %30, %34
%36 = getelementptr inbounds [4 x i8], [4 x i8]* %9, i64 0, i64 1
%37 = load i8, i8* %36
%38 = call zeroext i8 @galois_multiply(i8 zeroext %37, i32 3)
%39 = zext i8 %38 to i32
%40 = xor i32 %35, %39
%41 = trunc i32 %40 to i8
%42 = load i8*, i8** %5
store i8 %41, i8* %42
%43 = getelementptr inbounds [4 x i8], [4 x i8]* %9, i64 0, i64 1
%44 = load i8, i8* %43
%45 = call zeroext i8 @galois_multiply(i8 zeroext %44, i32 2)
%46 = zext i8 %45 to i32
%47 = getelementptr inbounds [4 x i8], [4 x i8]* %9, i64 0, i64 0
%48 = load i8, i8* %47
%49 = call zeroext i8 @galois_multiply(i8 zeroext %48, i32 1)
%50 = zext i8 %49 to i32
%51 = xor i32 %46, %50
%52 = getelementptr inbounds [4 x i8], [4 x i8]* %9, i64 0, i64 3
%53 = load i8, i8* %52
%54 = call zeroext i8 @galois_multiply(i8 zeroext %53, i32 1)
%55 = zext i8 %54 to i32
%56 = xor i32 %51, %55
%57 = getelementptr inbounds [4 x i8], [4 x i8]* %9, i64 0, i64 2
%58 = load i8, i8* %57
%59 = call zeroext i8 @galois_multiply(i8 zeroext %58, i32 3)
%60 = zext i8 %59 to i32
%61 = xor i32 %56, %60
%62 = trunc i32 %61 to i8
%63 = load i8*, i8** %6
store i8 %62, i8* %63
%64 = getelementptr inbounds [4 x i8], [4 x i8]* %9, i64 0, i64 2
%65 = load i8, i8* %64
%66 = call zeroext i8 @galois_multiply(i8 zeroext %65, i32 2)
%67 = zext i8 %66 to i32
%68 = getelementptr inbounds [4 x i8], [4 x i8]* %9, i64 0, i64 1
%69 = load i8, i8* %68
%70 = call zeroext i8 @galois_multiply(i8 zeroext %69, i32 1)
%71 = zext i8 %70 to i32
%72 = xor i32 %67, %71
%73 = getelementptr inbounds [4 x i8], [4 x i8]* %9, i64 0, i64 0
%74 = load i8, i8* %73
%75 = call zeroext i8 @galois_multiply(i8 zeroext %74, i32 1)
%76 = zext i8 %75 to i32
%77 = xor i32 %72, %76
%78 = getelementptr inbounds [4 x i8], [4 x i8]* %9, i64 0, i64 3
%79 = load i8, i8* %78
%80 = call zeroext i8 @galois_multiply(i8 zeroext %79, i32 3)
%81 = zext i8 %80 to i32
%82 = xor i32 %77, %81
%83 = trunc i32 %82 to i8
%84 = load i8*, i8** %7
store i8 %83, i8* %84
%85 = getelementptr inbounds [4 x i8], [4 x i8]* %9, i64 0, i64 3
%86 = load i8, i8* %85
%87 = call zeroext i8 @galois_multiply(i8 zeroext %86, i32 2)
%88 = zext i8 %87 to i32
%89 = getelementptr inbounds [4 x i8], [4 x i8]* %9, i64 0, i64 2
%90 = load i8, i8* %89
%91 = call zeroext i8 @galois_multiply(i8 zeroext %90, i32 1)
%92 = zext i8 %91 to i32
%93 = xor i32 %88, %92
%94 = getelementptr inbounds [4 x i8], [4 x i8]* %9, i64 0, i64 1
%95 = load i8, i8* %94
%96 = call zeroext i8 @galois_multiply(i8 zeroext %95, i32 1)
%97 = zext i8 %96 to i32
%98 = xor i32 %93, %97
%99 = getelementptr inbounds [4 x i8], [4 x i8]* %9, i64 0, i64 0
%100 = load i8, i8* %99
%101 = call zeroext i8 @galois_multiply(i8 zeroext %100, i32 3)
%102 = zext i8 %101 to i32
%103 = xor i32 %98, %102
%104 = trunc i32 %103 to i8
%105 = load i8*, i8** %8
store i8 %104, i8* %105
ret void
}

LLVM IR (-O2):
define void @mixcolumns(i8* nocapture %0, i8* nocapture %1, i8* nocapture %2, i8* nocapture %3) {
%5 = load i8, i8* %0
%6 = load i8, i8* %1
%7 = load i8, i8* %2
%8 = load i8, i8* %3
%9 = tail call zeroext i8 @galois_multiply(i8 zeroext %5, i32 2)
%10 = tail call zeroext i8 @galois_multiply(i8 zeroext %8, i32 1)
%11 = xor i8 %10, %9
%12 = tail call zeroext i8 @galois_multiply(i8 zeroext %7, i32 1)
%13 = xor i8 %11, %12
%14 = tail call zeroext i8 @galois_multiply(i8 zeroext %6, i32 3)
%15 = xor i8 %13, %14
store i8 %15, i8* %0
%16 = tail call zeroext i8 @galois_multiply(i8 zeroext %6, i32 2)
%17 = tail call zeroext i8 @galois_multiply(i8 zeroext %5, i32 1)
%18 = xor i8 %17, %16
%19 = tail call zeroext i8 @galois_multiply(i8 zeroext %8, i32 1)
%20 = xor i8 %18, %19
%21 = tail call zeroext i8 @galois_multiply(i8 zeroext %7, i32 3)
%22 = xor i8 %20, %21
store i8 %22, i8* %1
%23 = tail call zeroext i8 @galois_multiply(i8 zeroext %7, i32 2)
%24 = tail call zeroext i8 @galois_multiply(i8 zeroext %6, i32 1)
%25 = xor i8 %24, %23
%26 = tail call zeroext i8 @galois_multiply(i8 zeroext %5, i32 1)
%27 = xor i8 %25, %26
%28 = tail call zeroext i8 @galois_multiply(i8 zeroext %8, i32 3)
%29 = xor i8 %27, %28
store i8 %29, i8* %2
%30 = tail call zeroext i8 @galois_multiply(i8 zeroext %8, i32 2)
%31 = tail call zeroext i8 @galois_multiply(i8 zeroext %7, i32 1)
%32 = xor i8 %31, %30
%33 = tail call zeroext i8 @galois_multiply(i8 zeroext %6, i32 1)
%34 = xor i8 %32, %33
%35 = tail call zeroext i8 @galois_multiply(i8 zeroext %5, i32 3)
%36 = xor i8 %34, %35
store i8 %36, i8* %3
ret void
}