#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*/ printf(char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ test(char *, int, unsigned int);
main() {
  unsigned a = 0x12345678;
  unsigned z = 0xFEDCBA98;
  unsigned *p;
  printf("Test load and store.  The following equalities should hold:\n");
  test("LB  ", 0xFFFFFFFE, *(signed char *)&z);
  test("LBU ", 0x000000FE, *(unsigned char *)&z);
  test("LH  ", 0xFFFFFEDC, *(signed short *)&z);
  test("LHU ", 0x0000FEDC, *(unsigned short *)&z);
  puts("\nStore tests:\n");
  ((char *)&a)[3] = 0x33;
  test("SB ", 0x12345633, a);
  ((short *)&z)[1] = 0x1111;
  test("SH ", 0xFEDC1111, z);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x12345678,-0x4(%rbp)
movl   $0xfedcba98,-0x8(%rbp)
lea    0xeb3(%rip),%rdi
call   1040 <printf@plt>
movsbl -0x8(%rbp),%edx
lea    0xee0(%rip),%rdi
mov    $0xfffffffe,%esi
call   1050 <test@plt>
movzbl -0x8(%rbp),%edx
lea    0xed0(%rip),%rdi
mov    $0xfe,%esi
call   1050 <test@plt>
movswl -0x8(%rbp),%edx
lea    0xec0(%rip),%rdi
mov    $0xfffffedc,%esi
call   1050 <test@plt>
movzwl -0x8(%rbp),%edx
lea    0xeb0(%rip),%rdi
mov    $0xfedc,%esi
call   1050 <test@plt>
lea    0xea4(%rip),%rdi
call   1030 <puts@plt>
movb   $0x33,-0x1(%rbp)
mov    -0x4(%rbp),%edx
lea    0xea0(%rip),%rdi
mov    $0x12345633,%esi
call   1050 <test@plt>
movw   $0x1111,-0x6(%rbp)
mov    -0x8(%rbp),%edx
lea    0xe8a(%rip),%rdi
mov    $0xfedc1111,%esi
call   1050 <test@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xf03(%rip),%rdi
call   1030 <puts@plt>
lea    0xecc(%rip),%rdi
mov    $0xfffffffe,%esi
mov    $0xffffff98,%edx
call   1040 <test@plt>
lea    0xebb(%rip),%rdi
mov    $0xfe,%esi
mov    $0x98,%edx
call   1040 <test@plt>
lea    0xeaa(%rip),%rdi
mov    $0xfffffedc,%esi
mov    $0xffffba98,%edx
call   1040 <test@plt>
lea    0xe99(%rip),%rdi
mov    $0xfedc,%esi
mov    $0xba98,%edx
call   1040 <test@plt>
lea    0xe88(%rip),%rdi
call   1030 <puts@plt>
lea    0xe8b(%rip),%rdi
mov    $0x12345633,%esi
mov    $0x33345678,%edx
call   1040 <test@plt>
lea    0xe79(%rip),%rdi
mov    $0xfedc1111,%esi
mov    $0x1111ba98,%edx
call   1040 <test@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [61 x i8] c"Test load and store. The following equalities should hold:\0A\00"
@.str.1 = [5 x i8] c"LB \00"
@.str.2 = [5 x i8] c"LBU \00"
@.str.3 = [5 x i8] c"LH \00"
@.str.4 = [5 x i8] c"LHU \00"
@.str.5 = [15 x i8] c"\0AStore tests:\0A\00"
@.str.6 = [4 x i8] c"SB \00"
@.str.7 = [4 x i8] c"SH \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
store i32 305419896, i32* %1
store i32 -19088744, i32* %2
%4 = call i32 @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0))
%5 = bitcast i32* %2 to i8*
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
%8 = call i32 @test(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 -2, i32 %7)
%9 = bitcast i32* %2 to i8*
%10 = load i8, i8* %9
%11 = zext i8 %10 to i32
%12 = call i32 @test(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 254, i32 %11)
%13 = bitcast i32* %2 to i16*
%14 = load i16, i16* %13
%15 = sext i16 %14 to i32
%16 = call i32 @test(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 -292, i32 %15)
%17 = bitcast i32* %2 to i16*
%18 = load i16, i16* %17
%19 = zext i16 %18 to i32
%20 = call i32 @test(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 65244, i32 %19)
%21 = call i32 @puts(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%22 = bitcast i32* %1 to i8*
%23 = getelementptr inbounds i8, i8* %22, i64 3
store i8 51, i8* %23
%24 = load i32, i32* %1
%25 = call i32 @test(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 305419827, i32 %24)
%26 = bitcast i32* %2 to i16*
%27 = getelementptr inbounds i16, i16* %26, i64 1
store i16 4369, i16* %27
%28 = load i32, i32* %2
%29 = call i32 @test(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 -19132143, i32 %28)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [5 x i8] c"LB \00"
@.str.2 = [5 x i8] c"LBU \00"
@.str.3 = [5 x i8] c"LH \00"
@.str.4 = [5 x i8] c"LHU \00"
@.str.5 = [15 x i8] c"\0AStore tests:\0A\00"
@.str.6 = [4 x i8] c"SB \00"
@.str.7 = [4 x i8] c"SH \00"
@str = [60 x i8] c"Test load and store. The following equalities should hold:\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @test(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 -2, i32 -104)
%3 = tail call i32 @test(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 254, i32 152)
%4 = tail call i32 @test(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 -292, i32 -17768)
%5 = tail call i32 @test(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 65244, i32 47768)
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%7 = tail call i32 @test(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 305419827, i32 859068024)
%8 = tail call i32 @test(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 -19132143, i32 286374552)
ret i32 0
}