#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 size_t off_t;

/* Variables and functions */
size_t char2int(char *, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ verbose(int, char *, long long, ...);
int parse_block(char *msgbuf, size_t msglen, off_t *pos, off_t *len,
                char **pblock) {
  if (msglen < sizeof(*pos) + 1) {
    verbose(0, "parse_getblock: bad message size %d\n", (int)msglen);
    exit(1);
  }
  *pos = char2int(msgbuf, sizeof(*pos));
  *len = msglen - sizeof(*pos);
  *pblock = msgbuf + sizeof(*pos);
  verbose(1, "parse_block: pos=%lld len=%lld\n", (long long)*pos,
          (long long)*len);
  return 0;
}


x86 assembly (clang, -O0):
<parse_block>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
cmpq   $0x9,-0x10(%rbp)
jae    1178 <parse_block+0x48>
mov    -0x10(%rbp),%rax
movslq %eax,%rdx
xor    %edi,%edi
lea    0xe99(%rip),%rsi
mov    $0x0,%al
call   1040 <verbose@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0x8(%rbp),%rdi
mov    $0x8,%esi
call   1030 <char2int@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rcx
sub    $0x8,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rcx
add    $0x8,%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdx
mov    -0x20(%rbp),%rax
mov    (%rax),%rcx
mov    $0x1,%edi
lea    0xe5d(%rip),%rsi
mov    $0x0,%al
call   1040 <verbose@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_block>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r13
cmp    $0x8,%rsi
jbe    118f <parse_block+0x5f>
mov    %r8,%r14
mov    %rcx,%r12
mov    %rdx,%r15
mov    %rdi,%rbx
mov    $0x8,%esi
call   1030 <char2int@plt>
mov    %rax,(%r15)
add    $0xfffffffffffffff8,%r13
mov    %r13,(%r12)
add    $0x8,%rbx
mov    %rbx,(%r14)
mov    (%r15),%rdx
lea    0xeb1(%rip),%rsi
mov    $0x1,%edi
mov    %r13,%rcx
xor    %eax,%eax
call   1040 <verbose@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xe6a(%rip),%rsi
xor    %edi,%edi
mov    %r13,%rdx
xor    %eax,%eax
call   1040 <verbose@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [37 x i8] c"parse_getblock: bad message size %d\0A\00"
@.str.1 = [32 x i8] c"parse_block: pos=%lld len=%lld\0A\00"
define i32 @parse_block(i8* %0, i64 %1, i64* %2, i64* %3, i8** %4) {
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64*
%9 = alloca i64*
%10 = alloca i8**
store i8* %0, i8** %6
store i64 %1, i64* %7
store i64* %2, i64** %8
store i64* %3, i64** %9
store i8** %4, i8*** %10
%11 = load i64, i64* %7
%12 = icmp ult i64 %11, 9
br i1 %12, label %13, label %19
13: ; preds = %5
%14 = load i64, i64* %7
%15 = trunc i64 %14 to i32
%16 = sext i32 %15 to i64
%17 = call i32 (i32, i8*, i64, ...) @verbose(i32 0, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i64 %16)
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %5
%20 = load i8*, i8** %6
%21 = call i64 @char2int(i8* %20, i32 8)
%22 = load i64*, i64** %8
store i64 %21, i64* %22
%23 = load i64, i64* %7
%24 = sub i64 %23, 8
%25 = load i64*, i64** %9
store i64 %24, i64* %25
%26 = load i8*, i8** %6
%27 = getelementptr inbounds i8, i8* %26, i64 8
%28 = load i8**, i8*** %10
store i8* %27, i8** %28
%29 = load i64*, i64** %8
%30 = load i64, i64* %29
%31 = load i64*, i64** %9
%32 = load i64, i64* %31
%33 = call i32 (i32, i8*, i64, ...) @verbose(i32 1, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i64 %30, i64 %32)
ret i32 0
}

LLVM IR (-O2):
@.str = [37 x i8] c"parse_getblock: bad message size %d\0A\00"
@.str.1 = [32 x i8] c"parse_block: pos=%lld len=%lld\0A\00"
define i32 @parse_block(i8* %0, i64 %1, i64* nocapture %2, i64* nocapture writeonly %3, i8** nocapture writeonly %4) {
%6 = icmp ult i64 %1, 9
br i1 %6, label %7, label %10
7: ; preds = %5
%8 = tail call i32 (i32, i8*, i64, ...) @verbose(i32 0, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i64 %1)
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %5
%11 = tail call i64 @char2int(i8* %0, i32 8)
store i64 %11, i64* %2
%12 = add i64 %1, -8
store i64 %12, i64* %3
%13 = getelementptr inbounds i8, i8* %0, i64 8
store i8* %13, i8** %4
%14 = load i64, i64* %2
%15 = tail call i32 (i32, i8*, i64, ...) @verbose(i32 1, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i64 %14, i64 %12)
ret i32 0
}