#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 */

/* Variables and functions */
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char **, int);
void createMagicPacket(unsigned char packet[], unsigned int macAddress[]) {
  int i;
  unsigned char mac[6];
  for (i = 0; i < 6; i++) {
    packet[i] = 0xFF;
    mac[i] = macAddress[i];
  }
  for (i = 1; i <= 16; i++) {
    memcpy(&packet[i * 6], &mac, 6 * sizeof(unsigned char));
  }
}


x86 assembly (clang, -O0):
<createMagicPacket>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x6,-0x14(%rbp)
jge    1160 <createMagicPacket+0x50>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0xff,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %al,%cl
movslq -0x14(%rbp),%rax
mov    %cl,-0x1a(%rbp,%rax,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1127 <createMagicPacket+0x17>
movl   $0x1,-0x14(%rbp)
cmpl   $0x10,-0x14(%rbp)
jg     119a <createMagicPacket+0x8a>
mov    -0x8(%rbp),%rdi
imul   $0x6,-0x14(%rbp),%eax
cltq
add    %rax,%rdi
lea    -0x1a(%rbp),%rsi
mov    $0x6,%edx
call   1030 <memcpy@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1167 <createMagicPacket+0x57>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<createMagicPacket>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
movb   $0xff,(%rdi)
mov    (%rsi),%al
mov    %al,0x2(%rsp)
movb   $0xff,0x1(%rdi)
mov    0x4(%rsi),%al
mov    %al,0x3(%rsp)
movb   $0xff,0x2(%rdi)
mov    0x8(%rsi),%al
mov    %al,0x4(%rsp)
movb   $0xff,0x3(%rdi)
mov    0xc(%rsi),%al
mov    %al,0x5(%rsp)
movb   $0xff,0x4(%rdi)
mov    0x10(%rsi),%al
mov    %al,0x6(%rsp)
movb   $0xff,0x5(%rdi)
mov    0x14(%rsi),%al
mov    %al,0x7(%rsp)
add    $0x6,%rdi
lea    0x2(%rsp),%r14
mov    %r14,%rsi
mov    $0x6,%edx
call   1030 <memcpy@plt>
lea    0xc(%rbx),%rdi
mov    %r14,%rsi
mov    $0x6,%edx
call   1030 <memcpy@plt>
lea    0x12(%rbx),%rdi
mov    %r14,%rsi
mov    $0x6,%edx
call   1030 <memcpy@plt>
lea    0x18(%rbx),%rdi
mov    %r14,%rsi
mov    $0x6,%edx
call   1030 <memcpy@plt>
lea    0x1e(%rbx),%rdi
mov    %r14,%rsi
mov    $0x6,%edx
call   1030 <memcpy@plt>
lea    0x24(%rbx),%rdi
mov    %r14,%rsi
mov    $0x6,%edx
call   1030 <memcpy@plt>
lea    0x2a(%rbx),%rdi
mov    %r14,%rsi
mov    $0x6,%edx
call   1030 <memcpy@plt>
lea    0x30(%rbx),%rdi
mov    %r14,%rsi
mov    $0x6,%edx
call   1030 <memcpy@plt>
lea    0x36(%rbx),%rdi
mov    %r14,%rsi
mov    $0x6,%edx
call   1030 <memcpy@plt>
lea    0x3c(%rbx),%rdi
mov    %r14,%rsi
mov    $0x6,%edx
call   1030 <memcpy@plt>
lea    0x42(%rbx),%rdi
mov    %r14,%rsi
mov    $0x6,%edx
call   1030 <memcpy@plt>
lea    0x48(%rbx),%rdi
mov    %r14,%rsi
mov    $0x6,%edx
call   1030 <memcpy@plt>
lea    0x4e(%rbx),%rdi
mov    %r14,%rsi
mov    $0x6,%edx
call   1030 <memcpy@plt>
lea    0x54(%rbx),%rdi
mov    %r14,%rsi
mov    $0x6,%edx
call   1030 <memcpy@plt>
lea    0x5a(%rbx),%rdi
mov    %r14,%rsi
mov    $0x6,%edx
call   1030 <memcpy@plt>
add    $0x60,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x6,%edx
call   1030 <memcpy@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @createMagicPacket(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca [6 x i8]
store i8* %0, i8** %3
store i32* %1, i32** %4
store i32 0, i32* %5
br label %7
7: ; preds = %24, %2
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 6
br i1 %9, label %10, label %27
10: ; preds = %7
%11 = load i8*, i8** %3
%12 = load i32, i32* %5
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
store i8 -1, i8* %14
%15 = load i32*, i32** %4
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i32, i32* %15, i64 %17
%19 = load i32, i32* %18
%20 = trunc i32 %19 to i8
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 %22
store i8 %20, i8* %23
br label %24
24: ; preds = %10
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 1
store i32 %26, i32* %5
br label %7
27: ; preds = %7
store i32 1, i32* %5
br label %28
28: ; preds = %39, %27
%29 = load i32, i32* %5
%30 = icmp sle i32 %29, 16
br i1 %30, label %31, label %42
31: ; preds = %28
%32 = load i8*, i8** %3
%33 = load i32, i32* %5
%34 = mul nsw i32 %33, 6
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %32, i64 %35
%37 = bitcast [6 x i8]* %6 to i8**
%38 = call i32 @memcpy(i8* %36, i8** %37, i32 6)
br label %39
39: ; preds = %31
%40 = load i32, i32* %5
%41 = add nsw i32 %40, 1
store i32 %41, i32* %5
br label %28
42: ; preds = %28
ret void
}

LLVM IR (-O2):
define void @createMagicPacket(i8* %0, i32* nocapture %1) {
%3 = alloca [6 x i8]
%4 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
store i8 -1, i8* %0
%5 = load i32, i32* %1
%6 = trunc i32 %5 to i8
store i8 %6, i8* %4
%7 = getelementptr inbounds i8, i8* %0, i64 1
store i8 -1, i8* %7
%8 = getelementptr inbounds i32, i32* %1, i64 1
%9 = load i32, i32* %8
%10 = trunc i32 %9 to i8
%11 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 1
store i8 %10, i8* %11
%12 = getelementptr inbounds i8, i8* %0, i64 2
store i8 -1, i8* %12
%13 = getelementptr inbounds i32, i32* %1, i64 2
%14 = load i32, i32* %13
%15 = trunc i32 %14 to i8
%16 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 2
store i8 %15, i8* %16
%17 = getelementptr inbounds i8, i8* %0, i64 3
store i8 -1, i8* %17
%18 = getelementptr inbounds i32, i32* %1, i64 3
%19 = load i32, i32* %18
%20 = trunc i32 %19 to i8
%21 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 3
store i8 %20, i8* %21
%22 = getelementptr inbounds i8, i8* %0, i64 4
store i8 -1, i8* %22
%23 = getelementptr inbounds i32, i32* %1, i64 4
%24 = load i32, i32* %23
%25 = trunc i32 %24 to i8
%26 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 4
store i8 %25, i8* %26
%27 = getelementptr inbounds i8, i8* %0, i64 5
store i8 -1, i8* %27
%28 = getelementptr inbounds i32, i32* %1, i64 5
%29 = load i32, i32* %28
%30 = trunc i32 %29 to i8
%31 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 5
store i8 %30, i8* %31
%32 = bitcast [6 x i8]* %3 to i8**
%33 = getelementptr inbounds i8, i8* %0, i64 6
%34 = call i32 @memcpy(i8* %33, i8** %32, i32 6)
%35 = getelementptr inbounds i8, i8* %0, i64 12
%36 = call i32 @memcpy(i8* %35, i8** %32, i32 6)
%37 = getelementptr inbounds i8, i8* %0, i64 18
%38 = call i32 @memcpy(i8* %37, i8** %32, i32 6)
%39 = getelementptr inbounds i8, i8* %0, i64 24
%40 = call i32 @memcpy(i8* %39, i8** %32, i32 6)
%41 = getelementptr inbounds i8, i8* %0, i64 30
%42 = call i32 @memcpy(i8* %41, i8** %32, i32 6)
%43 = getelementptr inbounds i8, i8* %0, i64 36
%44 = call i32 @memcpy(i8* %43, i8** %32, i32 6)
%45 = getelementptr inbounds i8, i8* %0, i64 42
%46 = call i32 @memcpy(i8* %45, i8** %32, i32 6)
%47 = getelementptr inbounds i8, i8* %0, i64 48
%48 = call i32 @memcpy(i8* %47, i8** %32, i32 6)
%49 = getelementptr inbounds i8, i8* %0, i64 54
%50 = call i32 @memcpy(i8* %49, i8** %32, i32 6)
%51 = getelementptr inbounds i8, i8* %0, i64 60
%52 = call i32 @memcpy(i8* %51, i8** %32, i32 6)
%53 = getelementptr inbounds i8, i8* %0, i64 66
%54 = call i32 @memcpy(i8* %53, i8** %32, i32 6)
%55 = getelementptr inbounds i8, i8* %0, i64 72
%56 = call i32 @memcpy(i8* %55, i8** %32, i32 6)
%57 = getelementptr inbounds i8, i8* %0, i64 78
%58 = call i32 @memcpy(i8* %57, i8** %32, i32 6)
%59 = getelementptr inbounds i8, i8* %0, i64 84
%60 = call i32 @memcpy(i8* %59, i8** %32, i32 6)
%61 = getelementptr inbounds i8, i8* %0, i64 90
%62 = call i32 @memcpy(i8* %61, i8** %32, i32 6)
%63 = getelementptr inbounds i8, i8* %0, i64 96
%64 = call i32 @memcpy(i8* %63, i8** %32, i32 6)
ret void
}