#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);
  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   %r12
push   %rbx
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    118d <decrypt+0x4d>
cmp    $0x3e87f,%r14d
jle    11aa <decrypt+0x6a>
cmp    $0x3e880,%r14d
je     11ea <decrypt+0xaa>
cmp    $0x3e8c0,%r14d
je     11f1 <decrypt+0xb1>
cmp    $0x3e900,%r14d
je     11d7 <decrypt+0x97>
jmp    1207 <decrypt+0xc7>
cmp    $0x1f4ff,%r14d
jg     11be <decrypt+0x7e>
cmp    $0x1f480,%r14d
je     11fd <decrypt+0xbd>
cmp    $0x1f4c0,%r14d
je     11e3 <decrypt+0xa3>
jmp    1207 <decrypt+0xc7>
cmp    $0x2eec0,%r14d
je     11e3 <decrypt+0xa3>
cmp    $0x2ef00,%r14d
je     11d7 <decrypt+0x97>
jmp    1207 <decrypt+0xc7>
cmp    $0x1f500,%r14d
je     11d7 <decrypt+0x97>
cmp    $0x2ee80,%r14d
jne    1207 <decrypt+0xc7>
mov    $0xc,%ebx
jmp    1202 <decrypt+0xc2>
mov    $0xe,%ebx
mov    $0x8,%ebp
jmp    1207 <decrypt+0xc7>
mov    $0xc,%ebx
jmp    11f6 <decrypt+0xb6>
mov    $0xe,%ebx
jmp    1202 <decrypt+0xc2>
mov    $0xe,%ebx
mov    $0x6,%ebp
jmp    1207 <decrypt+0xc7>
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     1252 <decrypt+0x112>
add    $0x1,%ebx
nopl   0x0(%rax)
lea    -0x2(%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    $0xffffffff,%ebx
cmp    $0x2,%ebx
ja     1230 <decrypt+0xf0>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r14d,%edx
xor    %ecx,%ecx
call   1030 <AddRoundKey@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
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 %28
22: ; preds = %16, %22
%23 = phi i32 [ %24, %22 ], [ %18, %16 ]
%24 = add nsw i32 %23, -1
%25 = tail call i32 @AddRoundKey_InversMixColumn(i32* %0, i32** %7, i32 %17, i32 %24)
%26 = tail call i32 @InversShiftRow_ByteSub(i32* %0, i32 %17)
%27 = icmp ugt i32 %23, 2
br i1 %27, label %22, label %28
28: ; preds = %22, %16
%29 = tail call i32 @AddRoundKey(i32* %0, i32** %7, i32 %3, i32 0)
ret i32 0
}