#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*/ par;
typedef int off_t;

/* Variables and functions */
int char2int(char *, int);
int /*<<< orphan*/ exit(int);
unsigned char *malloc(int);
int /*<<< orphan*/ memcpy(unsigned char *, char *, int);
int /*<<< orphan*/ verbose(int, char *, long long, long long, ...);
int parse_hashes(int hashsize, char *msgbuf, size_t msglen, off_t *start,
                 off_t *step, int *nstep, unsigned char **hbuf) {
  off_t par[3];
  int i;
  if (msglen < sizeof(par)) {
    verbose(0, "parse_hashes: bad size=%lld minimum=%lld\n", (long long)msglen,
            (long long)(sizeof(par)));
    exit(1);
  }
  for (i = 0; i < 3; i++, msgbuf += sizeof(par[0])) {
    par[i] = char2int(msgbuf, sizeof(par[0]));
  }
  *start = par[0];
  *step = par[1];
  *nstep = par[2];
  if (msglen != sizeof(par) + *nstep * hashsize) {
    verbose(0, "parse_hashes: bad size=%lld expected=%lld\n", (long long)msglen,
            (long long)(sizeof(par) + *nstep * hashsize));
    exit(1);
  }
  *hbuf = malloc(*nstep * hashsize);
  memcpy(*hbuf, msgbuf, *nstep * hashsize);
  verbose(1, "parse_hashes: start=%lld, step=%lld, nstep=%d\n",
          (long long)*start, (long long)*step, *nstep);
  return 0;
}


x86 assembly (clang, -O0):
<parse_hashes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
cmpq   $0xc,-0x18(%rbp)
jae    11a1 <parse_hashes+0x51>
mov    -0x18(%rbp),%rdx
xor    %edi,%edi
lea    0xe75(%rip),%rsi
mov    $0xc,%ecx
mov    $0x0,%al
call   1060 <verbose@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
movl   $0x0,-0x40(%rbp)
cmpl   $0x3,-0x40(%rbp)
jge    11e4 <parse_hashes+0x94>
mov    -0x10(%rbp),%rdi
mov    $0x4,%esi
call   1050 <char2int@plt>
mov    %eax,%ecx
movslq -0x40(%rbp),%rax
mov    %ecx,-0x3c(%rbp,%rax,4)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x10(%rbp)
jmp    11a8 <parse_hashes+0x58>
mov    -0x3c(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x38(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x34(%rbp),%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rcx),%ecx
imul   -0x4(%rbp),%ecx
movslq %ecx,%rcx
add    $0xc,%rcx
cmp    %rcx,%rax
je     124c <parse_hashes+0xfc>
mov    -0x18(%rbp),%rdx
mov    -0x30(%rbp),%rax
mov    (%rax),%eax
imul   -0x4(%rbp),%eax
movslq %eax,%rcx
add    $0xc,%rcx
xor    %edi,%edi
lea    0xdef(%rip),%rsi
mov    $0x0,%al
call   1060 <verbose@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x30(%rbp),%rax
mov    (%rax),%edi
imul   -0x4(%rbp),%edi
call   1040 <malloc@plt>
mov    %rax,%rcx
mov    0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x30(%rbp),%rax
mov    (%rax),%edx
imul   -0x4(%rbp),%edx
call   1030 <memcpy@plt>
mov    -0x20(%rbp),%rax
movslq (%rax),%rdx
mov    -0x28(%rbp),%rax
movslq (%rax),%rcx
mov    -0x30(%rbp),%rax
mov    (%rax),%r8d
mov    $0x1,%edi
lea    0xdb5(%rip),%rsi
mov    $0x0,%al
call   1060 <verbose@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_hashes>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,0x10(%rsp)
mov    %r8,0x8(%rsp)
mov    %rdx,%r12
cmp    $0xc,%rdx
jb     1222 <parse_hashes+0xd2>
mov    %rcx,%r13
mov    %rsi,%rbx
mov    %edi,%ebp
mov    %rsi,%rdi
mov    $0x4,%esi
call   1050 <char2int@plt>
mov    %eax,%r14d
lea    0x4(%rbx),%rdi
mov    $0x4,%esi
call   1050 <char2int@plt>
mov    %eax,%r15d
lea    0x8(%rbx),%rdi
mov    $0x4,%esi
call   1050 <char2int@plt>
mov    %r14d,0x0(%r13)
mov    0x8(%rsp),%rcx
mov    %r15d,(%rcx)
mov    0x10(%rsp),%r15
mov    %eax,(%r15)
imul   %eax,%ebp
movslq %ebp,%rcx
add    $0xc,%rcx
cmp    %r12,%rcx
jne    1230 <parse_hashes+0xe0>
mov    0x50(%rsp),%r14
add    $0xc,%rbx
mov    %ebp,%edi
call   1040 <malloc@plt>
mov    %rax,(%r14)
mov    %rax,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1030 <memcpy@plt>
movslq 0x0(%r13),%rdx
mov    0x8(%rsp),%rax
movslq (%rax),%rcx
mov    (%r15),%r8d
lea    0xe50(%rip),%rsi
mov    $0x1,%edi
xor    %eax,%eax
call   1060 <verbose@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdd7(%rip),%rsi
mov    $0xc,%ecx
jmp    1237 <parse_hashes+0xe7>
lea    0xdf3(%rip),%rsi
xor    %edi,%edi
mov    %r12,%rdx
xor    %eax,%eax
call   1060 <verbose@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [42 x i8] c"parse_hashes: bad size=%lld minimum=%lld\0A\00"
@.str.1 = [43 x i8] c"parse_hashes: bad size=%lld expected=%lld\0A\00"
@.str.2 = [47 x i8] c"parse_hashes: start=%lld, step=%lld, nstep=%d\0A\00"
define i32 @parse_hashes(i32 %0, i8* %1, i64 %2, i32* %3, i32* %4, i32* %5, i8** %6) {
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i8**
%15 = alloca [3 x i32]
%16 = alloca i32
store i32 %0, i32* %8
store i8* %1, i8** %9
store i64 %2, i64* %10
store i32* %3, i32** %11
store i32* %4, i32** %12
store i32* %5, i32** %13
store i8** %6, i8*** %14
%17 = load i64, i64* %10
%18 = icmp ult i64 %17, 12
br i1 %18, label %19, label %23
19: ; preds = %7
%20 = load i64, i64* %10
%21 = call i32 (i32, i8*, i64, i64, ...) @verbose(i32 0, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i64 %20, i64 12)
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %7
store i32 0, i32* %16
br label %24
24: ; preds = %33, %23
%25 = load i32, i32* %16
%26 = icmp slt i32 %25, 3
br i1 %26, label %27, label %38
27: ; preds = %24
%28 = load i8*, i8** %9
%29 = call i32 @char2int(i8* %28, i32 4)
%30 = load i32, i32* %16
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [3 x i32], [3 x i32]* %15, i64 0, i64 %31
store i32 %29, i32* %32
br label %33
33: ; preds = %27
%34 = load i32, i32* %16
%35 = add nsw i32 %34, 1
store i32 %35, i32* %16
%36 = load i8*, i8** %9
%37 = getelementptr inbounds i8, i8* %36, i64 4
store i8* %37, i8** %9
br label %24
38: ; preds = %24
%39 = getelementptr inbounds [3 x i32], [3 x i32]* %15, i64 0, i64 0
%40 = load i32, i32* %39
%41 = load i32*, i32** %11
store i32 %40, i32* %41
%42 = getelementptr inbounds [3 x i32], [3 x i32]* %15, i64 0, i64 1
%43 = load i32, i32* %42
%44 = load i32*, i32** %12
store i32 %43, i32* %44
%45 = getelementptr inbounds [3 x i32], [3 x i32]* %15, i64 0, i64 2
%46 = load i32, i32* %45
%47 = load i32*, i32** %13
store i32 %46, i32* %47
%48 = load i64, i64* %10
%49 = load i32*, i32** %13
%50 = load i32, i32* %49
%51 = load i32, i32* %8
%52 = mul nsw i32 %50, %51
%53 = sext i32 %52 to i64
%54 = add i64 12, %53
%55 = icmp ne i64 %48, %54
br i1 %55, label %56, label %66
56: ; preds = %38
%57 = load i64, i64* %10
%58 = load i32*, i32** %13
%59 = load i32, i32* %58
%60 = load i32, i32* %8
%61 = mul nsw i32 %59, %60
%62 = sext i32 %61 to i64
%63 = add i64 12, %62
%64 = call i32 (i32, i8*, i64, i64, ...) @verbose(i32 0, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i64 %57, i64 %63)
%65 = call i32 @exit(i32 1)
unreachable
66: ; preds = %38
%67 = load i32*, i32** %13
%68 = load i32, i32* %67
%69 = load i32, i32* %8
%70 = mul nsw i32 %68, %69
%71 = call i8* @malloc(i32 %70)
%72 = load i8**, i8*** %14
store i8* %71, i8** %72
%73 = load i8**, i8*** %14
%74 = load i8*, i8** %73
%75 = load i8*, i8** %9
%76 = load i32*, i32** %13
%77 = load i32, i32* %76
%78 = load i32, i32* %8
%79 = mul nsw i32 %77, %78
%80 = call i32 @memcpy(i8* %74, i8* %75, i32 %79)
%81 = load i32*, i32** %11
%82 = load i32, i32* %81
%83 = sext i32 %82 to i64
%84 = load i32*, i32** %12
%85 = load i32, i32* %84
%86 = sext i32 %85 to i64
%87 = load i32*, i32** %13
%88 = load i32, i32* %87
%89 = call i32 (i32, i8*, i64, i64, ...) @verbose(i32 1, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0), i64 %83, i64 %86, i32 %88)
ret i32 0
}

LLVM IR (-O2):
@.str = [42 x i8] c"parse_hashes: bad size=%lld minimum=%lld\0A\00"
@.str.1 = [43 x i8] c"parse_hashes: bad size=%lld expected=%lld\0A\00"
@.str.2 = [47 x i8] c"parse_hashes: start=%lld, step=%lld, nstep=%d\0A\00"
define i32 @parse_hashes(i32 %0, i8* %1, i64 %2, i32* nocapture %3, i32* nocapture %4, i32* nocapture %5, i8** nocapture writeonly %6) {
%8 = icmp ult i64 %2, 12
br i1 %8, label %19, label %9
9: ; preds = %7
%10 = tail call i32 @char2int(i8* %1, i32 4)
%11 = getelementptr inbounds i8, i8* %1, i64 4
%12 = tail call i32 @char2int(i8* %11, i32 4)
%13 = getelementptr inbounds i8, i8* %1, i64 8
%14 = tail call i32 @char2int(i8* %13, i32 4)
store i32 %10, i32* %3
store i32 %12, i32* %4
store i32 %14, i32* %5
%15 = mul nsw i32 %14, %0
%16 = sext i32 %15 to i64
%17 = add nsw i64 %16, 12
%18 = icmp eq i64 %17, %2
br i1 %18, label %25, label %22
19: ; preds = %7
%20 = tail call i32 (i32, i8*, i64, i64, ...) @verbose(i32 0, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i64 %2, i64 12)
%21 = tail call i32 @exit(i32 1)
unreachable
22: ; preds = %9
%23 = tail call i32 (i32, i8*, i64, i64, ...) @verbose(i32 0, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i64 %2, i64 %17)
%24 = tail call i32 @exit(i32 1)
unreachable
25: ; preds = %9
%26 = getelementptr inbounds i8, i8* %1, i64 12
%27 = tail call i8* @malloc(i32 %15)
store i8* %27, i8** %6
%28 = tail call i32 @memcpy(i8* %27, i8* %26, i32 %15)
%29 = load i32, i32* %3
%30 = sext i32 %29 to i64
%31 = load i32, i32* %4
%32 = sext i32 %31 to i64
%33 = load i32, i32* %5
%34 = tail call i32 (i32, i8*, i64, i64, ...) @verbose(i32 1, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0), i64 %30, i64 %32, i32 %33)
ret i32 0
}