#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*/ uint8_t;
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ big_to_little32(int *, int);
int /*<<< orphan*/ little_to_big32(int *, int);
int /*<<< orphan*/ print_memory(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ printf(char *);
void test_data1(uint8_t *data, uint32_t size) {
  printf("\ntest_data_1 :\n  ");
  assert(size % sizeof(uint32_t) == 0);
  uint32_t *uint32_ptr = (uint32_t *)data;
  print_memory(data, size);
  printf("\n  ");
  big_to_little32(uint32_ptr, size);
  print_memory(data, size);
  printf("\n  ");
  little_to_big32(uint32_ptr, size);
  print_memory(data, size);
  printf("\n  ");
}


x86 assembly (clang, -O0):
<test_data1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0xe9a(%rip),%rdi
call   1040 <printf@plt>
movslq -0xc(%rbp),%rax
and    $0x3,%rax
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1070 <print_memory@plt>
lea    0xe6f(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <big_to_little32@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1070 <print_memory@plt>
lea    0xe4b(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1060 <little_to_big32@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1070 <print_memory@plt>
lea    0xe27(%rip),%rdi
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_data1>:
push   %r15
push   %r14
push   %rbx
mov    %esi,%ebx
mov    %rdi,%r14
lea    0xe9f(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
test   $0x3,%bl
sete   %dil
call   1050 <assert@plt>
mov    %r14,%rdi
mov    %ebx,%esi
call   1070 <print_memory@plt>
lea    0xe89(%rip),%r15
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <big_to_little32@plt>
mov    %r14,%rdi
mov    %ebx,%esi
call   1070 <print_memory@plt>
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %ebx,%esi
call   1060 <little_to_big32@plt>
mov    %r14,%rdi
mov    %ebx,%esi
call   1070 <print_memory@plt>
mov    %r15,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"\0Atest_data_1 :\0A \00"
@.str.1 = [4 x i8] c"\0A \00"
define void @test_data1(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32*
store i32* %0, i32** %3
store i32 %1, i32* %4
%6 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* %4
%8 = sext i32 %7 to i64
%9 = urem i64 %8, 4
%10 = icmp eq i64 %9, 0
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = load i32*, i32** %3
store i32* %13, i32** %5
%14 = load i32*, i32** %3
%15 = load i32, i32* %4
%16 = call i32 @print_memory(i32* %14, i32 %15)
%17 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%18 = load i32*, i32** %5
%19 = load i32, i32* %4
%20 = call i32 @big_to_little32(i32* %18, i32 %19)
%21 = load i32*, i32** %3
%22 = load i32, i32* %4
%23 = call i32 @print_memory(i32* %21, i32 %22)
%24 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%25 = load i32*, i32** %5
%26 = load i32, i32* %4
%27 = call i32 @little_to_big32(i32* %25, i32 %26)
%28 = load i32*, i32** %3
%29 = load i32, i32* %4
%30 = call i32 @print_memory(i32* %28, i32 %29)
%31 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"\0Atest_data_1 :\0A \00"
@.str.1 = [4 x i8] c"\0A \00"
define void @test_data1(i32* %0, i32 %1) {
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%4 = and i32 %1, 3
%5 = icmp eq i32 %4, 0
%6 = zext i1 %5 to i32
%7 = tail call i32 @assert(i32 %6)
%8 = tail call i32 @print_memory(i32* %0, i32 %1)
%9 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%10 = tail call i32 @big_to_little32(i32* %0, i32 %1)
%11 = tail call i32 @print_memory(i32* %0, i32 %1)
%12 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%13 = tail call i32 @little_to_big32(i32* %0, i32 %1)
%14 = tail call i32 @print_memory(i32* %0, i32 %1)
%15 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
ret void
}