#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*/ write_ZIGBEE_short(int, short);
void set_long_address(short int *address) {
  short int i = 0;
  for (i = 0; i < 8; i++) {
    write_ZIGBEE_short(0x05 + i, address[i]);
  }
}


x86 assembly (clang, -O0):
<set_long_address>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movw   $0x0,-0xa(%rbp)
movw   $0x0,-0xa(%rbp)
movswl -0xa(%rbp),%eax
cmp    $0x8,%eax
jge    115f <set_long_address+0x4f>
movswl -0xa(%rbp),%edi
add    $0x5,%edi
mov    -0x8(%rbp),%rax
movswq -0xa(%rbp),%rcx
movswl (%rax,%rcx,2),%esi
call   1030 <write_ZIGBEE_short@plt>
mov    -0xa(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0xa(%rbp)
jmp    1128 <set_long_address+0x18>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_long_address>:
push   %rbx
mov    %rdi,%rbx
movswl (%rdi),%esi
mov    $0x5,%edi
call   1030 <write_ZIGBEE_short@plt>
movswl 0x2(%rbx),%esi
mov    $0x6,%edi
call   1030 <write_ZIGBEE_short@plt>
movswl 0x4(%rbx),%esi
mov    $0x7,%edi
call   1030 <write_ZIGBEE_short@plt>
movswl 0x6(%rbx),%esi
mov    $0x8,%edi
call   1030 <write_ZIGBEE_short@plt>
movswl 0x8(%rbx),%esi
mov    $0x9,%edi
call   1030 <write_ZIGBEE_short@plt>
movswl 0xa(%rbx),%esi
mov    $0xa,%edi
call   1030 <write_ZIGBEE_short@plt>
movswl 0xc(%rbx),%esi
mov    $0xb,%edi
call   1030 <write_ZIGBEE_short@plt>
movswl 0xe(%rbx),%esi
mov    $0xc,%edi
pop    %rbx
jmp    1030 <write_ZIGBEE_short@plt>

LLVM IR (-O0):
define void @set_long_address(i16* %0) {
%2 = alloca i16*
%3 = alloca i16
store i16* %0, i16** %2
store i16 0, i16* %3
store i16 0, i16* %3
br label %4
4: ; preds = %18, %1
%5 = load i16, i16* %3
%6 = sext i16 %5 to i32
%7 = icmp slt i32 %6, 8
br i1 %7, label %8, label %21
8: ; preds = %4
%9 = load i16, i16* %3
%10 = sext i16 %9 to i32
%11 = add nsw i32 5, %10
%12 = load i16*, i16** %2
%13 = load i16, i16* %3
%14 = sext i16 %13 to i64
%15 = getelementptr inbounds i16, i16* %12, i64 %14
%16 = load i16, i16* %15
%17 = call i32 @write_ZIGBEE_short(i32 %11, i16 signext %16)
br label %18
18: ; preds = %8
%19 = load i16, i16* %3
%20 = add i16 %19, 1
store i16 %20, i16* %3
br label %4
21: ; preds = %4
ret void
}

LLVM IR (-O2):
define void @set_long_address(i16* nocapture %0) {
%2 = load i16, i16* %0
%3 = tail call i32 @write_ZIGBEE_short(i32 5, i16 signext %2)
%4 = getelementptr inbounds i16, i16* %0, i64 1
%5 = load i16, i16* %4
%6 = tail call i32 @write_ZIGBEE_short(i32 6, i16 signext %5)
%7 = getelementptr inbounds i16, i16* %0, i64 2
%8 = load i16, i16* %7
%9 = tail call i32 @write_ZIGBEE_short(i32 7, i16 signext %8)
%10 = getelementptr inbounds i16, i16* %0, i64 3
%11 = load i16, i16* %10
%12 = tail call i32 @write_ZIGBEE_short(i32 8, i16 signext %11)
%13 = getelementptr inbounds i16, i16* %0, i64 4
%14 = load i16, i16* %13
%15 = tail call i32 @write_ZIGBEE_short(i32 9, i16 signext %14)
%16 = getelementptr inbounds i16, i16* %0, i64 5
%17 = load i16, i16* %16
%18 = tail call i32 @write_ZIGBEE_short(i32 10, i16 signext %17)
%19 = getelementptr inbounds i16, i16* %0, i64 6
%20 = load i16, i16* %19
%21 = tail call i32 @write_ZIGBEE_short(i32 11, i16 signext %20)
%22 = getelementptr inbounds i16, i16* %0, i64 7
%23 = load i16, i16* %22
%24 = tail call i32 @write_ZIGBEE_short(i32 12, i16 signext %23)
ret void
}