#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*/ E(unsigned char *, int);
int /*<<< orphan*/ M(unsigned char *);
int /*<<< orphan*/ S(unsigned char *);
int /*<<< orphan*/ T(unsigned char *);
void minalpher_P(unsigned char *_msg_, unsigned char _dir) {
  int r, rn;
  unsigned char dat[32];
  do {
    int u;
    for (u = 0; u < 32; u++)
      (dat)[u] = (_msg_)[u];
  } while (0);
  r = 17;
  while (r > 0) {
    S(dat);
    T(dat);
    if (_dir == 0) {
      rn = 17 - r;
      M(dat);
      E(dat, rn);
    } else if (_dir == 1) {
      rn = r - 1;
      E(dat, rn);
      M(dat);
    }
    r--;
  }
  S(dat);
  T(dat);
  do {
    int u;
    for (u = 0; u < 32; u++)
      (_msg_)[u] = (dat)[u];
  } while (0);
}


x86 assembly (clang, -O0):
<minalpher_P>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
movl   $0x0,-0x44(%rbp)
cmpl   $0x20,-0x44(%rbp)
jge    1184 <minalpher_P+0x44>
mov    -0x8(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
movslq -0x44(%rbp),%rax
mov    %cl,-0x40(%rbp,%rax,1)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1159 <minalpher_P+0x19>
jmp    1189 <minalpher_P+0x49>
movl   $0x11,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jle    121c <minalpher_P+0xdc>
lea    -0x40(%rbp),%rdi
call   1060 <S@plt>
lea    -0x40(%rbp),%rdi
call   1030 <T@plt>
movzbl -0x9(%rbp),%eax
cmp    $0x0,%eax
jne    11de <minalpher_P+0x9e>
mov    $0x11,%eax
sub    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
lea    -0x40(%rbp),%rdi
call   1050 <M@plt>
lea    -0x40(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <E@plt>
jmp    120e <minalpher_P+0xce>
movzbl -0x9(%rbp),%eax
cmp    $0x1,%eax
jne    1209 <minalpher_P+0xc9>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <E@plt>
lea    -0x40(%rbp),%rdi
call   1050 <M@plt>
jmp    120e <minalpher_P+0xce>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    1190 <minalpher_P+0x50>
lea    -0x40(%rbp),%rdi
call   1060 <S@plt>
lea    -0x40(%rbp),%rdi
call   1030 <T@plt>
movl   $0x0,-0x48(%rbp)
cmpl   $0x20,-0x48(%rbp)
jge    1260 <minalpher_P+0x120>
movslq -0x48(%rbp),%rax
mov    -0x40(%rbp,%rax,1),%dl
mov    -0x8(%rbp),%rax
movslq -0x48(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    1235 <minalpher_P+0xf5>
jmp    1265 <minalpher_P+0x125>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<minalpher_P>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %esi,%r15d
mov    %rdi,%r14
movups (%rdi),%xmm0
movups 0x10(%rdi),%xmm1
movaps %xmm1,0x10(%rsp)
movaps %xmm0,(%rsp)
mov    $0x12,%ebp
xor    %ebx,%ebx
mov    %rsp,%r12
jmp    118e <minalpher_P+0x4e>
xchg   %ax,%ax
lea    -0x2(%rbp),%esi
mov    %r12,%rdi
call   1040 <E@plt>
mov    %r12,%rdi
call   1050 <M@plt>
add    $0xffffffff,%ebp
add    $0x1,%ebx
cmp    $0x1,%ebp
jbe    11bd <minalpher_P+0x7d>
mov    %r12,%rdi
call   1060 <S@plt>
mov    %r12,%rdi
call   1030 <T@plt>
cmp    $0x1,%r15b
je     1170 <minalpher_P+0x30>
test   %r15b,%r15b
jne    1183 <minalpher_P+0x43>
mov    %r12,%rdi
call   1050 <M@plt>
mov    %r12,%rdi
mov    %ebx,%esi
call   1040 <E@plt>
jmp    1183 <minalpher_P+0x43>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1060 <S@plt>
mov    %rbx,%rdi
call   1030 <T@plt>
movaps (%rsp),%xmm0
movaps 0x10(%rsp),%xmm1
movups %xmm0,(%r14)
movups %xmm1,0x10(%r14)
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @minalpher_P(i8* nocapture %0, i8 zeroext %1) {
%3 = alloca [32 x i8]
%4 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
br label %6
6: ; preds = %2, %18
%7 = phi i32 [ %19, %18 ], [ 17, %2 ]
%8 = call i32 @S(i8* %5)
%9 = call i32 @T(i8* %5)
switch i8 %1, label %18 [
i8 0, label %10
i8 1, label %14
]
10: ; preds = %6
%11 = sub nuw nsw i32 17, %7
%12 = call i32 @M(i8* %5)
%13 = call i32 @E(i8* %5, i32 %11)
br label %18
14: ; preds = %6
%15 = add nsw i32 %7, -1
%16 = call i32 @E(i8* %5, i32 %15)
%17 = call i32 @M(i8* %5)
br label %18
18: ; preds = %6, %14, %10
%19 = add nsw i32 %7, -1
%20 = icmp ugt i32 %7, 1
br i1 %20, label %6, label %21
21: ; preds = %18
%22 = call i32 @S(i8* %5)
%23 = call i32 @T(i8* %5)
ret void
}