#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*/ AddRoundKey(int *, int **, int, int);
int /*<<< orphan*/ AddRoundKey_InversMixColumn(int *, int **, int, int);
int /*<<< orphan*/ InversShiftRow_ByteSub(int *, int);
int /*<<< orphan*/ KeySchedule(int, int *, int **);
int decrypt(int statemt[32], int key[32], int word[4][120], int type, int nb,
            int round) {
  int i;
  KeySchedule(type, key, word);
  switch (type) {
  case 128128:
    round = 10;
    nb = 4;
    break;
  case 128192:
  case 192192:
    round = 12;
    nb = 6;
    break;
  case 192128:
    round = 12;
    nb = 4;
    break;
  case 128256:
  case 192256:
    round = 14;
    nb = 8;
    break;
  case 256128:
    round = 14;
    nb = 4;
    break;
  case 256192:
    round = 14;
    nb = 6;
    break;
  case 256256:
    round = 14;
    nb = 8;
    break;
  }
  AddRoundKey(statemt, word, type, round);
  InversShiftRow_ByteSub(statemt, nb);
#pragma unroll
  for (i = round - 1; i >= 1; --i) {
    AddRoundKey_InversMixColumn(statemt, word, nb, i);
    InversShiftRow_ByteSub(statemt, nb);
  }
  AddRoundKey(statemt, word, type, 0);
  return 0;
}


x86 assembly (clang, -O0):
<decrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1060 <KeySchedule@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
sub    $0x1f480,%eax
je     121d <decrypt+0xdd>
jmp    1185 <decrypt+0x45>
mov    -0x2c(%rbp),%eax
sub    $0x1f4c0,%eax
je     1230 <decrypt+0xf0>
jmp    1198 <decrypt+0x58>
mov    -0x2c(%rbp),%eax
sub    $0x1f500,%eax
je     1256 <decrypt+0x116>
jmp    11ab <decrypt+0x6b>
mov    -0x2c(%rbp),%eax
sub    $0x2ee80,%eax
je     1243 <decrypt+0x103>
jmp    11be <decrypt+0x7e>
mov    -0x2c(%rbp),%eax
sub    $0x2eec0,%eax
je     1230 <decrypt+0xf0>
jmp    11d1 <decrypt+0x91>
mov    -0x2c(%rbp),%eax
sub    $0x2ef00,%eax
je     1256 <decrypt+0x116>
jmp    11e4 <decrypt+0xa4>
mov    -0x2c(%rbp),%eax
sub    $0x3e880,%eax
je     1269 <decrypt+0x129>
jmp    11f7 <decrypt+0xb7>
mov    -0x2c(%rbp),%eax
sub    $0x3e8c0,%eax
je     127c <decrypt+0x13c>
jmp    120a <decrypt+0xca>
mov    -0x2c(%rbp),%eax
sub    $0x3e900,%eax
je     128f <decrypt+0x14f>
jmp    129d <decrypt+0x15d>
movl   $0xa,-0x24(%rbp)
movl   $0x4,-0x20(%rbp)
jmp    129d <decrypt+0x15d>
movl   $0xc,-0x24(%rbp)
movl   $0x6,-0x20(%rbp)
jmp    129d <decrypt+0x15d>
movl   $0xc,-0x24(%rbp)
movl   $0x4,-0x20(%rbp)
jmp    129d <decrypt+0x15d>
movl   $0xe,-0x24(%rbp)
movl   $0x8,-0x20(%rbp)
jmp    129d <decrypt+0x15d>
movl   $0xe,-0x24(%rbp)
movl   $0x4,-0x20(%rbp)
jmp    129d <decrypt+0x15d>
movl   $0xe,-0x24(%rbp)
movl   $0x6,-0x20(%rbp)
jmp    129d <decrypt+0x15d>
movl   $0xe,-0x24(%rbp)
movl   $0x8,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x24(%rbp),%ecx
call   1030 <AddRoundKey@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   1040 <InversShiftRow_ByteSub@plt>
mov    -0x24(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x1,-0x28(%rbp)
jl     12fc <decrypt+0x1bc>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%edx
mov    -0x28(%rbp),%ecx
call   1050 <AddRoundKey_InversMixColumn@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   1040 <InversShiftRow_ByteSub@plt>
mov    -0x28(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x28(%rbp)
jmp    12c5 <decrypt+0x185>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
xor    %ecx,%ecx
call   1030 <AddRoundKey@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decrypt>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%ebx
mov    %r8d,%ebp
mov    %ecx,%r14d
mov    %rdx,%r15
mov    %rdi,%r12
mov    %ecx,%edi
call   1060 <KeySchedule@plt>
cmp    $0x2eebf,%r14d
jle    1190 <decrypt+0x50>
cmp    $0x3e87f,%r14d
jle    11ad <decrypt+0x6d>
cmp    $0x3e880,%r14d
je     11ed <decrypt+0xad>
cmp    $0x3e8c0,%r14d
je     11f4 <decrypt+0xb4>
cmp    $0x3e900,%r14d
je     11da <decrypt+0x9a>
jmp    120a <decrypt+0xca>
cmp    $0x1f4ff,%r14d
jg     11c1 <decrypt+0x81>
cmp    $0x1f480,%r14d
je     1200 <decrypt+0xc0>
cmp    $0x1f4c0,%r14d
je     11e6 <decrypt+0xa6>
jmp    120a <decrypt+0xca>
cmp    $0x2eec0,%r14d
je     11e6 <decrypt+0xa6>
cmp    $0x2ef00,%r14d
je     11da <decrypt+0x9a>
jmp    120a <decrypt+0xca>
cmp    $0x1f500,%r14d
je     11da <decrypt+0x9a>
cmp    $0x2ee80,%r14d
jne    120a <decrypt+0xca>
mov    $0xc,%ebx
jmp    1205 <decrypt+0xc5>
mov    $0xe,%ebx
mov    $0x8,%ebp
jmp    120a <decrypt+0xca>
mov    $0xc,%ebx
jmp    11f9 <decrypt+0xb9>
mov    $0xe,%ebx
jmp    1205 <decrypt+0xc5>
mov    $0xe,%ebx
mov    $0x6,%ebp
jmp    120a <decrypt+0xca>
mov    $0xa,%ebx
mov    $0x4,%ebp
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r14d,%edx
mov    %ebx,%ecx
call   1030 <AddRoundKey@plt>
mov    %r12,%rdi
mov    %ebp,%esi
call   1040 <InversShiftRow_ByteSub@plt>
cmp    $0x2,%ebx
jl     134c <decrypt+0x20c>
lea    -0x1(%rbx),%r13d
lea    -0x2(%rbx),%eax
mov    %eax,0x4(%rsp)
and    $0x7,%r13d
je     1262 <decrypt+0x122>
xchg   %ax,%ax
add    $0xffffffff,%ebx
mov    %r12,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
mov    %ebx,%ecx
call   1050 <AddRoundKey_InversMixColumn@plt>
mov    %r12,%rdi
mov    %ebp,%esi
call   1040 <InversShiftRow_ByteSub@plt>
add    $0xffffffff,%r13d
jne    1240 <decrypt+0x100>
cmpl   $0x7,0x4(%rsp)
jb     134c <decrypt+0x20c>
add    $0x8,%ebx
lea    -0x9(%rbx),%ecx
mov    %r12,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1050 <AddRoundKey_InversMixColumn@plt>
mov    %r12,%rdi
mov    %ebp,%esi
call   1040 <InversShiftRow_ByteSub@plt>
lea    -0xa(%rbx),%ecx
mov    %r12,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1050 <AddRoundKey_InversMixColumn@plt>
mov    %r12,%rdi
mov    %ebp,%esi
call   1040 <InversShiftRow_ByteSub@plt>
lea    -0xb(%rbx),%ecx
mov    %r12,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1050 <AddRoundKey_InversMixColumn@plt>
mov    %r12,%rdi
mov    %ebp,%esi
call   1040 <InversShiftRow_ByteSub@plt>
lea    -0xc(%rbx),%ecx
mov    %r12,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1050 <AddRoundKey_InversMixColumn@plt>
mov    %r12,%rdi
mov    %ebp,%esi
call   1040 <InversShiftRow_ByteSub@plt>
lea    -0xd(%rbx),%ecx
mov    %r12,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1050 <AddRoundKey_InversMixColumn@plt>
mov    %r12,%rdi
mov    %ebp,%esi
call   1040 <InversShiftRow_ByteSub@plt>
lea    -0xe(%rbx),%ecx
mov    %r12,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1050 <AddRoundKey_InversMixColumn@plt>
mov    %r12,%rdi
mov    %ebp,%esi
call   1040 <InversShiftRow_ByteSub@plt>
lea    -0xf(%rbx),%ecx
mov    %r12,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1050 <AddRoundKey_InversMixColumn@plt>
mov    %r12,%rdi
mov    %ebp,%esi
call   1040 <InversShiftRow_ByteSub@plt>
lea    -0x10(%rbx),%ecx
mov    %r12,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1050 <AddRoundKey_InversMixColumn@plt>
mov    %r12,%rdi
mov    %ebp,%esi
call   1040 <InversShiftRow_ByteSub@plt>
add    $0xfffffff8,%ebx
cmp    $0x9,%ebx
jg     1270 <decrypt+0x130>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r14d,%edx
xor    %ecx,%ecx
call   1030 <AddRoundKey@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @decrypt(i32* %0, i32* %1, [120 x i32]* %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca [120 x i32]*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32* %0, i32** %7
store i32* %1, i32** %8
store [120 x i32]* %2, [120 x i32]** %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i32 %5, i32* %12
%14 = load i32, i32* %10
%15 = load i32*, i32** %8
%16 = load [120 x i32]*, [120 x i32]** %9
%17 = bitcast [120 x i32]* %16 to i32**
%18 = call i32 @KeySchedule(i32 %14, i32* %15, i32** %17)
%19 = load i32, i32* %10
switch i32 %19, label %27 [
i32 128128, label %20
i32 128192, label %21
i32 192192, label %21
i32 192128, label %22
i32 128256, label %23
i32 192256, label %23
i32 256128, label %24
i32 256192, label %25
i32 256256, label %26
]
20: ; preds = %6
store i32 10, i32* %12
store i32 4, i32* %11
br label %27
21: ; preds = %6, %6
store i32 12, i32* %12
store i32 6, i32* %11
br label %27
22: ; preds = %6
store i32 12, i32* %12
store i32 4, i32* %11
br label %27
23: ; preds = %6, %6
store i32 14, i32* %12
store i32 8, i32* %11
br label %27
24: ; preds = %6
store i32 14, i32* %12
store i32 4, i32* %11
br label %27
25: ; preds = %6
store i32 14, i32* %12
store i32 6, i32* %11
br label %27
26: ; preds = %6
store i32 14, i32* %12
store i32 8, i32* %11
br label %27
27: ; preds = %6, %26, %25, %24, %23, %22, %21, %20
%28 = load i32*, i32** %7
%29 = load [120 x i32]*, [120 x i32]** %9
%30 = bitcast [120 x i32]* %29 to i32**
%31 = load i32, i32* %10
%32 = load i32, i32* %12
%33 = call i32 @AddRoundKey(i32* %28, i32** %30, i32 %31, i32 %32)
%34 = load i32*, i32** %7
%35 = load i32, i32* %11
%36 = call i32 @InversShiftRow_ByteSub(i32* %34, i32 %35)
%37 = load i32, i32* %12
%38 = sub nsw i32 %37, 1
store i32 %38, i32* %13
br label %39
39: ; preds = %52, %27
%40 = load i32, i32* %13
%41 = icmp sge i32 %40, 1
br i1 %41, label %42, label %55
42: ; preds = %39
%43 = load i32*, i32** %7
%44 = load [120 x i32]*, [120 x i32]** %9
%45 = bitcast [120 x i32]* %44 to i32**
%46 = load i32, i32* %11
%47 = load i32, i32* %13
%48 = call i32 @AddRoundKey_InversMixColumn(i32* %43, i32** %45, i32 %46, i32 %47)
%49 = load i32*, i32** %7
%50 = load i32, i32* %11
%51 = call i32 @InversShiftRow_ByteSub(i32* %49, i32 %50)
br label %52
52: ; preds = %42
%53 = load i32, i32* %13
%54 = add nsw i32 %53, -1
store i32 %54, i32* %13
br label %39
55: ; preds = %39
%56 = load i32*, i32** %7
%57 = load [120 x i32]*, [120 x i32]** %9
%58 = bitcast [120 x i32]* %57 to i32**
%59 = load i32, i32* %10
%60 = call i32 @AddRoundKey(i32* %56, i32** %58, i32 %59, i32 0)
ret i32 0
}

LLVM IR (-O2):
define i32 @decrypt(i32* %0, i32* %1, [120 x i32]* %2, i32 %3, i32 %4, i32 %5) {
%7 = bitcast [120 x i32]* %2 to i32**
%8 = tail call i32 @KeySchedule(i32 %3, i32* %1, i32** %7)
switch i32 %3, label %16 [
i32 128128, label %9
i32 128192, label %10
i32 192192, label %10
i32 192128, label %11
i32 128256, label %12
i32 192256, label %12
i32 256128, label %13
i32 256192, label %14
i32 256256, label %15
]
9: ; preds = %6
br label %16
10: ; preds = %6, %6
br label %16
11: ; preds = %6
br label %16
12: ; preds = %6, %6
br label %16
13: ; preds = %6
br label %16
14: ; preds = %6
br label %16
15: ; preds = %6
br label %16
16: ; preds = %6, %15, %14, %13, %12, %11, %10, %9
%17 = phi i32 [ %4, %6 ], [ 8, %15 ], [ 6, %14 ], [ 4, %13 ], [ 8, %12 ], [ 4, %11 ], [ 6, %10 ], [ 4, %9 ]
%18 = phi i32 [ %5, %6 ], [ 14, %15 ], [ 14, %14 ], [ 14, %13 ], [ 14, %12 ], [ 12, %11 ], [ 12, %10 ], [ 10, %9 ]
%19 = tail call i32 @AddRoundKey(i32* %0, i32** %7, i32 %3, i32 %18)
%20 = tail call i32 @InversShiftRow_ByteSub(i32* %0, i32 %17)
%21 = icmp sgt i32 %18, 1
br i1 %21, label %22, label %65
22: ; preds = %16
%23 = add nuw i32 %18, 7
%24 = add nsw i32 %18, -2
%25 = and i32 %23, 7
%26 = icmp eq i32 %25, 0
br i1 %26, label %35, label %27
27: ; preds = %22, %27
%28 = phi i32 [ %30, %27 ], [ %18, %22 ]
%29 = phi i32 [ %33, %27 ], [ 0, %22 ]
%30 = add nsw i32 %28, -1
%31 = tail call i32 @AddRoundKey_InversMixColumn(i32* %0, i32** %7, i32 %17, i32 %30)
%32 = tail call i32 @InversShiftRow_ByteSub(i32* %0, i32 %17)
%33 = add nuw nsw i32 %29, 1
%34 = icmp eq i32 %33, %25
br i1 %34, label %35, label %27
35: ; preds = %27, %22
%36 = phi i32 [ %18, %22 ], [ %30, %27 ]
%37 = icmp ult i32 %24, 7
br i1 %37, label %65, label %38
38: ; preds = %35, %38
%39 = phi i32 [ %61, %38 ], [ %36, %35 ]
%40 = add nsw i32 %39, -1
%41 = tail call i32 @AddRoundKey_InversMixColumn(i32* %0, i32** %7, i32 %17, i32 %40)
%42 = tail call i32 @InversShiftRow_ByteSub(i32* %0, i32 %17)
%43 = add nsw i32 %39, -2
%44 = tail call i32 @AddRoundKey_InversMixColumn(i32* %0, i32** %7, i32 %17, i32 %43)
%45 = tail call i32 @InversShiftRow_ByteSub(i32* %0, i32 %17)
%46 = add nsw i32 %39, -3
%47 = tail call i32 @AddRoundKey_InversMixColumn(i32* %0, i32** %7, i32 %17, i32 %46)
%48 = tail call i32 @InversShiftRow_ByteSub(i32* %0, i32 %17)
%49 = add nsw i32 %39, -4
%50 = tail call i32 @AddRoundKey_InversMixColumn(i32* %0, i32** %7, i32 %17, i32 %49)
%51 = tail call i32 @InversShiftRow_ByteSub(i32* %0, i32 %17)
%52 = add nsw i32 %39, -5
%53 = tail call i32 @AddRoundKey_InversMixColumn(i32* %0, i32** %7, i32 %17, i32 %52)
%54 = tail call i32 @InversShiftRow_ByteSub(i32* %0, i32 %17)
%55 = add nsw i32 %39, -6
%56 = tail call i32 @AddRoundKey_InversMixColumn(i32* %0, i32** %7, i32 %17, i32 %55)
%57 = tail call i32 @InversShiftRow_ByteSub(i32* %0, i32 %17)
%58 = add nsw i32 %39, -7
%59 = tail call i32 @AddRoundKey_InversMixColumn(i32* %0, i32** %7, i32 %17, i32 %58)
%60 = tail call i32 @InversShiftRow_ByteSub(i32* %0, i32 %17)
%61 = add nsw i32 %39, -8
%62 = tail call i32 @AddRoundKey_InversMixColumn(i32* %0, i32** %7, i32 %17, i32 %61)
%63 = tail call i32 @InversShiftRow_ByteSub(i32* %0, i32 %17)
%64 = icmp sgt i32 %39, 9
br i1 %64, label %38, label %65
65: ; preds = %38, %35, %16
%66 = tail call i32 @AddRoundKey(i32* %0, i32** %7, i32 %3, i32 0)
ret i32 0
}