#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_inv_s_box(int *, int /*<<< orphan*/);
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ inv_mix_columns(int *);
int /*<<< orphan*/ inv_shift_rows(int *);
int /*<<< orphan*/ printf(char *, ...);
int *rijndael_key_schedule(int *, int);
int /*<<< orphan*/ rotate_matrix(int *, int /*<<< orphan*/);
void decrypt(uint8_t data[], uint8_t key[], int keysize) {
  uint8_t *key_schedule = rijndael_key_schedule(key, keysize);
  int schedule_loc;
  if (keysize == 128)
    schedule_loc = 40;
  else if (keysize == 192)
    schedule_loc = 48;
  else
    schedule_loc = 56;
  rotate_matrix(data, 0);
  add_round_key(data, key_schedule, schedule_loc);
  printf("After initial addroundkey\n");
  for (int x = 0; x < 4; x++) {
    printf("%08x\n", data[x]);
  }
  inv_shift_rows(data);
  printf("After initial inv_shift_rows\n");
  for (int x = 0; x < 4; x++) {
    printf("%08x\n", data[x]);
  }
  apply_inv_s_box(data, 0);
  printf("After initial inv_sub_bytes\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++) {
    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]);
    }
    inv_mix_columns(data);
    printf("After round %d inv_mix_columns\n", y);
    for (int x = 0; x < 4; x++) {
      printf("%08x\n", data[x]);
    }
    inv_shift_rows(data);
    printf("After round %d inv_shift_rows\n", y);
    for (int x = 0; x < 4; x++) {
      printf("%08x\n", data[x]);
    }
    apply_inv_s_box(data, 0);
    printf("After round %d inv_sub_bytes\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);
  rotate_matrix(data, 0);
  free(key_schedule);
}


x86 assembly (clang, -O0):
<decrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1090 <rijndael_key_schedule@plt>
mov    %rax,-0x20(%rbp)
cmpl   $0x80,-0x14(%rbp)
jne    11bc <decrypt+0x3c>
movl   $0x28,-0x24(%rbp)
jmp    11e1 <decrypt+0x61>
cmpl   $0xc0,-0x14(%rbp)
jne    11d5 <decrypt+0x55>
movl   $0x30,-0x24(%rbp)
jmp    11dc <decrypt+0x5c>
movl   $0x38,-0x24(%rbp)
jmp    11e1 <decrypt+0x61>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   10a0 <rotate_matrix@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1080 <add_round_key@plt>
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x28(%rbp)
cmpl   $0x4,-0x28(%rbp)
jge    1242 <decrypt+0xc2>
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xdee(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1211 <decrypt+0x91>
mov    -0x8(%rbp),%rdi
call   1070 <inv_shift_rows@plt>
lea    0xdcf(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x4,-0x2c(%rbp)
jge    1291 <decrypt+0x111>
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xd9f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1260 <decrypt+0xe0>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1050 <apply_inv_s_box@plt>
lea    0xd9c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x30(%rbp)
cmpl   $0x4,-0x30(%rbp)
jge    12e2 <decrypt+0x162>
mov    -0x8(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xd4e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    12b1 <decrypt+0x131>
cmpl   $0x80,-0x14(%rbp)
jne    12fb <decrypt+0x17b>
movl   $0x9,-0x34(%rbp)
jmp    1320 <decrypt+0x1a0>
cmpl   $0xc0,-0x14(%rbp)
jne    1314 <decrypt+0x194>
movl   $0xb,-0x34(%rbp)
jmp    131b <decrypt+0x19b>
movl   $0xd,-0x34(%rbp)
jmp    1320 <decrypt+0x1a0>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    14a0 <decrypt+0x320>
mov    -0x24(%rbp),%eax
sub    $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    -0x38(%rbp),%esi
lea    0xd06(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x3c(%rbp)
cmpl   $0x4,-0x3c(%rbp)
jge    1395 <decrypt+0x215>
mov    -0x8(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xc9b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1364 <decrypt+0x1e4>
mov    -0x8(%rbp),%rdi
call   1040 <inv_mix_columns@plt>
mov    -0x38(%rbp),%esi
lea    0xcd0(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x40(%rbp)
cmpl   $0x4,-0x40(%rbp)
jge    13e7 <decrypt+0x267>
mov    -0x8(%rbp),%rax
movslq -0x40(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xc49(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    13b6 <decrypt+0x236>
mov    -0x8(%rbp),%rdi
call   1070 <inv_shift_rows@plt>
mov    -0x38(%rbp),%esi
lea    0xc9e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x44(%rbp)
cmpl   $0x4,-0x44(%rbp)
jge    1439 <decrypt+0x2b9>
mov    -0x8(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xbf7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1408 <decrypt+0x288>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1050 <apply_inv_s_box@plt>
mov    -0x38(%rbp),%esi
lea    0xc69(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x48(%rbp)
cmpl   $0x4,-0x48(%rbp)
jge    148d <decrypt+0x30d>
mov    -0x8(%rbp),%rax
movslq -0x48(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xba3(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    145c <decrypt+0x2dc>
jmp    1492 <decrypt+0x312>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1327 <decrypt+0x1a7>
mov    -0x24(%rbp),%eax
sub    $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):
<decrypt>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %rdi,%rbx
mov    %rsi,%rdi
mov    %edx,%esi
call   10a0 <rijndael_key_schedule@plt>
mov    %rax,%r14
xor    %ebp,%ebp
cmp    $0xc0,%r15d
setne  %bpl
mov    %rbx,%rdi
xor    %esi,%esi
call   10b0 <rotate_matrix@plt>
cmp    $0x80,%r15d
lea    0x30(,%rbp,8),%eax
mov    $0x28,%r15d
cmovne %eax,%r15d
lea    0xe9b(%rip),%r12
lea    0xb(%rbp,%rbp,1),%eax
mov    $0x9,%r13d
cmovne %eax,%r13d
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15d,%edx
call   1090 <add_round_key@plt>
mov    %r12,%rdi
call   1040 <puts@plt>
mov    (%rbx),%esi
lea    0xdef(%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
lea    0xe5a(%rip),%r12
mov    %rbp,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
call   1080 <inv_shift_rows@plt>
mov    %r12,%rdi
call   1040 <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
lea    0xe2d(%rip),%r12
mov    %rbp,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1060 <apply_inv_s_box@plt>
mov    %r12,%rdi
call   1040 <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>
add    $0xfffffffc,%r15d
xor    %r12d,%r12d
nop
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15d,%edx
call   1090 <add_round_key@plt>
lea    0xd11(%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   1050 <inv_mix_columns@plt>
lea    0xce1(%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 <inv_shift_rows@plt>
lea    0xcb5(%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
xor    %esi,%esi
call   1060 <apply_inv_s_box@plt>
lea    0xc86(%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    $0xfffffffc,%r15d
cmp    %r12d,%r13d
jne    12e0 <decrypt+0x150>
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 = [27 x i8] c"After initial addroundkey\0A\00"
@.str.1 = [6 x i8] c"%08x\0A\00"
@.str.2 = [30 x i8] c"After initial inv_shift_rows\0A\00"
@.str.3 = [29 x i8] c"After initial inv_sub_bytes\0A\00"
@.str.4 = [28 x i8] c"After round %d addroundkey\0A\00"
@.str.5 = [32 x i8] c"After round %d inv_mix_columns\0A\00"
@.str.6 = [31 x i8] c"After round %d inv_shift_rows\0A\00"
@.str.7 = [30 x i8] c"After round %d inv_sub_bytes\0A\00"
define void @decrypt(i32* %0, i32* %1, i32 %2) {
%4 = alloca i32*
%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
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
%18 = load i32*, i32** %5
%19 = load i32, i32* %6
%20 = call i32* @rijndael_key_schedule(i32* %18, i32 %19)
store i32* %20, i32** %7
%21 = load i32, i32* %6
%22 = icmp eq i32 %21, 128
br i1 %22, label %23, label %24
23: ; preds = %3
store i32 40, i32* %8
br label %30
24: ; preds = %3
%25 = load i32, i32* %6
%26 = icmp eq i32 %25, 192
br i1 %26, label %27, label %28
27: ; preds = %24
store i32 48, i32* %8
br label %29
28: ; preds = %24
store i32 56, i32* %8
br label %29
29: ; preds = %28, %27
br label %30
30: ; preds = %29, %23
%31 = load i32*, i32** %4
%32 = call i32 @rotate_matrix(i32* %31, i32 0)
%33 = load i32*, i32** %4
%34 = load i32*, i32** %7
%35 = load i32, i32* %8
%36 = call i32 @add_round_key(i32* %33, i32* %34, i32 %35)
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %9
br label %38
38: ; preds = %48, %30
%39 = load i32, i32* %9
%40 = icmp slt i32 %39, 4
br i1 %40, label %41, label %51
41: ; preds = %38
%42 = load i32*, i32** %4
%43 = load i32, i32* %9
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i32, i32* %42, i64 %44
%46 = load i32, i32* %45
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %46)
br label %48
48: ; preds = %41
%49 = load i32, i32* %9
%50 = add nsw i32 %49, 1
store i32 %50, i32* %9
br label %38
51: ; preds = %38
%52 = load i32*, i32** %4
%53 = call i32 @inv_shift_rows(i32* %52)
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %10
br label %55
55: ; preds = %65, %51
%56 = load i32, i32* %10
%57 = icmp slt i32 %56, 4
br i1 %57, label %58, label %68
58: ; preds = %55
%59 = load i32*, i32** %4
%60 = load i32, i32* %10
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i32, i32* %59, i64 %61
%63 = load i32, i32* %62
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %63)
br label %65
65: ; preds = %58
%66 = load i32, i32* %10
%67 = add nsw i32 %66, 1
store i32 %67, i32* %10
br label %55
68: ; preds = %55
%69 = load i32*, i32** %4
%70 = call i32 @apply_inv_s_box(i32* %69, i32 0)
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %11
br label %72
72: ; preds = %82, %68
%73 = load i32, i32* %11
%74 = icmp slt i32 %73, 4
br i1 %74, label %75, label %85
75: ; preds = %72
%76 = load i32*, i32** %4
%77 = load i32, i32* %11
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds i32, i32* %76, i64 %78
%80 = load i32, i32* %79
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %80)
br label %82
82: ; preds = %75
%83 = load i32, i32* %11
%84 = add nsw i32 %83, 1
store i32 %84, i32* %11
br label %72
85: ; preds = %72
%86 = load i32, i32* %6
%87 = icmp eq i32 %86, 128
br i1 %87, label %88, label %89
88: ; preds = %85
store i32 9, i32* %12
br label %95
89: ; preds = %85
%90 = load i32, i32* %6
%91 = icmp eq i32 %90, 192
br i1 %91, label %92, label %93
92: ; preds = %89
store i32 11, i32* %12
br label %94
93: ; preds = %89
store i32 13, i32* %12
br label %94
94: ; preds = %93, %92
br label %95
95: ; preds = %94, %88
store i32 0, i32* %13
br label %96
96: ; preds = %177, %95
%97 = load i32, i32* %13
%98 = load i32, i32* %12
%99 = icmp slt i32 %97, %98
br i1 %99, label %100, label %180
100: ; preds = %96
%101 = load i32, i32* %8
%102 = sub nsw i32 %101, 4
store i32 %102, i32* %8
%103 = load i32*, i32** %4
%104 = load i32*, i32** %7
%105 = load i32, i32* %8
%106 = call i32 @add_round_key(i32* %103, i32* %104, i32 %105)
%107 = load i32, i32* %13
%108 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i32 %107)
store i32 0, i32* %14
br label %109
109: ; preds = %119, %100
%110 = load i32, i32* %14
%111 = icmp slt i32 %110, 4
br i1 %111, label %112, label %122
112: ; preds = %109
%113 = load i32*, i32** %4
%114 = load i32, i32* %14
%115 = sext i32 %114 to i64
%116 = getelementptr inbounds i32, i32* %113, i64 %115
%117 = load i32, i32* %116
%118 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %117)
br label %119
119: ; preds = %112
%120 = load i32, i32* %14
%121 = add nsw i32 %120, 1
store i32 %121, i32* %14
br label %109
122: ; preds = %109
%123 = load i32*, i32** %4
%124 = call i32 @inv_mix_columns(i32* %123)
%125 = load i32, i32* %13
%126 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i32 %125)
store i32 0, i32* %15
br label %127
127: ; preds = %137, %122
%128 = load i32, i32* %15
%129 = icmp slt i32 %128, 4
br i1 %129, label %130, label %140
130: ; preds = %127
%131 = load i32*, i32** %4
%132 = load i32, i32* %15
%133 = sext i32 %132 to i64
%134 = getelementptr inbounds i32, i32* %131, i64 %133
%135 = load i32, i32* %134
%136 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %135)
br label %137
137: ; preds = %130
%138 = load i32, i32* %15
%139 = add nsw i32 %138, 1
store i32 %139, i32* %15
br label %127
140: ; preds = %127
%141 = load i32*, i32** %4
%142 = call i32 @inv_shift_rows(i32* %141)
%143 = load i32, i32* %13
%144 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i32 %143)
store i32 0, i32* %16
br label %145
145: ; preds = %155, %140
%146 = load i32, i32* %16
%147 = icmp slt i32 %146, 4
br i1 %147, label %148, label %158
148: ; preds = %145
%149 = load i32*, i32** %4
%150 = load i32, i32* %16
%151 = sext i32 %150 to i64
%152 = getelementptr inbounds i32, i32* %149, i64 %151
%153 = load i32, i32* %152
%154 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %153)
br label %155
155: ; preds = %148
%156 = load i32, i32* %16
%157 = add nsw i32 %156, 1
store i32 %157, i32* %16
br label %145
158: ; preds = %145
%159 = load i32*, i32** %4
%160 = call i32 @apply_inv_s_box(i32* %159, i32 0)
%161 = load i32, i32* %13
%162 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0), i32 %161)
store i32 0, i32* %17
br label %163
163: ; preds = %173, %158
%164 = load i32, i32* %17
%165 = icmp slt i32 %164, 4
br i1 %165, label %166, label %176
166: ; preds = %163
%167 = load i32*, i32** %4
%168 = load i32, i32* %17
%169 = sext i32 %168 to i64
%170 = getelementptr inbounds i32, i32* %167, i64 %169
%171 = load i32, i32* %170
%172 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %171)
br label %173
173: ; preds = %166
%174 = load i32, i32* %17
%175 = add nsw i32 %174, 1
store i32 %175, i32* %17
br label %163
176: ; preds = %163
br label %177
177: ; preds = %176
%178 = load i32, i32* %13
%179 = add nsw i32 %178, 1
store i32 %179, i32* %13
br label %96
180: ; preds = %96
%181 = load i32, i32* %8
%182 = sub nsw i32 %181, 4
store i32 %182, i32* %8
%183 = load i32*, i32** %4
%184 = load i32*, i32** %7
%185 = load i32, i32* %8
%186 = call i32 @add_round_key(i32* %183, i32* %184, i32 %185)
%187 = load i32*, i32** %4
%188 = call i32 @rotate_matrix(i32* %187, i32 0)
%189 = load i32*, i32** %7
%190 = call i32 @free(i32* %189)
ret void
}

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