#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 */
int /*<<< orphan*/ add_round_key(int *, int *, int);
int /*<<< orphan*/ apply_s_box(int *, int /*<<< orphan*/);
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ mix_columns(int *);
int /*<<< orphan*/ printf(char *, ...);
int *rijndael_key_schedule(int *, int);
int /*<<< orphan*/ rotate_matrix(int *, int /*<<< orphan*/);
int /*<<< orphan*/ shift_rows(int *);
void encrypt(uint8_t data[], uint8_t key[], int keysize, bool debug) {
  uint8_t *key_schedule = rijndael_key_schedule(key, keysize);
  int schedule_loc = 0;
  rotate_matrix(data, 0);
  add_round_key(data, key, schedule_loc);
  printf("After initial add round key\n");
  for (int x = 0; x < 4; x++) {
    printf("%08x\n", data[x]);
  }
  int rounds;
  if (keysize == 128)
    rounds = 9;
  else if (keysize == 192)
    rounds = 11;
  else
    rounds = 13;
  for (int y = 0; y < rounds; y++) {
    apply_s_box(data, 0);
    printf("After round %d subbytes\n", y);
    for (int x = 0; x < 4; x++) {
      printf("%08x\n", data[x]);
    }
    shift_rows(data);
    printf("After round %d shiftrows\n", y);
    for (int x = 0; x < 4; x++) {
      printf("%08x\n", data[x]);
    }
    mix_columns(data);
    printf("After round %d mixcolumns\n", y);
    for (int x = 0; x < 4; x++) {
      printf("%08x\n", data[x]);
    }
    schedule_loc += 4;
    add_round_key(data, key_schedule, schedule_loc);
    printf("After round %d addroundkey\n", y);
    for (int x = 0; x < 4; x++) {
      printf("%08x\n", data[x]);
    }
  }
  apply_s_box(data, 0);
  printf("After final subbytes\n");
  for (int x = 0; x < 4; x++) {
    printf("%08x\n", data[x]);
  }
  shift_rows(data);
  printf("After final shiftrows\n");
  for (int x = 0; x < 4; x++) {
    printf("%08x\n", data[x]);
  }
  schedule_loc += 4;
  add_round_key(data, key_schedule, schedule_loc);
  rotate_matrix(data, 0);
  free(key_schedule);
}


x86 assembly (clang, -O0):
<encrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1090 <rijndael_key_schedule@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   10a0 <rotate_matrix@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1080 <add_round_key@plt>
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x28(%rbp)
cmpl   $0x4,-0x28(%rbp)
jge    120e <encrypt+0x8e>
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11dd <encrypt+0x5d>
cmpl   $0x80,-0x14(%rbp)
jne    1227 <encrypt+0xa7>
movl   $0x9,-0x2c(%rbp)
jmp    124c <encrypt+0xcc>
cmpl   $0xc0,-0x14(%rbp)
jne    1240 <encrypt+0xc0>
movl   $0xb,-0x2c(%rbp)
jmp    1247 <encrypt+0xc7>
movl   $0xd,-0x2c(%rbp)
jmp    124c <encrypt+0xcc>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    13cc <encrypt+0x24c>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1050 <apply_s_box@plt>
mov    -0x30(%rbp),%esi
lea    0xdaf(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0x4,-0x34(%rbp)
jge    12b3 <encrypt+0x133>
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xd7f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1282 <encrypt+0x102>
mov    -0x8(%rbp),%rdi
call   1070 <shift_rows@plt>
mov    -0x30(%rbp),%esi
lea    0xd76(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x38(%rbp)
cmpl   $0x4,-0x38(%rbp)
jge    1305 <encrypt+0x185>
mov    -0x8(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xd2d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    12d4 <encrypt+0x154>
mov    -0x8(%rbp),%rdi
call   1040 <mix_columns@plt>
mov    -0x30(%rbp),%esi
lea    0xd3e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x3c(%rbp)
cmpl   $0x4,-0x3c(%rbp)
jge    1357 <encrypt+0x1d7>
mov    -0x8(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xcdb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1326 <encrypt+0x1a6>
mov    -0x24(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1080 <add_round_key@plt>
mov    -0x30(%rbp),%esi
lea    0xcf7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x40(%rbp)
cmpl   $0x4,-0x40(%rbp)
jge    13b9 <encrypt+0x239>
mov    -0x8(%rbp),%rax
movslq -0x40(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xc79(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1388 <encrypt+0x208>
jmp    13be <encrypt+0x23e>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1253 <encrypt+0xd3>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1050 <apply_s_box@plt>
lea    0xcaf(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x44(%rbp)
cmpl   $0x4,-0x44(%rbp)
jge    141d <encrypt+0x29d>
mov    -0x8(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xc15(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    13ec <encrypt+0x26c>
mov    -0x8(%rbp),%rdi
call   1070 <shift_rows@plt>
lea    0xc76(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x48(%rbp)
cmpl   $0x4,-0x48(%rbp)
jge    146c <encrypt+0x2ec>
mov    -0x8(%rbp),%rax
movslq -0x48(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xbc6(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    143b <encrypt+0x2bb>
mov    -0x24(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1080 <add_round_key@plt>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   10a0 <rotate_matrix@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<encrypt>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %rsi,%rbp
mov    %rdi,%rbx
mov    %rsi,%rdi
mov    %edx,%esi
call   10a0 <rijndael_key_schedule@plt>
mov    %rax,%r14
mov    %rbx,%rdi
xor    %esi,%esi
call   10b0 <rotate_matrix@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %edx,%edx
call   1090 <add_round_key@plt>
lea    0xea1(%rip),%rdi
call   1050 <puts@plt>
mov    (%rbx),%esi
lea    0xe23(%rip),%rbp
mov    %rbp,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x4(%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x8(%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0xc(%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %eax,%eax
cmp    $0xc0,%r15d
setne  %al
add    %eax,%eax
add    $0xb,%eax
cmp    $0x80,%r15d
mov    $0x9,%r13d
cmovne %eax,%r13d
mov    $0x4,%r15d
xor    %r12d,%r12d
nopl   0x0(%rax)
mov    %rbx,%rdi
xor    %esi,%esi
call   1060 <apply_s_box@plt>
lea    0xdb5(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    (%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x4(%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x8(%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0xc(%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
call   1080 <shift_rows@plt>
lea    0xd82(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    (%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x4(%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x8(%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0xc(%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
call   1040 <mix_columns@plt>
lea    0xd50(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    (%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x4(%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x8(%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0xc(%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15d,%edx
call   1090 <add_round_key@plt>
lea    0xd19(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    (%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x4(%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x8(%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0xc(%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
add    $0x1,%r12d
add    $0x4,%r15d
cmp    %r12d,%r13d
jne    1240 <encrypt+0xb0>
mov    %rbx,%rdi
xor    %esi,%esi
call   1060 <apply_s_box@plt>
lea    0xcf2(%rip),%rdi
call   1050 <puts@plt>
mov    (%rbx),%esi
lea    0xc58(%rip),%rbp
mov    %rbp,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x4(%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x8(%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0xc(%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
call   1080 <shift_rows@plt>
lea    0xcb9(%rip),%rdi
call   1050 <puts@plt>
mov    (%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x4(%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x8(%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0xc(%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15d,%edx
call   1090 <add_round_key@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   10b0 <rotate_matrix@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [29 x i8] c"After initial add round key\0A\00"
@.str.1 = [6 x i8] c"%08x\0A\00"
@.str.2 = [25 x i8] c"After round %d subbytes\0A\00"
@.str.3 = [26 x i8] c"After round %d shiftrows\0A\00"
@.str.4 = [27 x i8] c"After round %d mixcolumns\0A\00"
@.str.5 = [28 x i8] c"After round %d addroundkey\0A\00"
@.str.6 = [22 x i8] c"After final subbytes\0A\00"
@.str.7 = [23 x i8] c"After final shiftrows\0A\00"
define void @encrypt(i32* %0, i32* %1, i32 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%20 = load i32*, i32** %6
%21 = load i32, i32* %7
%22 = call i32* @rijndael_key_schedule(i32* %20, i32 %21)
store i32* %22, i32** %9
store i32 0, i32* %10
%23 = load i32*, i32** %5
%24 = call i32 @rotate_matrix(i32* %23, i32 0)
%25 = load i32*, i32** %5
%26 = load i32*, i32** %6
%27 = load i32, i32* %10
%28 = call i32 @add_round_key(i32* %25, i32* %26, i32 %27)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %11
br label %30
30: ; preds = %40, %4
%31 = load i32, i32* %11
%32 = icmp slt i32 %31, 4
br i1 %32, label %33, label %43
33: ; preds = %30
%34 = load i32*, i32** %5
%35 = load i32, i32* %11
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i32, i32* %34, i64 %36
%38 = load i32, i32* %37
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %38)
br label %40
40: ; preds = %33
%41 = load i32, i32* %11
%42 = add nsw i32 %41, 1
store i32 %42, i32* %11
br label %30
43: ; preds = %30
%44 = load i32, i32* %7
%45 = icmp eq i32 %44, 128
br i1 %45, label %46, label %47
46: ; preds = %43
store i32 9, i32* %12
br label %53
47: ; preds = %43
%48 = load i32, i32* %7
%49 = icmp eq i32 %48, 192
br i1 %49, label %50, label %51
50: ; preds = %47
store i32 11, i32* %12
br label %52
51: ; preds = %47
store i32 13, i32* %12
br label %52
52: ; preds = %51, %50
br label %53
53: ; preds = %52, %46
store i32 0, i32* %13
br label %54
54: ; preds = %135, %53
%55 = load i32, i32* %13
%56 = load i32, i32* %12
%57 = icmp slt i32 %55, %56
br i1 %57, label %58, label %138
58: ; preds = %54
%59 = load i32*, i32** %5
%60 = call i32 @apply_s_box(i32* %59, i32 0)
%61 = load i32, i32* %13
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %61)
store i32 0, i32* %14
br label %63
63: ; preds = %73, %58
%64 = load i32, i32* %14
%65 = icmp slt i32 %64, 4
br i1 %65, label %66, label %76
66: ; preds = %63
%67 = load i32*, i32** %5
%68 = load i32, i32* %14
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i32, i32* %67, i64 %69
%71 = load i32, i32* %70
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %71)
br label %73
73: ; preds = %66
%74 = load i32, i32* %14
%75 = add nsw i32 %74, 1
store i32 %75, i32* %14
br label %63
76: ; preds = %63
%77 = load i32*, i32** %5
%78 = call i32 @shift_rows(i32* %77)
%79 = load i32, i32* %13
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %79)
store i32 0, i32* %15
br label %81
81: ; preds = %91, %76
%82 = load i32, i32* %15
%83 = icmp slt i32 %82, 4
br i1 %83, label %84, label %94
84: ; preds = %81
%85 = load i32*, i32** %5
%86 = load i32, i32* %15
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds i32, i32* %85, i64 %87
%89 = load i32, i32* %88
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %89)
br label %91
91: ; preds = %84
%92 = load i32, i32* %15
%93 = add nsw i32 %92, 1
store i32 %93, i32* %15
br label %81
94: ; preds = %81
%95 = load i32*, i32** %5
%96 = call i32 @mix_columns(i32* %95)
%97 = load i32, i32* %13
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i32 %97)
store i32 0, i32* %16
br label %99
99: ; preds = %109, %94
%100 = load i32, i32* %16
%101 = icmp slt i32 %100, 4
br i1 %101, label %102, label %112
102: ; preds = %99
%103 = load i32*, i32** %5
%104 = load i32, i32* %16
%105 = sext i32 %104 to i64
%106 = getelementptr inbounds i32, i32* %103, i64 %105
%107 = load i32, i32* %106
%108 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %107)
br label %109
109: ; preds = %102
%110 = load i32, i32* %16
%111 = add nsw i32 %110, 1
store i32 %111, i32* %16
br label %99
112: ; preds = %99
%113 = load i32, i32* %10
%114 = add nsw i32 %113, 4
store i32 %114, i32* %10
%115 = load i32*, i32** %5
%116 = load i32*, i32** %9
%117 = load i32, i32* %10
%118 = call i32 @add_round_key(i32* %115, i32* %116, i32 %117)
%119 = load i32, i32* %13
%120 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i32 %119)
store i32 0, i32* %17
br label %121
121: ; preds = %131, %112
%122 = load i32, i32* %17
%123 = icmp slt i32 %122, 4
br i1 %123, label %124, label %134
124: ; preds = %121
%125 = load i32*, i32** %5
%126 = load i32, i32* %17
%127 = sext i32 %126 to i64
%128 = getelementptr inbounds i32, i32* %125, i64 %127
%129 = load i32, i32* %128
%130 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %129)
br label %131
131: ; preds = %124
%132 = load i32, i32* %17
%133 = add nsw i32 %132, 1
store i32 %133, i32* %17
br label %121
134: ; preds = %121
br label %135
135: ; preds = %134
%136 = load i32, i32* %13
%137 = add nsw i32 %136, 1
store i32 %137, i32* %13
br label %54
138: ; preds = %54
%139 = load i32*, i32** %5
%140 = call i32 @apply_s_box(i32* %139, i32 0)
%141 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %18
br label %142
142: ; preds = %152, %138
%143 = load i32, i32* %18
%144 = icmp slt i32 %143, 4
br i1 %144, label %145, label %155
145: ; preds = %142
%146 = load i32*, i32** %5
%147 = load i32, i32* %18
%148 = sext i32 %147 to i64
%149 = getelementptr inbounds i32, i32* %146, i64 %148
%150 = load i32, i32* %149
%151 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %150)
br label %152
152: ; preds = %145
%153 = load i32, i32* %18
%154 = add nsw i32 %153, 1
store i32 %154, i32* %18
br label %142
155: ; preds = %142
%156 = load i32*, i32** %5
%157 = call i32 @shift_rows(i32* %156)
%158 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* %19
br label %159
159: ; preds = %169, %155
%160 = load i32, i32* %19
%161 = icmp slt i32 %160, 4
br i1 %161, label %162, label %172
162: ; preds = %159
%163 = load i32*, i32** %5
%164 = load i32, i32* %19
%165 = sext i32 %164 to i64
%166 = getelementptr inbounds i32, i32* %163, i64 %165
%167 = load i32, i32* %166
%168 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %167)
br label %169
169: ; preds = %162
%170 = load i32, i32* %19
%171 = add nsw i32 %170, 1
store i32 %171, i32* %19
br label %159
172: ; preds = %159
%173 = load i32, i32* %10
%174 = add nsw i32 %173, 4
store i32 %174, i32* %10
%175 = load i32*, i32** %5
%176 = load i32*, i32** %9
%177 = load i32, i32* %10
%178 = call i32 @add_round_key(i32* %175, i32* %176, i32 %177)
%179 = load i32*, i32** %5
%180 = call i32 @rotate_matrix(i32* %179, i32 0)
%181 = load i32*, i32** %9
%182 = call i32 @free(i32* %181)
ret void
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c"%08x\0A\00"
@.str.2 = [25 x i8] c"After round %d subbytes\0A\00"
@.str.3 = [26 x i8] c"After round %d shiftrows\0A\00"
@.str.4 = [27 x i8] c"After round %d mixcolumns\0A\00"
@.str.5 = [28 x i8] c"After round %d addroundkey\0A\00"
@str = [28 x i8] c"After initial add round key\00"
@str.8 = [21 x i8] c"After final subbytes\00"
@str.9 = [22 x i8] c"After final shiftrows\00"
define void @encrypt(i32* %0, i32* %1, i32 %2, i32 %3) {
%5 = tail call i32* @rijndael_key_schedule(i32* %1, i32 %2)
%6 = tail call i32 @rotate_matrix(i32* %0, i32 0)
%7 = tail call i32 @add_round_key(i32* %0, i32* %1, i32 0)
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%9 = load i32, i32* %0
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = getelementptr inbounds i32, i32* %0, i64 1
%12 = load i32, i32* %11
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = getelementptr inbounds i32, i32* %0, i64 2
%15 = load i32, i32* %14
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds i32, i32* %0, i64 3
%18 = load i32, i32* %17
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = icmp eq i32 %2, 192
%21 = select i1 %20, i32 11, i32 13
%22 = icmp eq i32 %2, 128
%23 = select i1 %22, i32 9, i32 %21
br label %48
24: ; preds = %48
%25 = tail call i32 @apply_s_box(i32* %0, i32 0)
%26 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.8, i64 0, i64 0))
%27 = load i32, i32* %0
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %27)
%29 = load i32, i32* %11
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %29)
%31 = load i32, i32* %14
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %31)
%33 = load i32, i32* %17
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %33)
%35 = tail call i32 @shift_rows(i32* %0)
%36 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.9, i64 0, i64 0))
%37 = load i32, i32* %0
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %37)
%39 = load i32, i32* %11
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %39)
%41 = load i32, i32* %14
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %41)
%43 = load i32, i32* %17
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %43)
%45 = tail call i32 @add_round_key(i32* %0, i32* %5, i32 %92)
%46 = tail call i32 @rotate_matrix(i32* %0, i32 0)
%47 = tail call i32 @free(i32* %5)
ret void
48: ; preds = %4, %48
%49 = phi i32 [ 0, %4 ], [ %91, %48 ]
%50 = phi i32 [ 4, %4 ], [ %92, %48 ]
%51 = tail call i32 @apply_s_box(i32* %0, i32 0)
%52 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %49)
%53 = load i32, i32* %0
%54 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %53)
%55 = load i32, i32* %11
%56 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %55)
%57 = load i32, i32* %14
%58 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %57)
%59 = load i32, i32* %17
%60 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %59)
%61 = tail call i32 @shift_rows(i32* %0)
%62 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %49)
%63 = load i32, i32* %0
%64 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %63)
%65 = load i32, i32* %11
%66 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %65)
%67 = load i32, i32* %14
%68 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %67)
%69 = load i32, i32* %17
%70 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %69)
%71 = tail call i32 @mix_columns(i32* %0)
%72 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i32 %49)
%73 = load i32, i32* %0
%74 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %73)
%75 = load i32, i32* %11
%76 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %75)
%77 = load i32, i32* %14
%78 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %77)
%79 = load i32, i32* %17
%80 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %79)
%81 = tail call i32 @add_round_key(i32* %0, i32* %5, i32 %50)
%82 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i32 %49)
%83 = load i32, i32* %0
%84 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %83)
%85 = load i32, i32* %11
%86 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %85)
%87 = load i32, i32* %14
%88 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %87)
%89 = load i32, i32* %17
%90 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %89)
%91 = add nuw nsw i32 %49, 1
%92 = add nuw nsw i32 %50, 4
%93 = icmp eq i32 %91, %23
br i1 %93, label %24, label %48
}