#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*/ halt(char *, int /*<<< orphan*/ *);
int s_len(char *);
int /*<<< orphan*/ s_let(char *, char *);
char *prcheck(char *prototype, char *pattern) {
  char buf[21];
  int i, l, k;
  i = l = s_len(prototype) - 1;
  s_let(prototype, buf);
  for (; !(i < 0); i--) {
    if ((!(pattern[i] > '\0')) || ((k = pattern[i] - 1) > l))
      halt("Invalid re-ordering set.", NULL);
    prototype[k] = buf[i];
  }
  return (prototype);
}


x86 assembly (clang, -O0):
<prcheck>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <s_len@plt>
sub    $0x1,%eax
mov    %eax,-0x38(%rbp)
mov    %eax,-0x34(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1040 <s_let@plt>
cmpl   $0x0,-0x34(%rbp)
setl   %al
xor    $0xff,%al
test   $0x1,%al
jne    1175 <prcheck+0x45>
jmp    11d6 <prcheck+0xa6>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jle    11a5 <prcheck+0x75>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
sub    $0x1,%eax
mov    %eax,-0x3c(%rbp)
cmp    -0x38(%rbp),%eax
jle    11b5 <prcheck+0x85>
lea    0xe54(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <halt@plt>
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,1),%dl
mov    -0x8(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x34(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x34(%rbp)
jmp    115f <prcheck+0x2f>
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prcheck>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%r13
call   1030 <s_len@plt>
mov    %eax,%r12d
mov    %rsp,%rsi
mov    %r13,%rdi
call   1040 <s_let@plt>
test   %r12d,%r12d
jle    11ac <prcheck+0x7c>
mov    %r12d,%ebp
add    $0x1,%rbp
jmp    1195 <prcheck+0x65>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xe89(%rip),%rdi
xor    %esi,%esi
call   1050 <halt@plt>
movzbl (%rsp,%r15,1),%eax
movslq %ebx,%rcx
mov    %al,0x0(%r13,%rcx,1)
add    $0xffffffffffffffff,%rbp
cmp    $0x1,%rbp
jbe    11ac <prcheck+0x7c>
lea    -0x2(%rbp),%r15d
movzbl (%r14,%r15,1),%eax
test   %al,%al
jle    1170 <prcheck+0x40>
lea    -0x1(%rax),%ebx
cmp    %eax,%r12d
jl     1170 <prcheck+0x40>
jmp    117e <prcheck+0x4e>
mov    %r13,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"Invalid re-ordering set.\00"
define i8* @prcheck(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [21 x i8]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%9 = load i8*, i8** %3
%10 = call i32 @s_len(i8* %9)
%11 = sub nsw i32 %10, 1
store i32 %11, i32* %7
store i32 %11, i32* %6
%12 = load i8*, i8** %3
%13 = getelementptr inbounds [21 x i8], [21 x i8]* %5, i64 0, i64 0
%14 = call i32 @s_let(i8* %12, i8* %13)
br label %15
15: ; preds = %48, %2
%16 = load i32, i32* %6
%17 = icmp slt i32 %16, 0
%18 = xor i1 %17, true
br i1 %18, label %19, label %51
19: ; preds = %15
%20 = load i8*, i8** %4
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp sgt i32 %25, 0
br i1 %26, label %27, label %37
27: ; preds = %19
%28 = load i8*, i8** %4
%29 = load i32, i32* %6
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = sub nsw i32 %33, 1
store i32 %34, i32* %8
%35 = load i32, i32* %7
%36 = icmp sgt i32 %34, %35
br i1 %36, label %37, label %39
37: ; preds = %27, %19
%38 = call i32 @halt(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32* null)
br label %39
39: ; preds = %37, %27
%40 = load i32, i32* %6
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [21 x i8], [21 x i8]* %5, i64 0, i64 %41
%43 = load i8, i8* %42
%44 = load i8*, i8** %3
%45 = load i32, i32* %8
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %44, i64 %46
store i8 %43, i8* %47
br label %48
48: ; preds = %39
%49 = load i32, i32* %6
%50 = add nsw i32 %49, -1
store i32 %50, i32* %6
br label %15
51: ; preds = %15
%52 = load i8*, i8** %3
ret i8* %52
}

LLVM IR (-O2):
@.str = [25 x i8] c"Invalid re-ordering set.\00"
define i8* @prcheck(i8* returned %0, i8* nocapture %1) {
%3 = alloca [21 x i8]
%4 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @s_len(i8* %0)
%6 = call i32 @s_let(i8* %0, i8* %4)
%7 = icmp sgt i32 %5, 0
br i1 %7, label %8, label %32
8: ; preds = %2
%9 = zext i32 %5 to i64
br label %10
10: ; preds = %8, %25
%11 = phi i64 [ %9, %8 ], [ %13, %25 ]
%12 = phi i32 [ undef, %8 ], [ %26, %25 ]
%13 = add nsw i64 %11, -1
%14 = and i64 %13, 4294967295
%15 = getelementptr inbounds i8, i8* %1, i64 %14
%16 = load i8, i8* %15
%17 = icmp sgt i8 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %10
%19 = zext i8 %16 to i32
%20 = add nsw i32 %19, -1
%21 = icmp slt i32 %5, %19
br i1 %21, label %22, label %25
22: ; preds = %18, %10
%23 = phi i32 [ %20, %18 ], [ %12, %10 ]
%24 = call i32 @halt(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32* null)
br label %25
25: ; preds = %22, %18
%26 = phi i32 [ %23, %22 ], [ %20, %18 ]
%27 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 %14
%28 = load i8, i8* %27
%29 = sext i32 %26 to i64
%30 = getelementptr inbounds i8, i8* %0, i64 %29
store i8 %28, i8* %30
%31 = icmp ugt i64 %11, 1
br i1 %31, label %10, label %32
32: ; preds = %25, %2
ret i8* %0
}