#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 /*<<< orphan*/ int16_t;

/* Variables and functions */
int /*<<< orphan*/ mem_swap(int /*<<< orphan*/ *);
void byteswap_ata_data(int16_t *buf) {
  int i;
  for (i = 0; i < 10; i++)
    mem_swap(buf + i);
  for (i = 20; i < 23; i++)
    mem_swap(buf + i);
  for (i = 47; i < 255; i++)
    mem_swap(buf + i);
}


x86 assembly (clang, -O0):
<byteswap_ata_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jge    114f <byteswap_ata_data+0x3f>
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
call   1030 <mem_swap@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <byteswap_ata_data+0x13>
movl   $0x14,-0xc(%rbp)
cmpl   $0x17,-0xc(%rbp)
jge    1182 <byteswap_ata_data+0x72>
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
call   1030 <mem_swap@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1156 <byteswap_ata_data+0x46>
movl   $0x2f,-0xc(%rbp)
cmpl   $0xff,-0xc(%rbp)
jge    11b8 <byteswap_ata_data+0xa8>
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
call   1030 <mem_swap@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1189 <byteswap_ata_data+0x79>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<byteswap_ata_data>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1030 <mem_swap@plt>
lea    0x4(%r14),%rdi
call   1030 <mem_swap@plt>
lea    0x8(%r14),%rdi
call   1030 <mem_swap@plt>
lea    0xc(%r14),%rdi
call   1030 <mem_swap@plt>
lea    0x10(%r14),%rdi
call   1030 <mem_swap@plt>
lea    0x14(%r14),%rdi
call   1030 <mem_swap@plt>
lea    0x18(%r14),%rdi
call   1030 <mem_swap@plt>
lea    0x1c(%r14),%rdi
call   1030 <mem_swap@plt>
lea    0x20(%r14),%rdi
call   1030 <mem_swap@plt>
lea    0x24(%r14),%rdi
call   1030 <mem_swap@plt>
lea    0x50(%r14),%rdi
call   1030 <mem_swap@plt>
lea    0x54(%r14),%rdi
call   1030 <mem_swap@plt>
lea    0x58(%r14),%rdi
call   1030 <mem_swap@plt>
mov    $0xbc,%ebx
nopl   (%rax)
lea    (%r14,%rbx,1),%rdi
call   1030 <mem_swap@plt>
add    $0x4,%rbx
cmp    $0x3fc,%rbx
jne    1190 <byteswap_ata_data+0x80>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define void @byteswap_ata_data(i32* %0) {
%2 = tail call i32 @mem_swap(i32* %0)
%3 = getelementptr inbounds i32, i32* %0, i64 1
%4 = tail call i32 @mem_swap(i32* %3)
%5 = getelementptr inbounds i32, i32* %0, i64 2
%6 = tail call i32 @mem_swap(i32* %5)
%7 = getelementptr inbounds i32, i32* %0, i64 3
%8 = tail call i32 @mem_swap(i32* %7)
%9 = getelementptr inbounds i32, i32* %0, i64 4
%10 = tail call i32 @mem_swap(i32* %9)
%11 = getelementptr inbounds i32, i32* %0, i64 5
%12 = tail call i32 @mem_swap(i32* %11)
%13 = getelementptr inbounds i32, i32* %0, i64 6
%14 = tail call i32 @mem_swap(i32* %13)
%15 = getelementptr inbounds i32, i32* %0, i64 7
%16 = tail call i32 @mem_swap(i32* %15)
%17 = getelementptr inbounds i32, i32* %0, i64 8
%18 = tail call i32 @mem_swap(i32* %17)
%19 = getelementptr inbounds i32, i32* %0, i64 9
%20 = tail call i32 @mem_swap(i32* %19)
%21 = getelementptr inbounds i32, i32* %0, i64 20
%22 = tail call i32 @mem_swap(i32* %21)
%23 = getelementptr inbounds i32, i32* %0, i64 21
%24 = tail call i32 @mem_swap(i32* %23)
%25 = getelementptr inbounds i32, i32* %0, i64 22
%26 = tail call i32 @mem_swap(i32* %25)
br label %27
27: ; preds = %1, %27
%28 = phi i64 [ 47, %1 ], [ %31, %27 ]
%29 = getelementptr inbounds i32, i32* %0, i64 %28
%30 = tail call i32 @mem_swap(i32* %29)
%31 = add nuw nsw i64 %28, 1
%32 = icmp eq i64 %31, 255
br i1 %32, label %33, label %27
33: ; preds = %27
ret void
}