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

/* Variables and functions */
int getUnicastChannelIndex(int, unsigned char *, int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int channels = 129;
  unsigned char MACAddr[8] = {0x00, 0x13, 0x50, 0x04, 0x00, 0x00, 0x05, 0xf8};
  unsigned char MACAddr1[8] = {0x00, 0x13, 0x50, 0x04, 0x00, 0x00, 0x06, 0x02};
  int getIndex;
  uint16_t slot;
  printf("unicast\n\r");
  for (slot = 10738; slot <= 10747; slot++) {
    getIndex = getUnicastChannelIndex(slot, MACAddr, channels);
    printf("slot[%d] = %d\n\r", slot, getIndex);
  }
  printf("unicast1\n\r");
  for (slot = 16446; slot <= 16455; slot++) {
    getIndex = getUnicastChannelIndex(slot, MACAddr1, channels);
    printf("slot[%d] = %d\n\r", slot, getIndex);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x81,-0x8(%rbp)
mov    0xec3(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xec0(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x29f2,-0x20(%rbp)
cmpl   $0x29fb,-0x20(%rbp)
jg     11a2 <main+0x82>
mov    -0x20(%rbp),%edi
lea    -0x10(%rbp),%rsi
mov    -0x8(%rbp),%edx
call   1040 <getUnicastChannelIndex@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1161 <main+0x41>
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x403e,-0x20(%rbp)
cmpl   $0x4047,-0x20(%rbp)
jg     11f8 <main+0xd8>
mov    -0x20(%rbp),%edi
lea    -0x18(%rbp),%rsi
mov    -0x8(%rbp),%edx
call   1040 <getUnicastChannelIndex@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11b7 <main+0x97>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movabs $0xf805000004501300,%rax
mov    %rax,0x10(%rsp)
movabs $0x206000004501300,%rax
mov    %rax,0x8(%rsp)
lea    0xeb4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x10(%rsp),%rbx
mov    $0x29f2,%edi
mov    %rbx,%rsi
mov    $0x81,%edx
call   1040 <getUnicastChannelIndex@plt>
lea    0xe99(%rip),%r14
mov    %r14,%rdi
mov    $0x29f2,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x29f3,%edi
mov    %rbx,%rsi
mov    $0x81,%edx
call   1040 <getUnicastChannelIndex@plt>
mov    %r14,%rdi
mov    $0x29f3,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x29f4,%edi
mov    %rbx,%rsi
mov    $0x81,%edx
call   1040 <getUnicastChannelIndex@plt>
mov    %r14,%rdi
mov    $0x29f4,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x29f5,%edi
mov    %rbx,%rsi
mov    $0x81,%edx
call   1040 <getUnicastChannelIndex@plt>
mov    %r14,%rdi
mov    $0x29f5,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x29f6,%edi
mov    %rbx,%rsi
mov    $0x81,%edx
call   1040 <getUnicastChannelIndex@plt>
mov    %r14,%rdi
mov    $0x29f6,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x29f7,%edi
mov    %rbx,%rsi
mov    $0x81,%edx
call   1040 <getUnicastChannelIndex@plt>
mov    %r14,%rdi
mov    $0x29f7,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x29f8,%edi
mov    %rbx,%rsi
mov    $0x81,%edx
call   1040 <getUnicastChannelIndex@plt>
mov    %r14,%rdi
mov    $0x29f8,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x29f9,%edi
mov    %rbx,%rsi
mov    $0x81,%edx
call   1040 <getUnicastChannelIndex@plt>
mov    %r14,%rdi
mov    $0x29f9,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x29fa,%edi
mov    %rbx,%rsi
mov    $0x81,%edx
call   1040 <getUnicastChannelIndex@plt>
mov    %r14,%rdi
mov    $0x29fa,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x29fb,%edi
mov    %rbx,%rsi
mov    $0x81,%edx
call   1040 <getUnicastChannelIndex@plt>
mov    %r14,%rdi
mov    $0x29fb,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xd56(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x8(%rsp),%rbx
mov    $0x403e,%edi
mov    %rbx,%rsi
mov    $0x81,%edx
call   1040 <getUnicastChannelIndex@plt>
mov    %r14,%rdi
mov    $0x403e,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x403f,%edi
mov    %rbx,%rsi
mov    $0x81,%edx
call   1040 <getUnicastChannelIndex@plt>
mov    %r14,%rdi
mov    $0x403f,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x4040,%edi
mov    %rbx,%rsi
mov    $0x81,%edx
call   1040 <getUnicastChannelIndex@plt>
mov    %r14,%rdi
mov    $0x4040,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x4041,%edi
mov    %rbx,%rsi
mov    $0x81,%edx
call   1040 <getUnicastChannelIndex@plt>
mov    %r14,%rdi
mov    $0x4041,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x4042,%edi
mov    %rbx,%rsi
mov    $0x81,%edx
call   1040 <getUnicastChannelIndex@plt>
mov    %r14,%rdi
mov    $0x4042,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x4043,%edi
mov    %rbx,%rsi
mov    $0x81,%edx
call   1040 <getUnicastChannelIndex@plt>
mov    %r14,%rdi
mov    $0x4043,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x4044,%edi
mov    %rbx,%rsi
mov    $0x81,%edx
call   1040 <getUnicastChannelIndex@plt>
mov    %r14,%rdi
mov    $0x4044,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x4045,%edi
mov    %rbx,%rsi
mov    $0x81,%edx
call   1040 <getUnicastChannelIndex@plt>
mov    %r14,%rdi
mov    $0x4045,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x4046,%edi
mov    %rbx,%rsi
mov    $0x81,%edx
call   1040 <getUnicastChannelIndex@plt>
mov    %r14,%rdi
mov    $0x4046,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x4047,%edi
mov    %rbx,%rsi
mov    $0x81,%edx
call   1040 <getUnicastChannelIndex@plt>
mov    %r14,%rdi
mov    $0x4047,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.MACAddr = [8 x i8] c"\00\13P\04\00\00\05\F8"
@__const.main.MACAddr1 = [8 x i8] c"\00\13P\04\00\00\06\02"
@.str = [10 x i8] c"unicast\0A\0D\00"
@.str.1 = [16 x i8] c"slot[%d] = %d\0A\0D\00"
@.str.2 = [11 x i8] c"unicast1\0A\0D\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [8 x i8]
%4 = alloca [8 x i8]
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 129, i32* %2
%7 = bitcast [8 x i8]* %3 to i8*
%8 = bitcast [8 x i8]* %4 to i8*
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
store i32 10738, i32* %6
br label %10
10: ; preds = %21, %0
%11 = load i32, i32* %6
%12 = icmp sle i32 %11, 10747
br i1 %12, label %13, label %24
13: ; preds = %10
%14 = load i32, i32* %6
%15 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%16 = load i32, i32* %2
%17 = call i32 @getUnicastChannelIndex(i32 %14, i8* %15, i32 %16)
store i32 %17, i32* %5
%18 = load i32, i32* %6
%19 = load i32, i32* %5
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %18, i32 %19)
br label %21
21: ; preds = %13
%22 = load i32, i32* %6
%23 = add nsw i32 %22, 1
store i32 %23, i32* %6
br label %10
24: ; preds = %10
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
store i32 16446, i32* %6
br label %26
26: ; preds = %37, %24
%27 = load i32, i32* %6
%28 = icmp sle i32 %27, 16455
br i1 %28, label %29, label %40
29: ; preds = %26
%30 = load i32, i32* %6
%31 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 0
%32 = load i32, i32* %2
%33 = call i32 @getUnicastChannelIndex(i32 %30, i8* %31, i32 %32)
store i32 %33, i32* %5
%34 = load i32, i32* %6
%35 = load i32, i32* %5
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %34, i32 %35)
br label %37
37: ; preds = %29
%38 = load i32, i32* %6
%39 = add nsw i32 %38, 1
store i32 %39, i32* %6
br label %26
40: ; preds = %26
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"unicast\0A\0D\00"
@.str.1 = [16 x i8] c"slot[%d] = %d\0A\0D\00"
@.str.2 = [11 x i8] c"unicast1\0A\0D\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca i64
%3 = bitcast i64* %1 to i8*
store i64 -575053377347513600, i64* %1
%4 = bitcast i64* %2 to i8*
store i64 145804038008476416, i64* %2
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @getUnicastChannelIndex(i32 10738, i8* %3, i32 129)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 10738, i32 %6)
%8 = call i32 @getUnicastChannelIndex(i32 10739, i8* %3, i32 129)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 10739, i32 %8)
%10 = call i32 @getUnicastChannelIndex(i32 10740, i8* %3, i32 129)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 10740, i32 %10)
%12 = call i32 @getUnicastChannelIndex(i32 10741, i8* %3, i32 129)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 10741, i32 %12)
%14 = call i32 @getUnicastChannelIndex(i32 10742, i8* %3, i32 129)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 10742, i32 %14)
%16 = call i32 @getUnicastChannelIndex(i32 10743, i8* %3, i32 129)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 10743, i32 %16)
%18 = call i32 @getUnicastChannelIndex(i32 10744, i8* %3, i32 129)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 10744, i32 %18)
%20 = call i32 @getUnicastChannelIndex(i32 10745, i8* %3, i32 129)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 10745, i32 %20)
%22 = call i32 @getUnicastChannelIndex(i32 10746, i8* %3, i32 129)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 10746, i32 %22)
%24 = call i32 @getUnicastChannelIndex(i32 10747, i8* %3, i32 129)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 10747, i32 %24)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%27 = call i32 @getUnicastChannelIndex(i32 16446, i8* %4, i32 129)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 16446, i32 %27)
%29 = call i32 @getUnicastChannelIndex(i32 16447, i8* %4, i32 129)
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 16447, i32 %29)
%31 = call i32 @getUnicastChannelIndex(i32 16448, i8* %4, i32 129)
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 16448, i32 %31)
%33 = call i32 @getUnicastChannelIndex(i32 16449, i8* %4, i32 129)
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 16449, i32 %33)
%35 = call i32 @getUnicastChannelIndex(i32 16450, i8* %4, i32 129)
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 16450, i32 %35)
%37 = call i32 @getUnicastChannelIndex(i32 16451, i8* %4, i32 129)
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 16451, i32 %37)
%39 = call i32 @getUnicastChannelIndex(i32 16452, i8* %4, i32 129)
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 16452, i32 %39)
%41 = call i32 @getUnicastChannelIndex(i32 16453, i8* %4, i32 129)
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 16453, i32 %41)
%43 = call i32 @getUnicastChannelIndex(i32 16454, i8* %4, i32 129)
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 16454, i32 %43)
%45 = call i32 @getUnicastChannelIndex(i32 16455, i8* %4, i32 129)
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 16455, i32 %45)
ret i32 0
}