#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*/ byteSwap(short *, int, int);
int /*<<< orphan*/ printf(char *, ...);
void testUtility() {
  int i, n;
  short int b[] = {4, 11, 8, 10, 6, 8};
  n = 6;
  printf("\nUtilities\n");
  printf("Byte swap\n");
  byteSwap(b, n, 2);
  for (i = 0; i < n; i++) {
    printf("%d ", b[i]);
  }
  printf("\n");
  byteSwap(b, n, 2);
  for (i = 0; i < n; i++) {
    printf("%d ", b[i]);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<testUtility>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xed1(%rip),%rax
mov    %rax,-0x14(%rbp)
mov    0xecf(%rip),%eax
mov    %eax,-0xc(%rbp)
movl   $0x6,-0x8(%rbp)
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x14(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    $0x2,%edx
call   1040 <byteSwap@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11a8 <testUtility+0x88>
movslq -0x4(%rbp),%rax
movswl -0x14(%rbp,%rax,2),%esi
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1177 <testUtility+0x57>
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x14(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    $0x2,%edx
call   1040 <byteSwap@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11ff <testUtility+0xdf>
movslq -0x4(%rbp),%rax
movswl -0x14(%rbp,%rax,2),%esi
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11ce <testUtility+0xae>
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testUtility>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    0xebb(%rip),%eax
mov    %eax,0x10(%rsp)
mov    0xea8(%rip),%rax
mov    %rax,0x8(%rsp)
lea    0xeac(%rip),%rdi
call   1040 <puts@plt>
lea    0xeab(%rip),%rdi
call   1040 <puts@plt>
lea    0x8(%rsp),%r14
mov    %r14,%rdi
mov    $0x6,%esi
mov    $0x2,%edx
call   1060 <byteSwap@plt>
movswl 0x8(%rsp),%esi
lea    0xe74(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movswl 0xa(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movswl 0xc(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movswl 0xe(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movswl 0x10(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movswl 0x12(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
mov    $0x6,%esi
mov    $0x2,%edx
call   1060 <byteSwap@plt>
movswl 0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movswl 0xa(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movswl 0xc(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movswl 0xe(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movswl 0x10(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movswl 0x12(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.testUtility.b = [6 x i16] [i16 4, i16 11, i16 8, i16 10, i16 6, i16 8]
@.str = [12 x i8] c"\0AUtilities\0A\00"
@.str.1 = [11 x i8] c"Byte swap\0A\00"
@.str.2 = [4 x i8] c"%d \00"
@.str.3 = [2 x i8] c"\0A\00"
define void @testUtility() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [6 x i16]
%4 = bitcast [6 x i16]* %3 to i8*
store i32 6, i32* %2
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%7 = getelementptr inbounds [6 x i16], [6 x i16]* %3, i64 0, i64 0
%8 = load i32, i32* %2
%9 = call i32 @byteSwap(i16* %7, i32 %8, i32 2)
store i32 0, i32* %1
br label %10
10: ; preds = %21, %0
%11 = load i32, i32* %1
%12 = load i32, i32* %2
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %24
14: ; preds = %10
%15 = load i32, i32* %1
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [6 x i16], [6 x i16]* %3, i64 0, i64 %16
%18 = load i16, i16* %17
%19 = sext i16 %18 to i32
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %19)
br label %21
21: ; preds = %14
%22 = load i32, i32* %1
%23 = add nsw i32 %22, 1
store i32 %23, i32* %1
br label %10
24: ; preds = %10
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%26 = getelementptr inbounds [6 x i16], [6 x i16]* %3, i64 0, i64 0
%27 = load i32, i32* %2
%28 = call i32 @byteSwap(i16* %26, i32 %27, i32 2)
store i32 0, i32* %1
br label %29
29: ; preds = %40, %24
%30 = load i32, i32* %1
%31 = load i32, i32* %2
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %43
33: ; preds = %29
%34 = load i32, i32* %1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [6 x i16], [6 x i16]* %3, i64 0, i64 %35
%37 = load i16, i16* %36
%38 = sext i16 %37 to i32
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %38)
br label %40
40: ; preds = %33
%41 = load i32, i32* %1
%42 = add nsw i32 %41, 1
store i32 %42, i32* %1
br label %29
43: ; preds = %29
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@__const.testUtility.b = [6 x i16] [i16 4, i16 11, i16 8, i16 10, i16 6, i16 8]
@.str.2 = [4 x i8] c"%d \00"
@str = [11 x i8] c"\0AUtilities\00"
@str.4 = [10 x i8] c"Byte swap\00"
define void @testUtility() {
%1 = alloca [6 x i16]
%2 = bitcast [6 x i16]* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.4, i64 0, i64 0))
%5 = getelementptr inbounds [6 x i16], [6 x i16]* %1, i64 0, i64 0
%6 = call i32 @byteSwap(i16* %5, i32 6, i32 2)
%7 = load i16, i16* %5
%8 = sext i16 %7 to i32
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %8)
%10 = getelementptr inbounds [6 x i16], [6 x i16]* %1, i64 0, i64 1
%11 = load i16, i16* %10
%12 = sext i16 %11 to i32
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%14 = getelementptr inbounds [6 x i16], [6 x i16]* %1, i64 0, i64 2
%15 = load i16, i16* %14
%16 = sext i16 %15 to i32
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%18 = getelementptr inbounds [6 x i16], [6 x i16]* %1, i64 0, i64 3
%19 = load i16, i16* %18
%20 = sext i16 %19 to i32
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %20)
%22 = getelementptr inbounds [6 x i16], [6 x i16]* %1, i64 0, i64 4
%23 = load i16, i16* %22
%24 = sext i16 %23 to i32
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %24)
%26 = getelementptr inbounds [6 x i16], [6 x i16]* %1, i64 0, i64 5
%27 = load i16, i16* %26
%28 = sext i16 %27 to i32
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %28)
%30 = call i32 @putchar(i32 10)
%31 = call i32 @byteSwap(i16* %5, i32 6, i32 2)
%32 = load i16, i16* %5
%33 = sext i16 %32 to i32
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %33)
%35 = load i16, i16* %10
%36 = sext i16 %35 to i32
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %36)
%38 = load i16, i16* %14
%39 = sext i16 %38 to i32
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %39)
%41 = load i16, i16* %18
%42 = sext i16 %41 to i32
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %42)
%44 = load i16, i16* %22
%45 = sext i16 %44 to i32
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %45)
%47 = load i16, i16* %26
%48 = sext i16 %47 to i32
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %48)
%50 = call i32 @putchar(i32 10)
ret void
}