#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 char uint8_t;
struct timeval {
  int tv_sec;
  int /*<<< orphan*/ tv_usec;
};

/* Variables and functions */
scalar_t__ PHS(char *, size_t, char const *, size_t, char const *, size_t,
               unsigned int, unsigned int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdout;
int run_phs(uint8_t *out, size_t outlen, const uint8_t *in, size_t inlen,
            const uint8_t *salt, size_t saltlen, unsigned int t_cost,
            unsigned int m_cost) {
  struct timeval start, end;
  int in_printable = 1;
  int salt_printable = 1;
  size_t i;
  for (i = 0; i < inlen; i++)
    if (in[i] < ' ' || in[i] > '~' || in[i] == '"')
      in_printable = 0;
  for (i = 0; i < saltlen; i++)
    if (salt[i] < ' ' || salt[i] > '~' || salt[i] == '"')
      salt_printable = 0;
  printf("PHS(");
  if (in_printable)
    printf("\"%s\", ", in);
  else {
    for (i = 0; i < inlen && i < 8; i++)
      printf("%.2hhx", in[i]);
    if (inlen > 8)
      printf("...%.2hhx", in[inlen - 1]);
    printf(", ");
  }
  if (salt_printable)
    printf("\"%s\", ", salt);
  else {
    for (i = 0; i < saltlen && i < 8; i++)
      printf("%.2hhx", salt[i]);
    if (saltlen > 8)
      printf("...%.2hhx", salt[saltlen - 1]);
    printf(", ");
  }
  printf("%d, %d, %u) = ", t_cost, m_cost, (unsigned int)outlen);
  fflush(stdout);
  gettimeofday(&start, NULL);
  if (PHS(out, outlen, in, inlen, salt, saltlen, t_cost, m_cost) != 0)
    return -1;
  gettimeofday(&end, NULL);
  for (i = 0; i < outlen; i++)
    printf("%.2hhx", out[i]);
  printf(" (%ldus)\n",
         1000000 * (end.tv_sec - start.tv_sec) + end.tv_usec - start.tv_usec);
  return 0;
}


x86 assembly (clang, -O0):
<run_phs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
movl   $0x1,-0x4c(%rbp)
movl   $0x1,-0x50(%rbp)
movq   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%rax
cmp    -0x28(%rbp),%rax
jae    11e6 <run_phs+0xa6>
mov    -0x20(%rbp),%rax
mov    -0x58(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jl     11c9 <run_phs+0x89>
mov    -0x20(%rbp),%rax
mov    -0x58(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x7e,%eax
jg     11c9 <run_phs+0x89>
mov    -0x20(%rbp),%rax
mov    -0x58(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x22,%eax
jne    11d0 <run_phs+0x90>
movl   $0x0,-0x4c(%rbp)
jmp    11d5 <run_phs+0x95>
mov    -0x58(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x58(%rbp)
jmp    117c <run_phs+0x3c>
movq   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%rax
cmp    -0x38(%rbp),%rax
jae    1258 <run_phs+0x118>
mov    -0x30(%rbp),%rax
mov    -0x58(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jl     123b <run_phs+0xfb>
mov    -0x30(%rbp),%rax
mov    -0x58(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x7e,%eax
jg     123b <run_phs+0xfb>
mov    -0x30(%rbp),%rax
mov    -0x58(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x22,%eax
jne    1242 <run_phs+0x102>
movl   $0x0,-0x50(%rbp)
jmp    1247 <run_phs+0x107>
mov    -0x58(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x58(%rbp)
jmp    11ee <run_phs+0xae>
lea    0xda1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x4c(%rbp)
je     1287 <run_phs+0x147>
mov    -0x20(%rbp),%rsi
lea    0xd8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    131f <run_phs+0x1df>
movq   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%rcx
xor    %eax,%eax
cmp    -0x28(%rbp),%rcx
mov    %al,-0x59(%rbp)
jae    12ad <run_phs+0x16d>
cmpq   $0x8,-0x58(%rbp)
setb   %al
mov    %al,-0x59(%rbp)
mov    -0x59(%rbp),%al
test   $0x1,%al
jne    12bd <run_phs+0x17d>
jmp    12e8 <run_phs+0x1a8>
mov    -0x20(%rbp),%rax
mov    -0x58(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xd3f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x58(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x58(%rbp)
jmp    128f <run_phs+0x14f>
cmpq   $0x8,-0x28(%rbp)
jbe    1311 <run_phs+0x1d1>
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
sub    $0x1,%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xd02(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xcf1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x50(%rbp)
je     1340 <run_phs+0x200>
mov    -0x30(%rbp),%rsi
lea    0xcd1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    13d8 <run_phs+0x298>
movq   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%rcx
xor    %eax,%eax
cmp    -0x38(%rbp),%rcx
mov    %al,-0x5a(%rbp)
jae    1366 <run_phs+0x226>
cmpq   $0x8,-0x58(%rbp)
setb   %al
mov    %al,-0x5a(%rbp)
mov    -0x5a(%rbp),%al
test   $0x1,%al
jne    1376 <run_phs+0x236>
jmp    13a1 <run_phs+0x261>
mov    -0x30(%rbp),%rax
mov    -0x58(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xc86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x58(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x58(%rbp)
jmp    1348 <run_phs+0x208>
cmpq   $0x8,-0x38(%rbp)
jbe    13ca <run_phs+0x28a>
mov    -0x30(%rbp),%rax
mov    -0x38(%rbp),%rcx
sub    $0x1,%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xc49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xc38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x10(%rbp),%esi
mov    0x18(%rbp),%edx
mov    -0x18(%rbp),%rax
mov    %eax,%ecx
lea    0xc2b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2be7(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
lea    -0x40(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x38(%rbp),%r9
mov    0x10(%rbp),%r10d
mov    0x18(%rbp),%eax
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1050 <PHS@plt>
cmp    $0x0,%rax
je     144f <run_phs+0x30f>
movl   $0xffffffff,-0x4(%rbp)
jmp    14c4 <run_phs+0x384>
lea    -0x48(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
movq   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    149d <run_phs+0x35d>
mov    -0x10(%rbp),%rax
mov    -0x58(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xb8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x58(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x58(%rbp)
jmp    1464 <run_phs+0x324>
mov    -0x48(%rbp),%eax
sub    -0x40(%rbp),%eax
imul   $0xf4240,%eax,%esi
add    -0x44(%rbp),%esi
sub    -0x3c(%rbp),%esi
lea    0xb6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_phs>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r8,%r13
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%r15
mov    $0x1,%ebx
mov    $0x1,%ebp
test   %rcx,%rcx
je     11e2 <run_phs+0xa2>
xor    %r10d,%r10d
cmp    $0x1,%rcx
jne    117b <run_phs+0x3b>
mov    $0x1,%ebp
xor    %eax,%eax
jmp    11c8 <run_phs+0x88>
mov    %rcx,%r8
and    $0xfffffffffffffffe,%r8
mov    $0x1,%ebp
xor    %eax,%eax
nopl   0x0(%rax)
movzbl (%r14,%rax,1),%esi
movzbl 0x1(%r14,%rax,1),%edi
lea    -0x7f(%rsi),%edx
cmp    $0xa1,%dl
cmovb  %r10d,%ebp
lea    -0x7f(%rdi),%edx
cmp    $0x22,%sil
cmove  %r10d,%ebp
cmp    $0xa1,%dl
cmovb  %r10d,%ebp
cmp    $0x22,%dil
cmove  %r10d,%ebp
add    $0x2,%rax
cmp    %rax,%r8
jne    1190 <run_phs+0x50>
test   $0x1,%cl
je     11e2 <run_phs+0xa2>
mov    (%r14,%rax,1),%al
lea    -0x7f(%rax),%esi
xor    %edx,%edx
cmp    $0xa1,%sil
cmovb  %edx,%ebp
cmp    $0x22,%al
cmove  %edx,%ebp
mov    %rcx,0x18(%rsp)
test   %r9,%r9
je     1260 <run_phs+0x120>
xor    %ecx,%ecx
cmp    $0x1,%r9
jne    11fd <run_phs+0xbd>
mov    $0x1,%ebx
xor    %eax,%eax
jmp    1245 <run_phs+0x105>
mov    %r9,%r8
and    $0xfffffffffffffffe,%r8
mov    $0x1,%ebx
xor    %eax,%eax
nopl   0x0(%rax,%rax,1)
movzbl 0x0(%r13,%rax,1),%esi
movzbl 0x1(%r13,%rax,1),%edi
lea    -0x7f(%rsi),%edx
cmp    $0xa1,%dl
cmovb  %ecx,%ebx
lea    -0x7f(%rdi),%edx
cmp    $0x22,%sil
cmove  %ecx,%ebx
cmp    $0xa1,%dl
cmovb  %ecx,%ebx
cmp    $0x22,%dil
cmove  %ecx,%ebx
add    $0x2,%rax
cmp    %rax,%r8
jne    1210 <run_phs+0xd0>
test   $0x1,%r9b
je     1260 <run_phs+0x120>
mov    0x0(%r13,%rax,1),%al
lea    -0x7f(%rax),%ecx
xor    %edx,%edx
cmp    $0xa1,%cl
cmovb  %edx,%ebx
cmp    $0x22,%al
cmove  %edx,%ebx
mov    %r9,0x8(%rsp)
lea    0xd94(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
test   %ebp,%ebp
je     128d <run_phs+0x14d>
lea    0xd87(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    130f <run_phs+0x1cf>
mov    0x18(%rsp),%rax
test   %rax,%rax
je     1301 <run_phs+0x1c1>
mov    %r15,0x10(%rsp)
mov    %r12,0x30(%rsp)
add    $0xffffffffffffffff,%rax
cmp    $0x7,%rax
mov    $0x7,%ebp
cmovb  %rax,%rbp
add    $0x1,%rbp
lea    0xd52(%rip),%r15
xor    %r12d,%r12d
movsbl (%r14,%r12,1),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%r12
cmp    %r12,%rbp
jne    12c0 <run_phs+0x180>
mov    0x18(%rsp),%rax
cmp    $0x9,%rax
mov    0x30(%rsp),%r12
mov    0x10(%rsp),%r15
jb     1301 <run_phs+0x1c1>
movsbl -0x1(%rax,%r14,1),%esi
lea    0xd12(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xd01(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x8(%rsp),%rax
mov    0x70(%rsp),%ebp
test   %ebx,%ebx
je     1332 <run_phs+0x1f2>
lea    0xce2(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    13af <run_phs+0x26f>
test   %rax,%rax
je     13a1 <run_phs+0x261>
mov    %r15,0x10(%rsp)
add    $0xffffffffffffffff,%rax
cmp    $0x7,%rax
mov    $0x7,%ebp
cmovb  %rax,%rbp
add    $0x1,%rbp
lea    0xcb7(%rip),%r15
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movsbl 0x0(%r13,%rbx,1),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1360 <run_phs+0x220>
mov    0x8(%rsp),%rax
cmp    $0x9,%rax
mov    0x10(%rsp),%r15
mov    0x70(%rsp),%ebp
jb     13a1 <run_phs+0x261>
movsbl -0x1(%rax,%r13,1),%esi
lea    0xc72(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xc61(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xc60(%rip),%rdi
mov    %ebp,%esi
mov    0x78(%rsp),%ebx
mov    %ebx,%edx
mov    %r12d,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2c11(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
lea    0x28(%rsp),%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
mov    0x18(%rsp),%rcx
mov    %r13,%r8
mov    0x8(%rsp),%r9
push   %rbx
push   %rbp
call   1050 <PHS@plt>
add    $0x10,%rsp
mov    $0xffffffff,%r14d
test   %rax,%rax
jne    146c <run_phs+0x32c>
xor    %r14d,%r14d
lea    0x20(%rsp),%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
test   %r12,%r12
je     1448 <run_phs+0x308>
lea    0xbe6(%rip),%rbp
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movsbl (%r15,%rbx,1),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1430 <run_phs+0x2f0>
mov    0x20(%rsp),%eax
sub    0x28(%rsp),%eax
imul   $0xf4240,%eax,%esi
add    0x24(%rsp),%esi
sub    0x2c(%rsp),%esi
lea    0xbc0(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r14d,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
@.str = [5 x i8] c"PHS(\00"
@.str.1 = [7 x i8] c"\22%s\22, \00"
@.str.2 = [7 x i8] c"%.2hhx\00"
@.str.3 = [10 x i8] c"...%.2hhx\00"
@.str.4 = [3 x i8] c", \00"
@.str.5 = [15 x i8] c"%d, %d, %u) = \00"
@stdout = global i32 0
@.str.6 = [10 x i8] c" (%ldus)\0A\00"
define i32 @run_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
%18 = alloca %struct.timeval
%19 = alloca %struct.timeval
%20 = alloca i32
%21 = alloca i32
%22 = alloca i64
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
store i32 1, i32* %20
store i32 1, i32* %21
store i64 0, i64* %22
br label %23
23: ; preds = %50, %8
%24 = load i64, i64* %22
%25 = load i64, i64* %13
%26 = icmp ult i64 %24, %25
br i1 %26, label %27, label %53
27: ; preds = %23
%28 = load i8*, i8** %12
%29 = load i64, i64* %22
%30 = getelementptr inbounds i8, i8* %28, i64 %29
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp slt i32 %32, 32
br i1 %33, label %48, label %34
34: ; preds = %27
%35 = load i8*, i8** %12
%36 = load i64, i64* %22
%37 = getelementptr inbounds i8, i8* %35, i64 %36
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp sgt i32 %39, 126
br i1 %40, label %48, label %41
41: ; preds = %34
%42 = load i8*, i8** %12
%43 = load i64, i64* %22
%44 = getelementptr inbounds i8, i8* %42, i64 %43
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp eq i32 %46, 34
br i1 %47, label %48, label %49
48: ; preds = %41, %34, %27
store i32 0, i32* %20
br label %49
49: ; preds = %48, %41
br label %50
50: ; preds = %49
%51 = load i64, i64* %22
%52 = add i64 %51, 1
store i64 %52, i64* %22
br label %23
53: ; preds = %23
store i64 0, i64* %22
br label %54
54: ; preds = %81, %53
%55 = load i64, i64* %22
%56 = load i64, i64* %15
%57 = icmp ult i64 %55, %56
br i1 %57, label %58, label %84
58: ; preds = %54
%59 = load i8*, i8** %14
%60 = load i64, i64* %22
%61 = getelementptr inbounds i8, i8* %59, i64 %60
%62 = load i8, i8* %61
%63 = sext i8 %62 to i32
%64 = icmp slt i32 %63, 32
br i1 %64, label %79, label %65
65: ; preds = %58
%66 = load i8*, i8** %14
%67 = load i64, i64* %22
%68 = getelementptr inbounds i8, i8* %66, i64 %67
%69 = load i8, i8* %68
%70 = sext i8 %69 to i32
%71 = icmp sgt i32 %70, 126
br i1 %71, label %79, label %72
72: ; preds = %65
%73 = load i8*, i8** %14
%74 = load i64, i64* %22
%75 = getelementptr inbounds i8, i8* %73, i64 %74
%76 = load i8, i8* %75
%77 = sext i8 %76 to i32
%78 = icmp eq i32 %77, 34
br i1 %78, label %79, label %80
79: ; preds = %72, %65, %58
store i32 0, i32* %21
br label %80
80: ; preds = %79, %72
br label %81
81: ; preds = %80
%82 = load i64, i64* %22
%83 = add i64 %82, 1
store i64 %83, i64* %22
br label %54
84: ; preds = %54
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%86 = load i32, i32* %20
%87 = icmp ne i32 %86, 0
br i1 %87, label %88, label %91
88: ; preds = %84
%89 = load i8*, i8** %12
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %89)
br label %124
91: ; preds = %84
store i64 0, i64* %22
br label %92
92: ; preds = %108, %91
%93 = load i64, i64* %22
%94 = load i64, i64* %13
%95 = icmp ult i64 %93, %94
br i1 %95, label %96, label %99
96: ; preds = %92
%97 = load i64, i64* %22
%98 = icmp ult i64 %97, 8
br label %99
99: ; preds = %96, %92
%100 = phi i1 [ false, %92 ], [ %98, %96 ]
br i1 %100, label %101, label %111
101: ; preds = %99
%102 = load i8*, i8** %12
%103 = load i64, i64* %22
%104 = getelementptr inbounds i8, i8* %102, i64 %103
%105 = load i8, i8* %104
%106 = sext i8 %105 to i32
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %106)
br label %108
108: ; preds = %101
%109 = load i64, i64* %22
%110 = add i64 %109, 1
store i64 %110, i64* %22
br label %92
111: ; preds = %99
%112 = load i64, i64* %13
%113 = icmp ugt i64 %112, 8
br i1 %113, label %114, label %122
114: ; preds = %111
%115 = load i8*, i8** %12
%116 = load i64, i64* %13
%117 = sub i64 %116, 1
%118 = getelementptr inbounds i8, i8* %115, i64 %117
%119 = load i8, i8* %118
%120 = sext i8 %119 to i32
%121 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %120)
br label %122
122: ; preds = %114, %111
%123 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %124
124: ; preds = %122, %88
%125 = load i32, i32* %21
%126 = icmp ne i32 %125, 0
br i1 %126, label %127, label %130
127: ; preds = %124
%128 = load i8*, i8** %14
%129 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %128)
br label %163
130: ; preds = %124
store i64 0, i64* %22
br label %131
131: ; preds = %147, %130
%132 = load i64, i64* %22
%133 = load i64, i64* %15
%134 = icmp ult i64 %132, %133
br i1 %134, label %135, label %138
135: ; preds = %131
%136 = load i64, i64* %22
%137 = icmp ult i64 %136, 8
br label %138
138: ; preds = %135, %131
%139 = phi i1 [ false, %131 ], [ %137, %135 ]
br i1 %139, label %140, label %150
140: ; preds = %138
%141 = load i8*, i8** %14
%142 = load i64, i64* %22
%143 = getelementptr inbounds i8, i8* %141, i64 %142
%144 = load i8, i8* %143
%145 = sext i8 %144 to i32
%146 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %145)
br label %147
147: ; preds = %140
%148 = load i64, i64* %22
%149 = add i64 %148, 1
store i64 %149, i64* %22
br label %131
150: ; preds = %138
%151 = load i64, i64* %15
%152 = icmp ugt i64 %151, 8
br i1 %152, label %153, label %161
153: ; preds = %150
%154 = load i8*, i8** %14
%155 = load i64, i64* %15
%156 = sub i64 %155, 1
%157 = getelementptr inbounds i8, i8* %154, i64 %156
%158 = load i8, i8* %157
%159 = sext i8 %158 to i32
%160 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %159)
br label %161
161: ; preds = %153, %150
%162 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %163
163: ; preds = %161, %127
%164 = load i32, i32* %16
%165 = load i32, i32* %17
%166 = load i64, i64* %11
%167 = trunc i64 %166 to i32
%168 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %164, i32 %165, i32 %167)
%169 = load i32, i32* @stdout
%170 = call i32 @fflush(i32 %169)
%171 = call i32 @gettimeofday(%struct.timeval* %18, i32* null)
%172 = load i8*, i8** %10
%173 = load i64, i64* %11
%174 = load i8*, i8** %12
%175 = load i64, i64* %13
%176 = load i8*, i8** %14
%177 = load i64, i64* %15
%178 = load i32, i32* %16
%179 = load i32, i32* %17
%180 = call i64 @PHS(i8* %172, i64 %173, i8* %174, i64 %175, i8* %176, i64 %177, i32 %178, i32 %179)
%181 = icmp ne i64 %180, 0
br i1 %181, label %182, label %183
182: ; preds = %163
store i32 -1, i32* %9
br label %213
183: ; preds = %163
%184 = call i32 @gettimeofday(%struct.timeval* %19, i32* null)
store i64 0, i64* %22
br label %185
185: ; preds = %196, %183
%186 = load i64, i64* %22
%187 = load i64, i64* %11
%188 = icmp ult i64 %186, %187
br i1 %188, label %189, label %199
189: ; preds = %185
%190 = load i8*, i8** %10
%191 = load i64, i64* %22
%192 = getelementptr inbounds i8, i8* %190, i64 %191
%193 = load i8, i8* %192
%194 = sext i8 %193 to i32
%195 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %194)
br label %196
196: ; preds = %189
%197 = load i64, i64* %22
%198 = add i64 %197, 1
store i64 %198, i64* %22
br label %185
199: ; preds = %185
%200 = getelementptr inbounds %struct.timeval, %struct.timeval* %19, i32 0, i32 0
%201 = load i32, i32* %200
%202 = getelementptr inbounds %struct.timeval, %struct.timeval* %18, i32 0, i32 0
%203 = load i32, i32* %202
%204 = sub nsw i32 %201, %203
%205 = mul nsw i32 1000000, %204
%206 = getelementptr inbounds %struct.timeval, %struct.timeval* %19, i32 0, i32 1
%207 = load i32, i32* %206
%208 = add nsw i32 %205, %207
%209 = getelementptr inbounds %struct.timeval, %struct.timeval* %18, i32 0, i32 1
%210 = load i32, i32* %209
%211 = sub nsw i32 %208, %210
%212 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 %211)
store i32 0, i32* %9
br label %213
213: ; preds = %199, %182
%214 = load i32, i32* %9
ret i32 %214
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
@.str = [5 x i8] c"PHS(\00"
@.str.1 = [7 x i8] c"\22%s\22, \00"
@.str.2 = [7 x i8] c"%.2hhx\00"
@.str.3 = [10 x i8] c"...%.2hhx\00"
@.str.4 = [3 x i8] c", \00"
@.str.5 = [15 x i8] c"%d, %d, %u) = \00"
@stdout = global i32 0
@.str.6 = [10 x i8] c" (%ldus)\0A\00"
define i32 @run_phs(i8* %0, i64 %1, i8* %2, i64 %3, i8* %4, i64 %5, i32 %6, i32 %7) {
%9 = alloca %struct.timeval
%10 = alloca %struct.timeval
%11 = bitcast %struct.timeval* %9 to i8*
%12 = bitcast %struct.timeval* %10 to i8*
%13 = icmp eq i64 %3, 0
br i1 %13, label %32, label %14
14: ; preds = %8
%15 = and i64 %3, 1
%16 = icmp eq i64 %3, 1
br i1 %16, label %19, label %17
17: ; preds = %14
%18 = and i64 %3, -2
br label %40
19: ; preds = %40, %14
%20 = phi i32 [ undef, %14 ], [ %58, %40 ]
%21 = phi i64 [ 0, %14 ], [ %59, %40 ]
%22 = phi i32 [ 1, %14 ], [ %58, %40 ]
%23 = icmp eq i64 %15, 0
br i1 %23, label %32, label %24
24: ; preds = %19
%25 = getelementptr inbounds i8, i8* %2, i64 %21
%26 = load i8, i8* %25
%27 = add i8 %26, -127
%28 = icmp ult i8 %27, -95
%29 = icmp eq i8 %26, 34
%30 = or i1 %29, %28
%31 = select i1 %30, i32 0, i32 %22
br label %32
32: ; preds = %24, %19, %8
%33 = phi i32 [ 1, %8 ], [ %20, %19 ], [ %31, %24 ]
%34 = icmp eq i64 %5, 0
br i1 %34, label %97, label %35
35: ; preds = %32
%36 = and i64 %5, 1
%37 = icmp eq i64 %5, 1
br i1 %37, label %84, label %38
38: ; preds = %35
%39 = and i64 %5, -2
br label %62
40: ; preds = %40, %17
%41 = phi i64 [ 0, %17 ], [ %59, %40 ]
%42 = phi i32 [ 1, %17 ], [ %58, %40 ]
%43 = phi i64 [ 0, %17 ], [ %60, %40 ]
%44 = getelementptr inbounds i8, i8* %2, i64 %41
%45 = load i8, i8* %44
%46 = add i8 %45, -127
%47 = icmp ult i8 %46, -95
%48 = icmp eq i8 %45, 34
%49 = or i1 %48, %47
%50 = or i64 %41, 1
%51 = getelementptr inbounds i8, i8* %2, i64 %50
%52 = load i8, i8* %51
%53 = add i8 %52, -127
%54 = icmp ult i8 %53, -95
%55 = icmp eq i8 %52, 34
%56 = or i1 %55, %54
%57 = select i1 %56, i1 true, i1 %49
%58 = select i1 %57, i32 0, i32 %42
%59 = add nuw i64 %41, 2
%60 = add i64 %43, 2
%61 = icmp eq i64 %60, %18
br i1 %61, label %19, label %40
62: ; preds = %62, %38
%63 = phi i64 [ 0, %38 ], [ %81, %62 ]
%64 = phi i32 [ 1, %38 ], [ %80, %62 ]
%65 = phi i64 [ 0, %38 ], [ %82, %62 ]
%66 = getelementptr inbounds i8, i8* %4, i64 %63
%67 = load i8, i8* %66
%68 = add i8 %67, -127
%69 = icmp ult i8 %68, -95
%70 = icmp eq i8 %67, 34
%71 = or i1 %70, %69
%72 = or i64 %63, 1
%73 = getelementptr inbounds i8, i8* %4, i64 %72
%74 = load i8, i8* %73
%75 = add i8 %74, -127
%76 = icmp ult i8 %75, -95
%77 = icmp eq i8 %74, 34
%78 = or i1 %77, %76
%79 = select i1 %78, i1 true, i1 %71
%80 = select i1 %79, i32 0, i32 %64
%81 = add nuw i64 %63, 2
%82 = add i64 %65, 2
%83 = icmp eq i64 %82, %39
br i1 %83, label %84, label %62
84: ; preds = %62, %35
%85 = phi i32 [ undef, %35 ], [ %80, %62 ]
%86 = phi i64 [ 0, %35 ], [ %81, %62 ]
%87 = phi i32 [ 1, %35 ], [ %80, %62 ]
%88 = icmp eq i64 %36, 0
br i1 %88, label %97, label %89
89: ; preds = %84
%90 = getelementptr inbounds i8, i8* %4, i64 %86
%91 = load i8, i8* %90
%92 = add i8 %91, -127
%93 = icmp ult i8 %92, -95
%94 = icmp eq i8 %91, 34
%95 = or i1 %94, %93
%96 = select i1 %95, i32 0, i32 %87
br label %97
97: ; preds = %89, %84, %32
%98 = phi i32 [ 1, %32 ], [ %85, %84 ], [ %96, %89 ]
%99 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%100 = icmp eq i32 %33, 0
br i1 %100, label %101, label %105
101: ; preds = %97
br i1 %13, label %123, label %102
102: ; preds = %101
%103 = add i64 %3, -1
%104 = call i64 @llvm.umin.i64(i64 %103, i64 7)
br label %107
105: ; preds = %97
%106 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %2)
br label %125
107: ; preds = %102, %107
%108 = phi i64 [ %113, %107 ], [ 0, %102 ]
%109 = getelementptr inbounds i8, i8* %2, i64 %108
%110 = load i8, i8* %109
%111 = sext i8 %110 to i32
%112 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %111)
%113 = add nuw nsw i64 %108, 1
%114 = icmp eq i64 %108, %104
br i1 %114, label %115, label %107
115: ; preds = %107
%116 = icmp ugt i64 %3, 8
br i1 %116, label %117, label %123
117: ; preds = %115
%118 = add i64 %3, -1
%119 = getelementptr inbounds i8, i8* %2, i64 %118
%120 = load i8, i8* %119
%121 = sext i8 %120 to i32
%122 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %121)
br label %123
123: ; preds = %101, %117, %115
%124 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %125
125: ; preds = %123, %105
%126 = icmp eq i32 %98, 0
br i1 %126, label %127, label %131
127: ; preds = %125
br i1 %34, label %149, label %128
128: ; preds = %127
%129 = add i64 %5, -1
%130 = call i64 @llvm.umin.i64(i64 %129, i64 7)
br label %133
131: ; preds = %125
%132 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %4)
br label %151
133: ; preds = %128, %133
%134 = phi i64 [ %139, %133 ], [ 0, %128 ]
%135 = getelementptr inbounds i8, i8* %4, i64 %134
%136 = load i8, i8* %135
%137 = sext i8 %136 to i32
%138 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %137)
%139 = add nuw nsw i64 %134, 1
%140 = icmp eq i64 %134, %130
br i1 %140, label %141, label %133
141: ; preds = %133
%142 = icmp ugt i64 %5, 8
br i1 %142, label %143, label %149
143: ; preds = %141
%144 = add i64 %5, -1
%145 = getelementptr inbounds i8, i8* %4, i64 %144
%146 = load i8, i8* %145
%147 = sext i8 %146 to i32
%148 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %147)
br label %149
149: ; preds = %127, %143, %141
%150 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %151
151: ; preds = %149, %131
%152 = trunc i64 %1 to i32
%153 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %6, i32 %7, i32 %152)
%154 = load i32, i32* @stdout
%155 = tail call i32 @fflush(i32 %154)
%156 = call i32 @gettimeofday(%struct.timeval* %9, i32* null)
%157 = tail call i64 @PHS(i8* %0, i64 %1, i8* %2, i64 %3, i8* %4, i64 %5, i32 %6, i32 %7)
%158 = icmp eq i64 %157, 0
br i1 %158, label %159, label %184
159: ; preds = %151
%160 = call i32 @gettimeofday(%struct.timeval* %10, i32* null)
%161 = icmp eq i64 %1, 0
br i1 %161, label %170, label %162
162: ; preds = %159, %162
%163 = phi i64 [ %168, %162 ], [ 0, %159 ]
%164 = getelementptr inbounds i8, i8* %0, i64 %163
%165 = load i8, i8* %164
%166 = sext i8 %165 to i32
%167 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %166)
%168 = add nuw i64 %163, 1
%169 = icmp eq i64 %168, %1
br i1 %169, label %170, label %162
170: ; preds = %162, %159
%171 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i64 0, i32 0
%172 = load i32, i32* %171
%173 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i64 0, i32 0
%174 = load i32, i32* %173
%175 = sub nsw i32 %172, %174
%176 = mul nsw i32 %175, 1000000
%177 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i64 0, i32 1
%178 = load i32, i32* %177
%179 = add nsw i32 %176, %178
%180 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i64 0, i32 1
%181 = load i32, i32* %180
%182 = sub i32 %179, %181
%183 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 %182)
br label %184
184: ; preds = %151, %170
%185 = phi i32 [ 0, %170 ], [ -1, %151 ]
ret i32 %185
}