#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 /*<<< orphan*/ uint8_t;

/* Variables and functions */
size_t UINT32_MAX;
size_t UINT8_MAX;
int __Catena(int /*<<< orphan*/ const *, size_t, void const *, size_t,
             int /*<<< orphan*/ const *, int /*<<< orphan*/, unsigned int,
             unsigned int, unsigned int, size_t, int /*<<< orphan*/,
             int /*<<< orphan*/, void *);
int PHS(void *out, size_t outlen, const void *in, size_t inlen,
        const void *salt, size_t saltlen, unsigned int t_cost,
        unsigned int m_cost) {
  if ((outlen > UINT8_MAX) || (inlen > UINT32_MAX) || (saltlen > UINT32_MAX) ||
      (t_cost > UINT8_MAX) || (m_cost > UINT8_MAX)) {
    return 1;
  }
  return __Catena((const uint8_t *)in, inlen, salt, saltlen,
                  (const uint8_t *)"", 0, t_cost, m_cost, m_cost, outlen, 0, 0,
                  out);
}


x86 assembly (clang, -O0):
<PHS>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
sub    $0x70,%rsp
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x20(%rbp)
mov    %rsi,-0x28(%rbp)
mov    %rdx,-0x30(%rbp)
mov    %rcx,-0x38(%rbp)
mov    %r8,-0x40(%rbp)
mov    %r9,-0x48(%rbp)
mov    -0x28(%rbp),%rax
mov    0x2e94(%rip),%rcx
cmp    (%rcx),%rax
ja     119b <PHS+0x8b>
mov    -0x38(%rbp),%rax
mov    0x2ea0(%rip),%rcx
cmp    (%rcx),%rax
ja     119b <PHS+0x8b>
mov    -0x48(%rbp),%rax
mov    0x2e8c(%rip),%rcx
cmp    (%rcx),%rax
ja     119b <PHS+0x8b>
mov    0x10(%rbp),%eax
mov    0x2e59(%rip),%rcx
cmp    (%rcx),%rax
ja     119b <PHS+0x8b>
mov    0x18(%rbp),%eax
mov    0x2e46(%rip),%rcx
cmp    (%rcx),%rax
jbe    11a7 <PHS+0x97>
movl   $0x1,-0x14(%rbp)
jmp    1203 <PHS+0xf3>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x40(%rbp),%rdx
mov    -0x48(%rbp),%rcx
mov    0x10(%rbp),%r14d
mov    0x18(%rbp),%ebx
mov    0x18(%rbp),%r11d
mov    -0x28(%rbp),%r10
mov    -0x20(%rbp),%rax
lea    0xe2f(%rip),%r8
xor    %r9d,%r9d
mov    %r14d,(%rsp)
mov    %ebx,0x8(%rsp)
mov    %r11d,0x10(%rsp)
mov    %r10,0x18(%rsp)
movl   $0x0,0x20(%rsp)
movl   $0x0,0x28(%rsp)
mov    %rax,0x30(%rsp)
call   1030 <__Catena@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

x86 assembly (clang, -O2):
<PHS>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rax
mov    0x2eba(%rip),%rsi
mov    (%rsi),%rsi
cmp    %rax,%rsi
jb     1188 <PHS+0x78>
mov    %rdi,%r10
mov    0x2ec8(%rip),%rdi
mov    (%rdi),%rdi
cmp    %rcx,%rdi
jb     1188 <PHS+0x78>
cmp    %r9,%rdi
jb     1188 <PHS+0x78>
mov    0x20(%rsp),%r14d
mov    %r14d,%edi
cmp    %rdi,%rsi
jb     1188 <PHS+0x78>
mov    0x28(%rsp),%ebx
mov    %ebx,%edi
cmp    %rdi,%rsi
jb     1188 <PHS+0x78>
sub    $0x8,%rsp
lea    0xea0(%rip),%r11
mov    %rdx,%rdi
mov    %rcx,%rsi
mov    %r8,%rdx
mov    %r9,%rcx
mov    %r11,%r8
xor    %r9d,%r9d
push   %r10
push   $0x0
push   $0x0
push   %rax
push   %rbx
push   %rbx
push   %r14
call   1030 <__Catena@plt>
add    $0x48,%rsp
jmp    1191 <PHS+0x81>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@UINT8_MAX = global i64 0
@UINT32_MAX = global i64 0
@.str = [1 x i8] zeroinitializer
define i32 @PHS(i8* %0, i64 %1, i8* %2, i64 %3, i8* %4, i64 %5, i32 %6, i32 %7) {
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i8*
%13 = alloca i64
%14 = alloca i8*
%15 = alloca i64
%16 = alloca i32
%17 = alloca i32
store i8* %0, i8** %10
store i64 %1, i64* %11
store i8* %2, i8** %12
store i64 %3, i64* %13
store i8* %4, i8** %14
store i64 %5, i64* %15
store i32 %6, i32* %16
store i32 %7, i32* %17
%18 = load i64, i64* %11
%19 = load i64, i64* @UINT8_MAX
%20 = icmp ugt i64 %18, %19
br i1 %20, label %39, label %21
21: ; preds = %8
%22 = load i64, i64* %13
%23 = load i64, i64* @UINT32_MAX
%24 = icmp ugt i64 %22, %23
br i1 %24, label %39, label %25
25: ; preds = %21
%26 = load i64, i64* %15
%27 = load i64, i64* @UINT32_MAX
%28 = icmp ugt i64 %26, %27
br i1 %28, label %39, label %29
29: ; preds = %25
%30 = load i32, i32* %16
%31 = zext i32 %30 to i64
%32 = load i64, i64* @UINT8_MAX
%33 = icmp ugt i64 %31, %32
br i1 %33, label %39, label %34
34: ; preds = %29
%35 = load i32, i32* %17
%36 = zext i32 %35 to i64
%37 = load i64, i64* @UINT8_MAX
%38 = icmp ugt i64 %36, %37
br i1 %38, label %39, label %40
39: ; preds = %34, %29, %25, %21, %8
store i32 1, i32* %9
br label %52
40: ; preds = %34
%41 = load i8*, i8** %12
%42 = bitcast i8* %41 to i32*
%43 = load i64, i64* %13
%44 = load i8*, i8** %14
%45 = load i64, i64* %15
%46 = load i32, i32* %16
%47 = load i32, i32* %17
%48 = load i32, i32* %17
%49 = load i64, i64* %11
%50 = load i8*, i8** %10
%51 = call i32 @__Catena(i32* %42, i64 %43, i8* %44, i64 %45, i32* bitcast ([1 x i8]* @.str to i32*), i32 0, i32 %46, i32 %47, i32 %48, i64 %49, i32 0, i32 0, i8* %50)
store i32 %51, i32* %9
br label %52
52: ; preds = %40, %39
%53 = load i32, i32* %9
ret i32 %53
}

LLVM IR (-O2):
@UINT8_MAX = global i64 0
@UINT32_MAX = global i64 0
@.str = [1 x i8] zeroinitializer
define i32 @PHS(i8* %0, i64 %1, i8* %2, i64 %3, i8* %4, i64 %5, i32 %6, i32 %7) {
%9 = load i64, i64* @UINT8_MAX
%10 = icmp ult i64 %9, %1
br i1 %10, label %25, label %11
11: ; preds = %8
%12 = load i64, i64* @UINT32_MAX
%13 = icmp ult i64 %12, %3
%14 = icmp ult i64 %12, %5
%15 = or i1 %13, %14
%16 = zext i32 %6 to i64
%17 = icmp ult i64 %9, %16
%18 = select i1 %15, i1 true, i1 %17
%19 = zext i32 %7 to i64
%20 = icmp ult i64 %9, %19
%21 = select i1 %18, i1 true, i1 %20
br i1 %21, label %25, label %22
22: ; preds = %11
%23 = bitcast i8* %2 to i32*
%24 = tail call i32 @__Catena(i32* %23, i64 %3, i8* %4, i64 %5, i32* bitcast ([1 x i8]* @.str to i32*), i32 0, i32 %6, i32 %7, i32 %7, i64 %1, i32 0, i32 0, i8* %0)
br label %25
25: ; preds = %8, %11, %22
%26 = phi i32 [ %24, %22 ], [ 1, %11 ], [ 1, %8 ]
ret i32 %26
}