#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*/ uint8_t;
typedef int uint16_t;

/* Variables and functions */
int checksum_icmpv6(char *, int);
int /*<<< orphan*/ memcpy(char *, int /*<<< orphan*/ *, int);
char *neighbor_solicitation(char *buffer, uint8_t *IPv6_address,
                            uint8_t *IPv6_dst, uint8_t *mac_address) {
  int offset = 0;
  uint16_t payload_length = 0;
  uint16_t checksum = 0;
  uint8_t target_addres[16];
  int i;
  for (i = 0; i < 16; i++) {
    target_addres[i] = IPv6_dst[i];
  }
  buffer[0] = 0x60;
  buffer[1] = 0;
  buffer[2] = 0;
  buffer[3] = 0;
  offset += 4;
  offset += 2;
  buffer[offset] = 0x3a;
  offset += 1;
  buffer[offset] = 255;
  offset += 1;
  memcpy(&buffer[offset], &IPv6_address[0], 16);
  offset += 16;
  memcpy(&buffer[offset], &IPv6_dst[0], 16);
  offset += 16;
  buffer[offset] = 0x87;
  offset += 1;
  buffer[offset] = 0;
  offset += 1;
  offset += 2;
  buffer[offset] = 0;
  buffer[offset + 1] = 0;
  buffer[offset + 2] = 0;
  buffer[offset + 3] = 0;
  offset += 4;
  memcpy(&buffer[offset], &target_addres[0], 16);
  offset += 16;
  buffer[offset] = 1;
  offset += 1;
  buffer[offset] = 1;
  offset += 1;
  memcpy(&buffer[offset], &mac_address[0], 6);
  offset += 6;
  payload_length = (offset - 40);
  buffer[4] = (payload_length >> 8) & 255;
  buffer[5] = (payload_length >> 0) & 255;
  checksum = checksum_icmpv6(buffer, (offset));
  buffer[42] = (checksum >> 8) & 255;
  buffer[43] = (checksum >> 0) & 255;
  return buffer;
}


x86 assembly (clang, -O0):
<neighbor_solicitation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x74(%rbp)
cmpl   $0x10,-0x74(%rbp)
jge    1182 <neighbor_solicitation+0x62>
mov    -0x18(%rbp),%rax
movslq -0x74(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
movslq -0x74(%rbp),%rax
mov    %ecx,-0x70(%rbp,%rax,4)
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    1157 <neighbor_solicitation+0x37>
mov    -0x8(%rbp),%rax
movb   $0x60,(%rax)
mov    -0x8(%rbp),%rax
movb   $0x0,0x1(%rax)
mov    -0x8(%rbp),%rax
movb   $0x0,0x2(%rax)
mov    -0x8(%rbp),%rax
movb   $0x0,0x3(%rax)
mov    -0x24(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movb   $0x3a,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movb   $0xff,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0x24(%rbp),%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
mov    $0x10,%edx
call   1040 <memcpy@plt>
mov    -0x24(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0x24(%rbp),%rax
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
mov    $0x10,%edx
call   1040 <memcpy@plt>
mov    -0x24(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movb   $0x87,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0x24(%rbp),%rax
add    %rax,%rdi
lea    -0x70(%rbp),%rsi
mov    $0x10,%edx
call   1040 <memcpy@plt>
mov    -0x24(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movb   $0x1,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movb   $0x1,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0x24(%rbp),%rax
add    %rax,%rdi
mov    -0x20(%rbp),%rsi
mov    $0x6,%edx
call   1040 <memcpy@plt>
mov    -0x24(%rbp),%eax
add    $0x6,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
sub    $0x28,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
sar    $0x8,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x4(%rax)
mov    -0x28(%rbp),%eax
sar    $0x0,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x5(%rax)
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1030 <checksum_icmpv6@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
sar    $0x8,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x2a(%rax)
mov    -0x2c(%rbp),%eax
sar    $0x0,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x2b(%rax)
mov    -0x8(%rbp),%rax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<neighbor_solicitation>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rdi,%rbx
movups (%rdx),%xmm0
movups 0x10(%rdx),%xmm1
movups 0x20(%rdx),%xmm2
movups 0x30(%rdx),%xmm3
movaps %xmm3,0x30(%rsp)
movaps %xmm2,0x20(%rsp)
movaps %xmm1,0x10(%rsp)
movaps %xmm0,(%rsp)
movl   $0x60,(%rdi)
movw   $0xff3a,0x6(%rdi)
add    $0x8,%rdi
mov    $0x10,%edx
call   1040 <memcpy@plt>
lea    0x18(%rbx),%rdi
mov    %r15,%rsi
mov    $0x10,%edx
call   1040 <memcpy@plt>
movw   $0x87,0x28(%rbx)
lea    0x30(%rbx),%rdi
movl   $0x0,0x2c(%rbx)
mov    %rsp,%rsi
mov    $0x10,%edx
call   1040 <memcpy@plt>
movw   $0x101,0x40(%rbx)
lea    0x42(%rbx),%rdi
mov    %r14,%rsi
mov    $0x6,%edx
call   1040 <memcpy@plt>
movw   $0x2000,0x4(%rbx)
mov    %rbx,%rdi
mov    $0x48,%esi
call   1030 <checksum_icmpv6@plt>
rol    $0x8,%ax
mov    %ax,0x2a(%rbx)
mov    %rbx,%rax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @neighbor_solicitation(i8* %0, i32* %1, i32* %2, i32* %3) {
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca [16 x i32]
%13 = alloca i32
store i8* %0, i8** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32* %3, i32** %8
store i32 0, i32* %9
store i32 0, i32* %10
store i32 0, i32* %11
store i32 0, i32* %13
br label %14
14: ; preds = %26, %4
%15 = load i32, i32* %13
%16 = icmp slt i32 %15, 16
br i1 %16, label %17, label %29
17: ; preds = %14
%18 = load i32*, i32** %7
%19 = load i32, i32* %13
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %18, i64 %20
%22 = load i32, i32* %21
%23 = load i32, i32* %13
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [16 x i32], [16 x i32]* %12, i64 0, i64 %24
store i32 %22, i32* %25
br label %26
26: ; preds = %17
%27 = load i32, i32* %13
%28 = add nsw i32 %27, 1
store i32 %28, i32* %13
br label %14
29: ; preds = %14
%30 = load i8*, i8** %5
%31 = getelementptr inbounds i8, i8* %30, i64 0
store i8 96, i8* %31
%32 = load i8*, i8** %5
%33 = getelementptr inbounds i8, i8* %32, i64 1
store i8 0, i8* %33
%34 = load i8*, i8** %5
%35 = getelementptr inbounds i8, i8* %34, i64 2
store i8 0, i8* %35
%36 = load i8*, i8** %5
%37 = getelementptr inbounds i8, i8* %36, i64 3
store i8 0, i8* %37
%38 = load i32, i32* %9
%39 = add nsw i32 %38, 4
store i32 %39, i32* %9
%40 = load i32, i32* %9
%41 = add nsw i32 %40, 2
store i32 %41, i32* %9
%42 = load i8*, i8** %5
%43 = load i32, i32* %9
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %42, i64 %44
store i8 58, i8* %45
%46 = load i32, i32* %9
%47 = add nsw i32 %46, 1
store i32 %47, i32* %9
%48 = load i8*, i8** %5
%49 = load i32, i32* %9
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %48, i64 %50
store i8 -1, i8* %51
%52 = load i32, i32* %9
%53 = add nsw i32 %52, 1
store i32 %53, i32* %9
%54 = load i8*, i8** %5
%55 = load i32, i32* %9
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8, i8* %54, i64 %56
%58 = load i32*, i32** %6
%59 = getelementptr inbounds i32, i32* %58, i64 0
%60 = call i32 @memcpy(i8* %57, i32* %59, i32 16)
%61 = load i32, i32* %9
%62 = add nsw i32 %61, 16
store i32 %62, i32* %9
%63 = load i8*, i8** %5
%64 = load i32, i32* %9
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8, i8* %63, i64 %65
%67 = load i32*, i32** %7
%68 = getelementptr inbounds i32, i32* %67, i64 0
%69 = call i32 @memcpy(i8* %66, i32* %68, i32 16)
%70 = load i32, i32* %9
%71 = add nsw i32 %70, 16
store i32 %71, i32* %9
%72 = load i8*, i8** %5
%73 = load i32, i32* %9
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds i8, i8* %72, i64 %74
store i8 -121, i8* %75
%76 = load i32, i32* %9
%77 = add nsw i32 %76, 1
store i32 %77, i32* %9
%78 = load i8*, i8** %5
%79 = load i32, i32* %9
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds i8, i8* %78, i64 %80
store i8 0, i8* %81
%82 = load i32, i32* %9
%83 = add nsw i32 %82, 1
store i32 %83, i32* %9
%84 = load i32, i32* %9
%85 = add nsw i32 %84, 2
store i32 %85, i32* %9
%86 = load i8*, i8** %5
%87 = load i32, i32* %9
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds i8, i8* %86, i64 %88
store i8 0, i8* %89
%90 = load i8*, i8** %5
%91 = load i32, i32* %9
%92 = add nsw i32 %91, 1
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds i8, i8* %90, i64 %93
store i8 0, i8* %94
%95 = load i8*, i8** %5
%96 = load i32, i32* %9
%97 = add nsw i32 %96, 2
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds i8, i8* %95, i64 %98
store i8 0, i8* %99
%100 = load i8*, i8** %5
%101 = load i32, i32* %9
%102 = add nsw i32 %101, 3
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds i8, i8* %100, i64 %103
store i8 0, i8* %104
%105 = load i32, i32* %9
%106 = add nsw i32 %105, 4
store i32 %106, i32* %9
%107 = load i8*, i8** %5
%108 = load i32, i32* %9
%109 = sext i32 %108 to i64
%110 = getelementptr inbounds i8, i8* %107, i64 %109
%111 = getelementptr inbounds [16 x i32], [16 x i32]* %12, i64 0, i64 0
%112 = call i32 @memcpy(i8* %110, i32* %111, i32 16)
%113 = load i32, i32* %9
%114 = add nsw i32 %113, 16
store i32 %114, i32* %9
%115 = load i8*, i8** %5
%116 = load i32, i32* %9
%117 = sext i32 %116 to i64
%118 = getelementptr inbounds i8, i8* %115, i64 %117
store i8 1, i8* %118
%119 = load i32, i32* %9
%120 = add nsw i32 %119, 1
store i32 %120, i32* %9
%121 = load i8*, i8** %5
%122 = load i32, i32* %9
%123 = sext i32 %122 to i64
%124 = getelementptr inbounds i8, i8* %121, i64 %123
store i8 1, i8* %124
%125 = load i32, i32* %9
%126 = add nsw i32 %125, 1
store i32 %126, i32* %9
%127 = load i8*, i8** %5
%128 = load i32, i32* %9
%129 = sext i32 %128 to i64
%130 = getelementptr inbounds i8, i8* %127, i64 %129
%131 = load i32*, i32** %8
%132 = getelementptr inbounds i32, i32* %131, i64 0
%133 = call i32 @memcpy(i8* %130, i32* %132, i32 6)
%134 = load i32, i32* %9
%135 = add nsw i32 %134, 6
store i32 %135, i32* %9
%136 = load i32, i32* %9
%137 = sub nsw i32 %136, 40
store i32 %137, i32* %10
%138 = load i32, i32* %10
%139 = ashr i32 %138, 8
%140 = and i32 %139, 255
%141 = trunc i32 %140 to i8
%142 = load i8*, i8** %5
%143 = getelementptr inbounds i8, i8* %142, i64 4
store i8 %141, i8* %143
%144 = load i32, i32* %10
%145 = ashr i32 %144, 0
%146 = and i32 %145, 255
%147 = trunc i32 %146 to i8
%148 = load i8*, i8** %5
%149 = getelementptr inbounds i8, i8* %148, i64 5
store i8 %147, i8* %149
%150 = load i8*, i8** %5
%151 = load i32, i32* %9
%152 = call i32 @checksum_icmpv6(i8* %150, i32 %151)
store i32 %152, i32* %11
%153 = load i32, i32* %11
%154 = ashr i32 %153, 8
%155 = and i32 %154, 255
%156 = trunc i32 %155 to i8
%157 = load i8*, i8** %5
%158 = getelementptr inbounds i8, i8* %157, i64 42
store i8 %156, i8* %158
%159 = load i32, i32* %11
%160 = ashr i32 %159, 0
%161 = and i32 %160, 255
%162 = trunc i32 %161 to i8
%163 = load i8*, i8** %5
%164 = getelementptr inbounds i8, i8* %163, i64 43
store i8 %162, i8* %164
%165 = load i8*, i8** %5
ret i8* %165
}

LLVM IR (-O2):
define i8* @neighbor_solicitation(i8* returned %0, i32* %1, i32* %2, i32* %3) {
%5 = bitcast i32* %2 to i8*
%6 = alloca [16 x i32]
%7 = bitcast [16 x i32]* %6 to i8*
store i8 96, i8* %0
%8 = getelementptr inbounds i8, i8* %0, i64 1
store i8 0, i8* %8
%9 = getelementptr inbounds i8, i8* %0, i64 2
store i8 0, i8* %9
%10 = getelementptr inbounds i8, i8* %0, i64 3
store i8 0, i8* %10
%11 = getelementptr inbounds i8, i8* %0, i64 6
store i8 58, i8* %11
%12 = getelementptr inbounds i8, i8* %0, i64 7
store i8 -1, i8* %12
%13 = getelementptr inbounds i8, i8* %0, i64 8
%14 = tail call i32 @memcpy(i8* %13, i32* %1, i32 16)
%15 = getelementptr inbounds i8, i8* %0, i64 24
%16 = tail call i32 @memcpy(i8* %15, i32* %2, i32 16)
%17 = getelementptr inbounds i8, i8* %0, i64 40
store i8 -121, i8* %17
%18 = getelementptr inbounds i8, i8* %0, i64 41
store i8 0, i8* %18
%19 = getelementptr inbounds i8, i8* %0, i64 44
%20 = getelementptr inbounds i8, i8* %0, i64 48
%21 = getelementptr inbounds [16 x i32], [16 x i32]* %6, i64 0, i64 0
%22 = bitcast i8* %19 to i32*
store i32 0, i32* %22
%23 = call i32 @memcpy(i8* %20, i32* %21, i32 16)
%24 = getelementptr inbounds i8, i8* %0, i64 64
store i8 1, i8* %24
%25 = getelementptr inbounds i8, i8* %0, i64 65
store i8 1, i8* %25
%26 = getelementptr inbounds i8, i8* %0, i64 66
%27 = call i32 @memcpy(i8* %26, i32* %3, i32 6)
%28 = getelementptr inbounds i8, i8* %0, i64 4
store i8 0, i8* %28
%29 = getelementptr inbounds i8, i8* %0, i64 5
store i8 32, i8* %29
%30 = call i32 @checksum_icmpv6(i8* %0, i32 72)
%31 = lshr i32 %30, 8
%32 = trunc i32 %31 to i8
%33 = getelementptr inbounds i8, i8* %0, i64 42
store i8 %32, i8* %33
%34 = trunc i32 %30 to i8
%35 = getelementptr inbounds i8, i8* %0, i64 43
store i8 %34, i8* %35
ret i8* %0
}