int check_commit_msg_body(char *addr, long long *commit_seq) {
  char *tp = addr;
  int magic;
  long long cseq;
  unsigned short csum1, csum2;
  memcpy(&magic, tp, sizeof(int));
  magic = ntohl(magic);
  if (magic != 0xEBABEFAC) {
    return 0;
  }
  tp += sizeof(int);
  csum1 = crc16(tp, sizeof(long long), 0);
  tp += sizeof(long long);
  memcpy(&csum2, tp, sizeof(unsigned short));
  csum2 = ntohs(csum2);
  if (csum1 != csum2) {
    return 0;
  }
  memcpy(&cseq, (char *)addr + sizeof(int), sizeof(long long));
  cseq = be64toh(cseq);
  *commit_seq = cseq;
  return 1;
}


x86 assembly (clang, -O0):
<check_commit_msg_body>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
mov    $0x0,%al
call   1060 <ntohl@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xebabefac,-0x24(%rbp)
je     1187 <check_commit_msg_body+0x47>
movl   $0x0,-0x4(%rbp)
jmp    121a <check_commit_msg_body+0xda>
mov    -0x20(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x8,%esi
xor    %edx,%edx
mov    $0x0,%al
call   1050 <crc16@plt>
mov    %ax,-0x32(%rbp)
mov    -0x20(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%ax
mov    %ax,-0x34(%rbp)
movzwl -0x34(%rbp),%edi
mov    $0x0,%al
call   1040 <ntohs@plt>
mov    %ax,-0x34(%rbp)
movzwl -0x32(%rbp),%eax
movzwl -0x34(%rbp),%ecx
cmp    %ecx,%eax
je     11eb <check_commit_msg_body+0xab>
movl   $0x0,-0x4(%rbp)
jmp    121a <check_commit_msg_body+0xda>
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    $0x0,%al
call   1030 <be64toh@plt>
cltq
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_commit_msg_body>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    (%rdi),%edi
xor    %ebp,%ebp
xor    %eax,%eax
call   1060 <ntohl@plt>
cmp    $0xebabefac,%eax
jne    119f <check_commit_msg_body+0x5f>
lea    0x4(%rbx),%r15
xor    %ebp,%ebp
mov    $0x8,%esi
mov    %r15,%rdi
xor    %edx,%edx
xor    %eax,%eax
call   1050 <crc16@plt>
mov    %eax,%r12d
movzwl 0xc(%rbx),%edi
xor    %eax,%eax
call   1040 <ntohs@plt>
xor    %r12w,%ax
jne    119f <check_commit_msg_body+0x5f>
mov    (%r15),%rdi
xor    %eax,%eax
call   1030 <be64toh@plt>
cltq
mov    %rax,(%r14)
mov    $0x1,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @check_commit_msg_body(i8* %0, i64* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i64
%9 = alloca i16
%10 = alloca i16
store i8* %0, i8** %4
store i64* %1, i64** %5
%11 = load i8*, i8** %4
store i8* %11, i8** %6
%12 = bitcast i32* %7 to i8*
%13 = load i8*, i8** %6
%14 = load i32, i32* %7
%15 = call i32 (i32, ...) bitcast (i32 (...)* @ntohl to i32 (i32, ...)*)(i32 %14)
store i32 %15, i32* %7
%16 = load i32, i32* %7
%17 = icmp ne i32 %16, -341053524
br i1 %17, label %18, label %19
18: ; preds = %2
store i32 0, i32* %3
br label %48
19: ; preds = %2
%20 = load i8*, i8** %6
%21 = getelementptr inbounds i8, i8* %20, i64 4
store i8* %21, i8** %6
%22 = load i8*, i8** %6
%23 = call i32 (i8*, i64, i32, ...) bitcast (i32 (...)* @crc16 to i32 (i8*, i64, i32, ...)*)(i8* %22, i64 8, i32 0)
%24 = trunc i32 %23 to i16
store i16 %24, i16* %9
%25 = load i8*, i8** %6
%26 = getelementptr inbounds i8, i8* %25, i64 8
store i8* %26, i8** %6
%27 = bitcast i16* %10 to i8*
%28 = load i8*, i8** %6
%29 = load i16, i16* %10
%30 = zext i16 %29 to i32
%31 = call i32 (i32, ...) bitcast (i32 (...)* @ntohs to i32 (i32, ...)*)(i32 %30)
%32 = trunc i32 %31 to i16
store i16 %32, i16* %10
%33 = load i16, i16* %9
%34 = zext i16 %33 to i32
%35 = load i16, i16* %10
%36 = zext i16 %35 to i32
%37 = icmp ne i32 %34, %36
br i1 %37, label %38, label %39
38: ; preds = %19
store i32 0, i32* %3
br label %48
39: ; preds = %19
%40 = bitcast i64* %8 to i8*
%41 = load i8*, i8** %4
%42 = getelementptr inbounds i8, i8* %41, i64 4
%43 = load i64, i64* %8
%44 = call i32 (i64, ...) bitcast (i32 (...)* @be64toh to i32 (i64, ...)*)(i64 %43)
%45 = sext i32 %44 to i64
store i64 %45, i64* %8
%46 = load i64, i64* %8
%47 = load i64*, i64** %5
store i64 %46, i64* %47
store i32 1, i32* %3
br label %48
48: ; preds = %39, %38, %18
%49 = load i32, i32* %3
ret i32 %49
}

LLVM IR (-O2):
define i32 @check_commit_msg_body(i8* %0, i64* nocapture writeonly %1) {
%3 = bitcast i8* %0 to i32*
%4 = load i32, i32* %3
%5 = tail call i32 (i32, ...) bitcast (i32 (...)* @ntohl to i32 (i32, ...)*)(i32 %4)
%6 = icmp eq i32 %5, -341053524
br i1 %6, label %7, label %23
7: ; preds = %2
%8 = getelementptr inbounds i8, i8* %0, i64 4
%9 = tail call i32 (i8*, i64, i32, ...) bitcast (i32 (...)* @crc16 to i32 (i8*, i64, i32, ...)*)(i8* %8, i64 8, i32 0)
%10 = getelementptr inbounds i8, i8* %0, i64 12
%11 = bitcast i8* %10 to i16*
%12 = load i16, i16* %11
%13 = zext i16 %12 to i32
%14 = tail call i32 (i32, ...) bitcast (i32 (...)* @ntohs to i32 (i32, ...)*)(i32 %13)
%15 = xor i32 %14, %9
%16 = and i32 %15, 65535
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %23
18: ; preds = %7
%19 = bitcast i8* %8 to i64*
%20 = load i64, i64* %19
%21 = tail call i32 (i64, ...) bitcast (i32 (...)* @be64toh to i32 (i64, ...)*)(i64 %20)
%22 = sext i32 %21 to i64
store i64 %22, i64* %1
br label %23
23: ; preds = %7, %2, %18
%24 = phi i32 [ 1, %18 ], [ 0, %2 ], [ 0, %7 ]
ret i32 %24
}