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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x12345678,-0x8(%rbp)
movl   $0xfedcba98,-0xc(%rbp)
mov    $0x9000,%eax
mov    %rax,-0x18(%rbp)
lea    0xeb3(%rip),%rdi
call   1030 <myputs@plt>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
lea    0xee6(%rip),%rdi
mov    $0xfffffffe,%esi
movswl %ax,%edx
call   1040 <test@plt>
mov    -0x18(%rbp),%rax
movzbl (%rax),%eax
lea    0xed0(%rip),%rdi
mov    $0xfe,%esi
movswl %ax,%edx
call   1040 <test@plt>
mov    -0x18(%rbp),%rax
lea    0xebd(%rip),%rdi
mov    $0xfffffedc,%esi
movswl (%rax),%edx
call   1040 <test@plt>
mov    -0x18(%rbp),%rax
lea    0xeaa(%rip),%rdi
mov    $0xfedc,%esi
movswl (%rax),%edx
call   1040 <test@plt>
lea    0xe9b(%rip),%rdi
call   1030 <myputs@plt>
mov    -0x18(%rbp),%rax
movb   $0x33,0x3(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
lea    0xe90(%rip),%rdi
mov    $0x12345633,%esi
movswl %ax,%edx
call   1040 <test@plt>
mov    -0x18(%rbp),%rax
movw   $0x1111,0x2(%rax)
mov    -0x18(%rbp),%rax
lea    0xe72(%rip),%rdi
mov    $0xfedc1111,%esi
movswl (%rax),%edx
call   1040 <test@plt>
lea    0xe62(%rip),%rdi
call   1030 <myputs@plt>
jmp    1214 <main+0xf4>

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
call   1030 <myputs@plt>
movsbl 0x9000,%edx
lea    0xf0a(%rip),%rdi
mov    $0xfffffffe,%esi
call   1040 <test@plt>
movzbl 0x9000,%edx
lea    0xef6(%rip),%rdi
mov    $0xfe,%esi
call   1040 <test@plt>
movswl 0x9000,%edx
lea    0xee2(%rip),%rdi
mov    $0xfffffedc,%esi
call   1040 <test@plt>
movswl 0x9000,%edx
lea    0xece(%rip),%rdi
mov    $0xfedc,%esi
call   1040 <test@plt>
lea    0xec2(%rip),%rdi
call   1030 <myputs@plt>
movb   $0x33,0x9003
33
movswl 0x9000,%edx
lea    0xeb5(%rip),%rdi
mov    $0x12345633,%esi
call   1040 <test@plt>
movw   $0x1111,0x9002
movswl 0x9000,%edx
lea    0xe96(%rip),%rdi
mov    $0xfedc1111,%esi
call   1040 <test@plt>
lea    0xe89(%rip),%rdi
call   1030 <myputs@plt>
nopl   (%rax)
jmp    11f0 <main+0xd0>

LLVM IR (-O0):
@.str = [70 x i8] c"\0ABegin load and store tests. The following equalities should match:\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"
@.str.8 = [19 x i8] c"That's it folks!\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32*
store i32 0, i32* %1
store i32 305419896, i32* %2
store i32 -19088744, i32* %3
store i32* inttoptr (i64 36864 to i32*), i32** %4
%5 = call i32 @myputs(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str, i64 0, i64 0))
%6 = load i32*, i32** %4
%7 = bitcast i32* %6 to i8*
%8 = load i8, i8* %7
%9 = sext i8 %8 to i16
%10 = call i32 @test(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 -2, i16 signext %9)
%11 = load i32*, i32** %4
%12 = bitcast i32* %11 to i8*
%13 = load i8, i8* %12
%14 = zext i8 %13 to i16
%15 = call i32 @test(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 254, i16 signext %14)
%16 = load i32*, i32** %4
%17 = bitcast i32* %16 to i16*
%18 = load i16, i16* %17
%19 = call i32 @test(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 -292, i16 signext %18)
%20 = load i32*, i32** %4
%21 = bitcast i32* %20 to i16*
%22 = load i16, i16* %21
%23 = call i32 @test(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 65244, i16 signext %22)
%24 = call i32 @myputs(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%25 = load i32*, i32** %4
%26 = bitcast i32* %25 to i8*
%27 = getelementptr inbounds i8, i8* %26, i64 3
store i8 51, i8* %27
%28 = load i32*, i32** %4
%29 = load i32, i32* %28
%30 = trunc i32 %29 to i16
%31 = call i32 @test(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 305419827, i16 signext %30)
%32 = load i32*, i32** %4
%33 = bitcast i32* %32 to i16*
%34 = getelementptr inbounds i16, i16* %33, i64 1
store i16 4369, i16* %34
%35 = load i32*, i32** %4
%36 = bitcast i32* %35 to i16*
%37 = load i16, i16* %36
%38 = call i32 @test(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 -19132143, i16 signext %37)
%39 = call i32 @myputs(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0))
br label %40
40: ; preds = %40, %0
br label %40
}

LLVM IR (-O2):
@.str = [70 x i8] c"\0ABegin load and store tests. The following equalities should match:\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"
@.str.8 = [19 x i8] c"That's it folks!\0A\0A\00"
define i32 @main() {
%1 = tail call i32 @myputs(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str, i64 0, i64 0))
%2 = load i8, i8* inttoptr (i64 36864 to i8*)
%3 = sext i8 %2 to i16
%4 = tail call i32 @test(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 -2, i16 signext %3)
%5 = load i8, i8* inttoptr (i64 36864 to i8*)
%6 = zext i8 %5 to i16
%7 = tail call i32 @test(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 254, i16 signext %6)
%8 = load i16, i16* inttoptr (i64 36864 to i16*)
%9 = tail call i32 @test(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 -292, i16 signext %8)
%10 = load i16, i16* inttoptr (i64 36864 to i16*)
%11 = tail call i32 @test(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 65244, i16 signext %10)
%12 = tail call i32 @myputs(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
store i8 51, i8* inttoptr (i64 36867 to i8*)
%13 = load i32, i32* inttoptr (i64 36864 to i32*)
%14 = trunc i32 %13 to i16
%15 = tail call i32 @test(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 305419827, i16 signext %14)
store i16 4369, i16* inttoptr (i64 36866 to i16*)
%16 = load i16, i16* inttoptr (i64 36864 to i16*)
%17 = tail call i32 @test(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 -19132143, i16 signext %16)
%18 = tail call i32 @myputs(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0))
br label %19
19: ; preds = %19, %0
br label %19
}