#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 */
int /*<<< orphan*/ _aes_multiply(char, char);
char aes_addition(int, int /*<<< orphan*/, int /*<<< orphan*/,
                  int /*<<< orphan*/, int /*<<< orphan*/);
int aes_matrix_multiply(char a[][4], char b[][4], char c[][4]) {
  int i;
  int j;
  for (i = 0; i < 4; i++)
    for (j = 0; j < 4; j++)
      c[i][j] = aes_addition(
          4, _aes_multiply(a[i][0], b[0][j]), _aes_multiply(a[i][1], b[1][j]),
          _aes_multiply(a[i][2], b[2][j]), _aes_multiply(a[i][3], b[3][j]));
  return 0;
}


x86 assembly (clang, -O0):
<aes_matrix_multiply>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x4,-0x1c(%rbp)
jge    1230 <aes_matrix_multiply+0x110>
movl   $0x0,-0x20(%rbp)
cmpl   $0x4,-0x20(%rbp)
jge    121d <aes_matrix_multiply+0xfd>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%dl
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl %dl,%edi
movsbl (%rax,%rcx,1),%esi
call   1030 <_aes_multiply@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    0x1(%rax,%rcx,4),%dl
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl %dl,%edi
movsbl 0x4(%rax,%rcx,1),%esi
call   1030 <_aes_multiply@plt>
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    0x2(%rax,%rcx,4),%dl
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl %dl,%edi
movsbl 0x8(%rax,%rcx,1),%esi
call   1030 <_aes_multiply@plt>
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    0x3(%rax,%rcx,4),%dl
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl %dl,%edi
movsbl 0xc(%rax,%rcx,1),%esi
call   1030 <_aes_multiply@plt>
mov    -0x2c(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    -0x24(%rbp),%ecx
mov    %eax,%r8d
mov    $0x4,%edi
call   1040 <aes_addition@plt>
mov    %al,%dl
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    114c <aes_matrix_multiply+0x2c>
jmp    1222 <aes_matrix_multiply+0x102>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113b <aes_matrix_multiply+0x1b>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aes_matrix_multiply>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,0x8(%rsp)
mov    %rsi,%r15
mov    %rdi,%rbx
xor    %r14d,%r14d
nopl   0x0(%rax)
movsbl (%rbx,%r14,4),%edi
movsbl (%r15),%esi
call   1030 <_aes_multiply@plt>
mov    %eax,%r12d
movsbl 0x1(%rbx,%r14,4),%edi
movsbl 0x4(%r15),%esi
call   1030 <_aes_multiply@plt>
mov    %eax,%r13d
movsbl 0x2(%rbx,%r14,4),%edi
movsbl 0x8(%r15),%esi
call   1030 <_aes_multiply@plt>
mov    %eax,%ebp
movsbl 0x3(%rbx,%r14,4),%edi
movsbl 0xc(%r15),%esi
call   1030 <_aes_multiply@plt>
mov    $0x4,%edi
mov    %r12d,%esi
mov    %r13d,%edx
mov    %ebp,%ecx
mov    %eax,%r8d
call   1040 <aes_addition@plt>
mov    0x8(%rsp),%rcx
mov    %al,(%rcx,%r14,4)
movsbl (%rbx,%r14,4),%edi
movsbl 0x1(%r15),%esi
call   1030 <_aes_multiply@plt>
mov    %eax,%r12d
movsbl 0x1(%rbx,%r14,4),%edi
movsbl 0x5(%r15),%esi
call   1030 <_aes_multiply@plt>
mov    %eax,%r13d
movsbl 0x2(%rbx,%r14,4),%edi
movsbl 0x9(%r15),%esi
call   1030 <_aes_multiply@plt>
mov    %eax,%ebp
movsbl 0x3(%rbx,%r14,4),%edi
movsbl 0xd(%r15),%esi
call   1030 <_aes_multiply@plt>
mov    $0x4,%edi
mov    %r12d,%esi
mov    %r13d,%edx
mov    %ebp,%ecx
mov    %eax,%r8d
call   1040 <aes_addition@plt>
mov    0x8(%rsp),%rbp
mov    %al,0x1(%rbp,%r14,4)
movsbl (%rbx,%r14,4),%edi
movsbl 0x2(%r15),%esi
call   1030 <_aes_multiply@plt>
mov    %eax,0x14(%rsp)
movsbl 0x1(%rbx,%r14,4),%edi
movsbl 0x6(%r15),%esi
call   1030 <_aes_multiply@plt>
mov    %eax,%r13d
movsbl 0x2(%rbx,%r14,4),%edi
movsbl 0xa(%r15),%esi
call   1030 <_aes_multiply@plt>
mov    %eax,%r12d
movsbl 0x3(%rbx,%r14,4),%edi
movsbl 0xe(%r15),%esi
call   1030 <_aes_multiply@plt>
mov    $0x4,%edi
mov    0x14(%rsp),%esi
mov    %r13d,%edx
mov    %r12d,%ecx
mov    %eax,%r8d
call   1040 <aes_addition@plt>
mov    %al,0x2(%rbp,%r14,4)
movsbl (%rbx,%r14,4),%edi
movsbl 0x3(%r15),%esi
call   1030 <_aes_multiply@plt>
mov    %eax,%r12d
movsbl 0x1(%rbx,%r14,4),%edi
movsbl 0x7(%r15),%esi
call   1030 <_aes_multiply@plt>
mov    %eax,%r13d
movsbl 0x2(%rbx,%r14,4),%edi
movsbl 0xb(%r15),%esi
call   1030 <_aes_multiply@plt>
mov    %eax,%ebp
movsbl 0x3(%rbx,%r14,4),%edi
movsbl 0xf(%r15),%esi
call   1030 <_aes_multiply@plt>
mov    $0x4,%edi
mov    %r12d,%esi
mov    %r13d,%edx
mov    %ebp,%ecx
mov    %eax,%r8d
call   1040 <aes_addition@plt>
mov    0x8(%rsp),%rcx
mov    %al,0x3(%rcx,%r14,4)
add    $0x1,%r14
cmp    $0x4,%r14
jne    1140 <aes_matrix_multiply+0x20>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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