#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 scalar_t__ uint32_t;

/* Variables and functions */
int PMAPPROC_CALLIT;
int PMAPPROG;
int PMAPVERS;
scalar_t__ htonl(int);
int /*<<< orphan*/ memcpy(void *, scalar_t__ *, unsigned int);
int build_callit_message(void *buffer, size_t size) {
  uint32_t raw_msg[64];
  unsigned int len = 0;
  raw_msg[len++] = 0;
  raw_msg[len++] = 0;
  raw_msg[len++] = htonl(2);
  raw_msg[len++] = htonl(PMAPPROG);
  raw_msg[len++] = htonl(PMAPVERS);
  raw_msg[len++] = htonl(PMAPPROC_CALLIT);
  raw_msg[len++] = 0;
  raw_msg[len++] = 0;
  raw_msg[len++] = 0;
  raw_msg[len++] = 0;
  raw_msg[len++] = htonl(202020);
  raw_msg[len++] = htonl(1);
  raw_msg[len++] = htonl(1);
  raw_msg[len++] = htonl(4);
  raw_msg[len++] = htonl(0xc01dc0fe);
  len *= 4;
  if (len > size)
    return -1;
  memcpy(buffer, raw_msg, len);
  return len;
}


x86 assembly (clang, -O0):
<build_callit_message>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x224(%rbp)
mov    -0x224(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x224(%rbp)
mov    %eax,%eax
movq   $0x0,-0x220(%rbp,%rax,8)
mov    -0x224(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x224(%rbp)
mov    %eax,%eax
movq   $0x0,-0x220(%rbp,%rax,8)
mov    $0x2,%edi
call   1030 <htonl@plt>
mov    %rax,%rcx
mov    -0x224(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x224(%rbp)
mov    %eax,%eax
mov    %rcx,-0x220(%rbp,%rax,8)
ff
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
call   1030 <htonl@plt>
mov    %rax,%rcx
mov    -0x224(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x224(%rbp)
mov    %eax,%eax
mov    %rcx,-0x220(%rbp,%rax,8)
ff
mov    0x2e02(%rip),%rax
mov    (%rax),%edi
call   1030 <htonl@plt>
mov    %rax,%rcx
mov    -0x224(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x224(%rbp)
mov    %eax,%eax
mov    %rcx,-0x220(%rbp,%rax,8)
ff
mov    0x2dde(%rip),%rax
mov    (%rax),%edi
call   1030 <htonl@plt>
mov    %rax,%rcx
mov    -0x224(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x224(%rbp)
mov    %eax,%eax
mov    %rcx,-0x220(%rbp,%rax,8)
ff
mov    -0x224(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x224(%rbp)
mov    %eax,%eax
movq   $0x0,-0x220(%rbp,%rax,8)
mov    -0x224(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x224(%rbp)
mov    %eax,%eax
movq   $0x0,-0x220(%rbp,%rax,8)
mov    -0x224(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x224(%rbp)
mov    %eax,%eax
movq   $0x0,-0x220(%rbp,%rax,8)
mov    -0x224(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x224(%rbp)
mov    %eax,%eax
movq   $0x0,-0x220(%rbp,%rax,8)
mov    $0x31524,%edi
call   1030 <htonl@plt>
mov    %rax,%rcx
mov    -0x224(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x224(%rbp)
mov    %eax,%eax
mov    %rcx,-0x220(%rbp,%rax,8)
ff
mov    $0x1,%edi
call   1030 <htonl@plt>
mov    %rax,%rcx
mov    -0x224(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x224(%rbp)
mov    %eax,%eax
mov    %rcx,-0x220(%rbp,%rax,8)
ff
mov    $0x1,%edi
call   1030 <htonl@plt>
mov    %rax,%rcx
mov    -0x224(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x224(%rbp)
mov    %eax,%eax
mov    %rcx,-0x220(%rbp,%rax,8)
ff
mov    $0x4,%edi
call   1030 <htonl@plt>
mov    %rax,%rcx
mov    -0x224(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x224(%rbp)
mov    %eax,%eax
mov    %rcx,-0x220(%rbp,%rax,8)
ff
mov    $0xc01dc0fe,%edi
call   1030 <htonl@plt>
mov    %rax,%rcx
mov    -0x224(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x224(%rbp)
mov    %eax,%eax
mov    %rcx,-0x220(%rbp,%rax,8)
ff
mov    -0x224(%rbp),%eax
shl    $0x2,%eax
mov    %eax,-0x224(%rbp)
mov    -0x224(%rbp),%eax
cmp    -0x18(%rbp),%rax
jbe    1396 <build_callit_message+0x276>
movl   $0xffffffff,-0x4(%rbp)
jmp    13b5 <build_callit_message+0x295>
mov    -0x10(%rbp),%rdi
lea    -0x220(%rbp),%rsi
mov    -0x224(%rbp),%edx
call   1040 <memcpy@plt>
mov    -0x224(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<build_callit_message>:
push   %rbp
push   %r14
push   %rbx
sub    $0x200,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
mov    $0x2,%edi
call   1030 <htonl@plt>
mov    %rax,0x10(%rsp)
mov    0x2e9a(%rip),%rax
mov    (%rax),%edi
call   1030 <htonl@plt>
mov    %rax,0x18(%rsp)
mov    0x2e77(%rip),%rax
mov    (%rax),%edi
call   1030 <htonl@plt>
mov    %rax,0x20(%rsp)
mov    0x2e6c(%rip),%rax
mov    (%rax),%edi
call   1030 <htonl@plt>
mov    %rax,0x28(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x40(%rsp)
mov    $0x31524,%edi
call   1030 <htonl@plt>
mov    %rax,0x50(%rsp)
mov    $0x1,%edi
call   1030 <htonl@plt>
mov    %rax,0x58(%rsp)
mov    $0x1,%edi
call   1030 <htonl@plt>
mov    %rax,0x60(%rsp)
mov    $0x4,%edi
call   1030 <htonl@plt>
mov    %rax,0x68(%rsp)
mov    $0xc01dc0fe,%edi
call   1030 <htonl@plt>
mov    %rax,0x70(%rsp)
mov    $0xffffffff,%ebp
cmp    $0x3c,%rbx
jb     11f8 <build_callit_message+0xd8>
mov    %rsp,%rsi
mov    $0x3c,%ebp
mov    %r14,%rdi
mov    $0x3c,%edx
call   1040 <memcpy@plt>
mov    %ebp,%eax
add    $0x200,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@PMAPPROG = global i32 0
@PMAPVERS = global i32 0
@PMAPPROC_CALLIT = global i32 0
define i32 @build_callit_message(i8* %0, i64 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca [64 x i64]
%7 = alloca i32
store i8* %0, i8** %4
store i64 %1, i64* %5
store i32 0, i32* %7
%8 = load i32, i32* %7
%9 = add i32 %8, 1
store i32 %9, i32* %7
%10 = zext i32 %8 to i64
%11 = getelementptr inbounds [64 x i64], [64 x i64]* %6, i64 0, i64 %10
store i64 0, i64* %11
%12 = load i32, i32* %7
%13 = add i32 %12, 1
store i32 %13, i32* %7
%14 = zext i32 %12 to i64
%15 = getelementptr inbounds [64 x i64], [64 x i64]* %6, i64 0, i64 %14
store i64 0, i64* %15
%16 = call i64 @htonl(i32 2)
%17 = load i32, i32* %7
%18 = add i32 %17, 1
store i32 %18, i32* %7
%19 = zext i32 %17 to i64
%20 = getelementptr inbounds [64 x i64], [64 x i64]* %6, i64 0, i64 %19
store i64 %16, i64* %20
%21 = load i32, i32* @PMAPPROG
%22 = call i64 @htonl(i32 %21)
%23 = load i32, i32* %7
%24 = add i32 %23, 1
store i32 %24, i32* %7
%25 = zext i32 %23 to i64
%26 = getelementptr inbounds [64 x i64], [64 x i64]* %6, i64 0, i64 %25
store i64 %22, i64* %26
%27 = load i32, i32* @PMAPVERS
%28 = call i64 @htonl(i32 %27)
%29 = load i32, i32* %7
%30 = add i32 %29, 1
store i32 %30, i32* %7
%31 = zext i32 %29 to i64
%32 = getelementptr inbounds [64 x i64], [64 x i64]* %6, i64 0, i64 %31
store i64 %28, i64* %32
%33 = load i32, i32* @PMAPPROC_CALLIT
%34 = call i64 @htonl(i32 %33)
%35 = load i32, i32* %7
%36 = add i32 %35, 1
store i32 %36, i32* %7
%37 = zext i32 %35 to i64
%38 = getelementptr inbounds [64 x i64], [64 x i64]* %6, i64 0, i64 %37
store i64 %34, i64* %38
%39 = load i32, i32* %7
%40 = add i32 %39, 1
store i32 %40, i32* %7
%41 = zext i32 %39 to i64
%42 = getelementptr inbounds [64 x i64], [64 x i64]* %6, i64 0, i64 %41
store i64 0, i64* %42
%43 = load i32, i32* %7
%44 = add i32 %43, 1
store i32 %44, i32* %7
%45 = zext i32 %43 to i64
%46 = getelementptr inbounds [64 x i64], [64 x i64]* %6, i64 0, i64 %45
store i64 0, i64* %46
%47 = load i32, i32* %7
%48 = add i32 %47, 1
store i32 %48, i32* %7
%49 = zext i32 %47 to i64
%50 = getelementptr inbounds [64 x i64], [64 x i64]* %6, i64 0, i64 %49
store i64 0, i64* %50
%51 = load i32, i32* %7
%52 = add i32 %51, 1
store i32 %52, i32* %7
%53 = zext i32 %51 to i64
%54 = getelementptr inbounds [64 x i64], [64 x i64]* %6, i64 0, i64 %53
store i64 0, i64* %54
%55 = call i64 @htonl(i32 202020)
%56 = load i32, i32* %7
%57 = add i32 %56, 1
store i32 %57, i32* %7
%58 = zext i32 %56 to i64
%59 = getelementptr inbounds [64 x i64], [64 x i64]* %6, i64 0, i64 %58
store i64 %55, i64* %59
%60 = call i64 @htonl(i32 1)
%61 = load i32, i32* %7
%62 = add i32 %61, 1
store i32 %62, i32* %7
%63 = zext i32 %61 to i64
%64 = getelementptr inbounds [64 x i64], [64 x i64]* %6, i64 0, i64 %63
store i64 %60, i64* %64
%65 = call i64 @htonl(i32 1)
%66 = load i32, i32* %7
%67 = add i32 %66, 1
store i32 %67, i32* %7
%68 = zext i32 %66 to i64
%69 = getelementptr inbounds [64 x i64], [64 x i64]* %6, i64 0, i64 %68
store i64 %65, i64* %69
%70 = call i64 @htonl(i32 4)
%71 = load i32, i32* %7
%72 = add i32 %71, 1
store i32 %72, i32* %7
%73 = zext i32 %71 to i64
%74 = getelementptr inbounds [64 x i64], [64 x i64]* %6, i64 0, i64 %73
store i64 %70, i64* %74
%75 = call i64 @htonl(i32 -1071791874)
%76 = load i32, i32* %7
%77 = add i32 %76, 1
store i32 %77, i32* %7
%78 = zext i32 %76 to i64
%79 = getelementptr inbounds [64 x i64], [64 x i64]* %6, i64 0, i64 %78
store i64 %75, i64* %79
%80 = load i32, i32* %7
%81 = mul i32 %80, 4
store i32 %81, i32* %7
%82 = load i32, i32* %7
%83 = zext i32 %82 to i64
%84 = load i64, i64* %5
%85 = icmp ugt i64 %83, %84
br i1 %85, label %86, label %87
86: ; preds = %2
store i32 -1, i32* %3
br label %93
87: ; preds = %2
%88 = load i8*, i8** %4
%89 = getelementptr inbounds [64 x i64], [64 x i64]* %6, i64 0, i64 0
%90 = load i32, i32* %7
%91 = call i32 @memcpy(i8* %88, i64* %89, i32 %90)
%92 = load i32, i32* %7
store i32 %92, i32* %3
br label %93
93: ; preds = %87, %86
%94 = load i32, i32* %3
ret i32 %94
}

LLVM IR (-O2):
@PMAPPROG = global i32 0
@PMAPVERS = global i32 0
@PMAPPROC_CALLIT = global i32 0
define i32 @build_callit_message(i8* %0, i64 %1) {
%3 = alloca [64 x i64]
%4 = bitcast [64 x i64]* %3 to i8*
%5 = bitcast [64 x i64]* %3 to i8*
%6 = tail call i64 @htonl(i32 2)
%7 = getelementptr inbounds [64 x i64], [64 x i64]* %3, i64 0, i64 2
store i64 %6, i64* %7
%8 = load i32, i32* @PMAPPROG
%9 = tail call i64 @htonl(i32 %8)
%10 = getelementptr inbounds [64 x i64], [64 x i64]* %3, i64 0, i64 3
store i64 %9, i64* %10
%11 = load i32, i32* @PMAPVERS
%12 = tail call i64 @htonl(i32 %11)
%13 = getelementptr inbounds [64 x i64], [64 x i64]* %3, i64 0, i64 4
store i64 %12, i64* %13
%14 = load i32, i32* @PMAPPROC_CALLIT
%15 = tail call i64 @htonl(i32 %14)
%16 = getelementptr inbounds [64 x i64], [64 x i64]* %3, i64 0, i64 5
store i64 %15, i64* %16
%17 = getelementptr inbounds [64 x i64], [64 x i64]* %3, i64 0, i64 6
%18 = bitcast i64* %17 to i8*
%19 = tail call i64 @htonl(i32 202020)
%20 = getelementptr inbounds [64 x i64], [64 x i64]* %3, i64 0, i64 10
store i64 %19, i64* %20
%21 = tail call i64 @htonl(i32 1)
%22 = getelementptr inbounds [64 x i64], [64 x i64]* %3, i64 0, i64 11
store i64 %21, i64* %22
%23 = tail call i64 @htonl(i32 1)
%24 = getelementptr inbounds [64 x i64], [64 x i64]* %3, i64 0, i64 12
store i64 %23, i64* %24
%25 = tail call i64 @htonl(i32 4)
%26 = getelementptr inbounds [64 x i64], [64 x i64]* %3, i64 0, i64 13
store i64 %25, i64* %26
%27 = tail call i64 @htonl(i32 -1071791874)
%28 = getelementptr inbounds [64 x i64], [64 x i64]* %3, i64 0, i64 14
store i64 %27, i64* %28
%29 = icmp ult i64 %1, 60
br i1 %29, label %33, label %30
30: ; preds = %2
%31 = getelementptr inbounds [64 x i64], [64 x i64]* %3, i64 0, i64 0
%32 = call i32 @memcpy(i8* %0, i64* %31, i32 60)
br label %33
33: ; preds = %2, %30
%34 = phi i32 [ 60, %30 ], [ -1, %2 ]
ret i32 %34
}