#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 uint8_t;

/* Variables and functions */
int /*<<< orphan*/ memcpy(int *, int *, int);
uint8_t *IPv6_address(uint8_t *last_B_addr, uint8_t *IPv6_addr, int type) {
  uint8_t first_B_addr[8];
  int ix;
  if (type == 0) {
    first_B_addr[0] = 0xfe;
    first_B_addr[1] = 0x80;
    for (ix = 2; ix < 8; ix++) {
      first_B_addr[ix] = 0;
    }
  } else {
    first_B_addr[0] = 0xaa;
    first_B_addr[1] = 0xaa;
    for (ix = 2; ix < 8; ix++) {
      first_B_addr[ix] = 0;
    }
  }
  uint8_t aux_last_B_addr[8];
  int i;
  for (i = 0; i < 8; i++) {
    aux_last_B_addr[i] = last_B_addr[i];
  }
  memcpy(&IPv6_addr[0], &first_B_addr[0], 8);
  memcpy(&IPv6_addr[8], &aux_last_B_addr[0], 8);
  return IPv6_addr;
}


x86 assembly (clang, -O0):
<IPv6_address>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    116e <IPv6_address+0x5e>
movl   $0xfe,-0x40(%rbp)
movl   $0x80,-0x3c(%rbp)
movl   $0x2,-0x44(%rbp)
cmpl   $0x8,-0x44(%rbp)
jge    1169 <IPv6_address+0x59>
movslq -0x44(%rbp),%rax
movl   $0x0,-0x40(%rbp,%rax,4)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1145 <IPv6_address+0x35>
jmp    11ac <IPv6_address+0x9c>
movl   $0xaa,-0x40(%rbp)
movl   $0xaa,-0x3c(%rbp)
movl   $0x2,-0x44(%rbp)
cmpl   $0x8,-0x44(%rbp)
jge    11a7 <IPv6_address+0x97>
movslq -0x44(%rbp),%rax
movl   $0x0,-0x40(%rbp,%rax,4)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1183 <IPv6_address+0x73>
jmp    11ac <IPv6_address+0x9c>
movl   $0x0,-0x74(%rbp)
cmpl   $0x8,-0x74(%rbp)
jge    11de <IPv6_address+0xce>
mov    -0x8(%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    11b3 <IPv6_address+0xa3>
mov    -0x10(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    $0x8,%edx
call   1030 <memcpy@plt>
mov    -0x10(%rbp),%rdi
add    $0x20,%rdi
lea    -0x70(%rbp),%rsi
mov    $0x8,%edx
call   1030 <memcpy@plt>
mov    -0x10(%rbp),%rax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<IPv6_address>:
push   %rbx
sub    $0x40,%rsp
mov    %rsi,%rbx
test   %edx,%edx
mov    $0xfe,%eax
mov    $0xaa,%ecx
cmovne %ecx,%eax
mov    $0x80,%edx
cmovne %ecx,%edx
mov    %eax,(%rsp)
mov    %edx,0x4(%rsp)
xorps  %xmm0,%xmm0
movups %xmm0,0x8(%rsp)
movq   $0x0,0x18(%rsp)
movups (%rdi),%xmm0
movups 0x10(%rdi),%xmm1
movaps %xmm1,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
mov    %rsp,%rsi
mov    %rbx,%rdi
mov    $0x8,%edx
call   1030 <memcpy@plt>
lea    0x20(%rbx),%rdi
lea    0x20(%rsp),%rsi
mov    $0x8,%edx
call   1030 <memcpy@plt>
mov    %rbx,%rax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32* @IPv6_address(i32* %0, i32* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca [8 x i32]
%8 = alloca i32
%9 = alloca [8 x i32]
%10 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
%11 = load i32, i32* %6
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %27
13: ; preds = %3
%14 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 0
store i32 254, i32* %14
%15 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 1
store i32 128, i32* %15
store i32 2, i32* %8
br label %16
16: ; preds = %23, %13
%17 = load i32, i32* %8
%18 = icmp slt i32 %17, 8
br i1 %18, label %19, label %26
19: ; preds = %16
%20 = load i32, i32* %8
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 %21
store i32 0, i32* %22
br label %23
23: ; preds = %19
%24 = load i32, i32* %8
%25 = add nsw i32 %24, 1
store i32 %25, i32* %8
br label %16
26: ; preds = %16
br label %41
27: ; preds = %3
%28 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 0
store i32 170, i32* %28
%29 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 1
store i32 170, i32* %29
store i32 2, i32* %8
br label %30
30: ; preds = %37, %27
%31 = load i32, i32* %8
%32 = icmp slt i32 %31, 8
br i1 %32, label %33, label %40
33: ; preds = %30
%34 = load i32, i32* %8
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 %35
store i32 0, i32* %36
br label %37
37: ; preds = %33
%38 = load i32, i32* %8
%39 = add nsw i32 %38, 1
store i32 %39, i32* %8
br label %30
40: ; preds = %30
br label %41
41: ; preds = %40, %26
store i32 0, i32* %10
br label %42
42: ; preds = %54, %41
%43 = load i32, i32* %10
%44 = icmp slt i32 %43, 8
br i1 %44, label %45, label %57
45: ; preds = %42
%46 = load i32*, i32** %4
%47 = load i32, i32* %10
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i32, i32* %46, i64 %48
%50 = load i32, i32* %49
%51 = load i32, i32* %10
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [8 x i32], [8 x i32]* %9, i64 0, i64 %52
store i32 %50, i32* %53
br label %54
54: ; preds = %45
%55 = load i32, i32* %10
%56 = add nsw i32 %55, 1
store i32 %56, i32* %10
br label %42
57: ; preds = %42
%58 = load i32*, i32** %5
%59 = getelementptr inbounds i32, i32* %58, i64 0
%60 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 0
%61 = call i32 @memcpy(i32* %59, i32* %60, i32 8)
%62 = load i32*, i32** %5
%63 = getelementptr inbounds i32, i32* %62, i64 8
%64 = getelementptr inbounds [8 x i32], [8 x i32]* %9, i64 0, i64 0
%65 = call i32 @memcpy(i32* %63, i32* %64, i32 8)
%66 = load i32*, i32** %5
ret i32* %66
}

LLVM IR (-O2):
define i32* @IPv6_address(i32* nocapture %0, i32* returned %1, i32 %2) {
%4 = alloca [8 x i32]
%5 = alloca [8 x i32]
%6 = bitcast [8 x i32]* %5 to i8*
%7 = bitcast [8 x i32]* %4 to i8*
%8 = icmp eq i32 %2, 0
%9 = select i1 %8, i32 254, i32 170
%10 = select i1 %8, i32 128, i32 170
%11 = getelementptr inbounds [8 x i32], [8 x i32]* %4, i64 0, i64 0
store i32 %9, i32* %11
%12 = getelementptr inbounds [8 x i32], [8 x i32]* %4, i64 0, i64 1
store i32 %10, i32* %12
%13 = getelementptr inbounds [8 x i32], [8 x i32]* %4, i64 0, i64 2
%14 = bitcast i32* %13 to i8*
%15 = bitcast i32* %0 to i8*
%16 = getelementptr inbounds [8 x i32], [8 x i32]* %4, i64 0, i64 0
%17 = call i32 @memcpy(i32* %1, i32* %16, i32 8)
%18 = getelementptr inbounds i32, i32* %1, i64 8
%19 = getelementptr inbounds [8 x i32], [8 x i32]* %5, i64 0, i64 0
%20 = call i32 @memcpy(i32* %18, i32* %19, i32 8)
ret i32* %1
}