#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 */
unsigned char SL11Read(unsigned char);
int /*<<< orphan*/ SL11Write(unsigned char, unsigned char);
int SL11HMemTest(void) {
  int errors = 0;
  int i;
  for (i = 0x40; i < 0xc0; i++)
    SL11Write((unsigned char)i, (unsigned char)i);
  for (i = 0x40; i < 0xc0; i++) {
    if ((unsigned char)i != SL11Read((unsigned char)i))
      errors++;
    SL11Write((unsigned char)i, (unsigned char)~i);
    if ((unsigned char)~i != SL11Read((unsigned char)i))
      errors++;
  }
  *((volatile unsigned char *)(((long unsigned int)(int)0xa0000000) |
                               (0x100C0000))) = (0x40);
  for (i = 0x40; i < 0xc0; i++)
    *((volatile unsigned char *)(((long unsigned int)(int)0xa0000000) |
                                 (0x100C0000 + 8))) = (i);
  *((volatile unsigned char *)(((long unsigned int)(int)0xa0000000) |
                               (0x100C0000))) = (0x40);
  for (i = 0x40; i < 0xc0; i++) {
    if ((unsigned char)i !=
        (*((volatile unsigned char *)(((long unsigned int)(int)0xa0000000) |
                                      (0x100C0000 + 8)))))
      errors++;
  }
  *((volatile unsigned char *)(((long unsigned int)(int)0xa0000000) |
                               (0x100C0000))) = (0x40);
  for (i = 0x40; i < 0xc0; i++)
    *((volatile unsigned char *)(((long unsigned int)(int)0xa0000000) |
                                 (0x100C0000 + 8))) = (0);
  return errors;
}


x86 assembly (clang, -O0):
<SL11HMemTest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x40,-0x8(%rbp)
cmpl   $0xc0,-0x8(%rbp)
jge    1164 <SL11HMemTest+0x44>
mov    -0x8(%rbp),%eax
mov    %al,%cl
mov    -0x8(%rbp),%eax
movzbl %cl,%edi
movzbl %al,%esi
call   1030 <SL11Write@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1136 <SL11HMemTest+0x16>
movl   $0x40,-0x8(%rbp)
cmpl   $0xc0,-0x8(%rbp)
jge    11fe <SL11HMemTest+0xde>
mov    -0x8(%rbp),%eax
movzbl %al,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
movzbl %al,%edi
call   1040 <SL11Read@plt>
mov    %al,%cl
mov    -0xc(%rbp),%eax
movzbl %cl,%ecx
cmp    %ecx,%eax
je     11a5 <SL11HMemTest+0x85>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%eax
mov    %al,%cl
mov    -0x8(%rbp),%eax
xor    $0xffffffff,%eax
movzbl %cl,%edi
movzbl %al,%esi
call   1030 <SL11Write@plt>
mov    -0x8(%rbp),%eax
xor    $0xffffffff,%eax
movzbl %al,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
movzbl %al,%edi
call   1040 <SL11Read@plt>
mov    %al,%cl
mov    -0x10(%rbp),%eax
movzbl %cl,%ecx
cmp    %ecx,%eax
je     11eb <SL11HMemTest+0xcb>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11f0 <SL11HMemTest+0xd0>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    116b <SL11HMemTest+0x4b>
mov    $0xffffffffb00c0000,%rax
movb   $0x40,(%rax)
movl   $0x40,-0x8(%rbp)
cmpl   $0xc0,-0x8(%rbp)
jge    1238 <SL11HMemTest+0x118>
mov    -0x8(%rbp),%eax
mov    %al,%cl
mov    $0xffffffffb00c0008,%rax
mov    %cl,(%rax)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    120f <SL11HMemTest+0xef>
mov    $0xffffffffb00c0000,%rax
movb   $0x40,(%rax)
movl   $0x40,-0x8(%rbp)
cmpl   $0xc0,-0x8(%rbp)
jge    128c <SL11HMemTest+0x16c>
mov    -0x8(%rbp),%eax
movzbl %al,%eax
mov    $0xffffffffb00c0008,%rcx
mov    (%rcx),%cl
movzbl %cl,%ecx
cmp    %ecx,%eax
je     1279 <SL11HMemTest+0x159>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    127e <SL11HMemTest+0x15e>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1249 <SL11HMemTest+0x129>
mov    $0xffffffffb00c0000,%rax
movb   $0x40,(%rax)
movl   $0x40,-0x8(%rbp)
cmpl   $0xc0,-0x8(%rbp)
jge    12c2 <SL11HMemTest+0x1a2>
mov    $0xffffffffb00c0008,%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    129d <SL11HMemTest+0x17d>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SL11HMemTest>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    $0xffffff80,%ebx
nopl   (%rax)
lea    0xc0(%rbx),%eax
movzbl %al,%edi
mov    %edi,%esi
call   1030 <SL11Write@plt>
inc    %ebx
jne    1130 <SL11HMemTest+0x10>
xor    %ebx,%ebx
mov    $0x80,%r12d
mov    $0x40,%al
xchg   %ax,%ax
movzbl %al,%r14d
mov    %r14d,%edi
call   1040 <SL11Read@plt>
xor    %ebp,%ebp
cmp    %al,%r14b
setne  %bpl
add    %ebx,%ebp
lea    0x3f(%r12),%eax
movzbl %al,%r15d
mov    %r14d,%edi
mov    %r15d,%esi
call   1030 <SL11Write@plt>
mov    %r14d,%edi
call   1040 <SL11Read@plt>
xor    %ebx,%ebx
cmp    %al,%r15b
setne  %bl
add    %ebp,%ebx
lea    0x1(%r14),%eax
add    $0xffffffff,%r12d
jne    1150 <SL11HMemTest+0x30>
movb   $0x40,0xffffffffb00c0000
40
mov    $0xffffff80,%eax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    -0x40(%rax),%ecx
mov    %cl,0xffffffffb00c0008
lea    -0x3f(%rax),%ecx
mov    %cl,0xffffffffb00c0008
lea    -0x3e(%rax),%ecx
mov    %cl,0xffffffffb00c0008
lea    -0x3d(%rax),%ecx
mov    %cl,0xffffffffb00c0008
lea    -0x3c(%rax),%ecx
mov    %cl,0xffffffffb00c0008
lea    -0x3b(%rax),%ecx
mov    %cl,0xffffffffb00c0008
lea    -0x3a(%rax),%ecx
mov    %cl,0xffffffffb00c0008
lea    -0x39(%rax),%ecx
mov    %cl,0xffffffffb00c0008
add    $0x8,%eax
jne    11b0 <SL11HMemTest+0x90>
movb   $0x40,0xffffffffb00c0000
40
mov    $0xffffff80,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    -0x40(%rax),%ecx
xor    %edx,%edx
cmp    0xffffffffb00c0008,%cl
setne  %dl
add    %ebx,%edx
lea    -0x3f(%rax),%ecx
xor    %esi,%esi
cmp    0xffffffffb00c0008,%cl
setne  %sil
add    %edx,%esi
lea    -0x3e(%rax),%ecx
xor    %edx,%edx
cmp    0xffffffffb00c0008,%cl
setne  %dl
add    %esi,%edx
lea    -0x3d(%rax),%ecx
xor    %ebx,%ebx
cmp    0xffffffffb00c0008,%cl
setne  %bl
add    %edx,%ebx
add    $0x4,%eax
jne    1220 <SL11HMemTest+0x100>
movb   $0x40,0xffffffffb00c0000
40
mov    $0x80,%eax
nopw   0x0(%rax,%rax,1)
movb   $0x0,0xffffffffb00c0008
movb   $0x0,0xffffffffb00c0008
movb   $0x0,0xffffffffb00c0008
movb   $0x0,0xffffffffb00c0008
movb   $0x0,0xffffffffb00c0008
movb   $0x0,0xffffffffb00c0008
movb   $0x0,0xffffffffb00c0008
movb   $0x0,0xffffffffb00c0008
add    $0xfffffff8,%eax
jne    1280 <SL11HMemTest+0x160>
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @SL11HMemTest() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 64, i32* %2
br label %3
3: ; preds = %12, %0
%4 = load i32, i32* %2
%5 = icmp slt i32 %4, 192
br i1 %5, label %6, label %15
6: ; preds = %3
%7 = load i32, i32* %2
%8 = trunc i32 %7 to i8
%9 = load i32, i32* %2
%10 = trunc i32 %9 to i8
%11 = call i32 @SL11Write(i8 zeroext %8, i8 zeroext %10)
br label %12
12: ; preds = %6
%13 = load i32, i32* %2
%14 = add nsw i32 %13, 1
store i32 %14, i32* %2
br label %3
15: ; preds = %3
store i32 64, i32* %2
br label %16
16: ; preds = %51, %15
%17 = load i32, i32* %2
%18 = icmp slt i32 %17, 192
br i1 %18, label %19, label %54
19: ; preds = %16
%20 = load i32, i32* %2
%21 = trunc i32 %20 to i8
%22 = zext i8 %21 to i32
%23 = load i32, i32* %2
%24 = trunc i32 %23 to i8
%25 = call zeroext i8 @SL11Read(i8 zeroext %24)
%26 = zext i8 %25 to i32
%27 = icmp ne i32 %22, %26
br i1 %27, label %28, label %31
28: ; preds = %19
%29 = load i32, i32* %1
%30 = add nsw i32 %29, 1
store i32 %30, i32* %1
br label %31
31: ; preds = %28, %19
%32 = load i32, i32* %2
%33 = trunc i32 %32 to i8
%34 = load i32, i32* %2
%35 = xor i32 %34, -1
%36 = trunc i32 %35 to i8
%37 = call i32 @SL11Write(i8 zeroext %33, i8 zeroext %36)
%38 = load i32, i32* %2
%39 = xor i32 %38, -1
%40 = trunc i32 %39 to i8
%41 = zext i8 %40 to i32
%42 = load i32, i32* %2
%43 = trunc i32 %42 to i8
%44 = call zeroext i8 @SL11Read(i8 zeroext %43)
%45 = zext i8 %44 to i32
%46 = icmp ne i32 %41, %45
br i1 %46, label %47, label %50
47: ; preds = %31
%48 = load i32, i32* %1
%49 = add nsw i32 %48, 1
store i32 %49, i32* %1
br label %50
50: ; preds = %47, %31
br label %51
51: ; preds = %50
%52 = load i32, i32* %2
%53 = add nsw i32 %52, 1
store i32 %53, i32* %2
br label %16
54: ; preds = %16
store volatile i8 64, i8* inttoptr (i64 -1341390848 to i8*)
store i32 64, i32* %2
br label %55
55: ; preds = %61, %54
%56 = load i32, i32* %2
%57 = icmp slt i32 %56, 192
br i1 %57, label %58, label %64
58: ; preds = %55
%59 = load i32, i32* %2
%60 = trunc i32 %59 to i8
store volatile i8 %60, i8* inttoptr (i64 -1341390840 to i8*)
br label %61
61: ; preds = %58
%62 = load i32, i32* %2
%63 = add nsw i32 %62, 1
store i32 %63, i32* %2
br label %55
64: ; preds = %55
store volatile i8 64, i8* inttoptr (i64 -1341390848 to i8*)
store i32 64, i32* %2
br label %65
65: ; preds = %79, %64
%66 = load i32, i32* %2
%67 = icmp slt i32 %66, 192
br i1 %67, label %68, label %82
68: ; preds = %65
%69 = load i32, i32* %2
%70 = trunc i32 %69 to i8
%71 = zext i8 %70 to i32
%72 = load volatile i8, i8* inttoptr (i64 -1341390840 to i8*)
%73 = zext i8 %72 to i32
%74 = icmp ne i32 %71, %73
br i1 %74, label %75, label %78
75: ; preds = %68
%76 = load i32, i32* %1
%77 = add nsw i32 %76, 1
store i32 %77, i32* %1
br label %78
78: ; preds = %75, %68
br label %79
79: ; preds = %78
%80 = load i32, i32* %2
%81 = add nsw i32 %80, 1
store i32 %81, i32* %2
br label %65
82: ; preds = %65
store volatile i8 64, i8* inttoptr (i64 -1341390848 to i8*)
store i32 64, i32* %2
br label %83
83: ; preds = %87, %82
%84 = load i32, i32* %2
%85 = icmp slt i32 %84, 192
br i1 %85, label %86, label %90
86: ; preds = %83
store volatile i8 0, i8* inttoptr (i64 -1341390840 to i8*)
br label %87
87: ; preds = %86
%88 = load i32, i32* %2
%89 = add nsw i32 %88, 1
store i32 %89, i32* %2
br label %83
90: ; preds = %83
%91 = load i32, i32* %1
ret i32 %91
}

LLVM IR (-O2):
define i32 @SL11HMemTest() {
br label %1
1: ; preds = %0, %1
%2 = phi i32 [ 64, %0 ], [ %5, %1 ]
%3 = trunc i32 %2 to i8
%4 = tail call i32 @SL11Write(i8 zeroext %3, i8 zeroext %3)
%5 = add nuw nsw i32 %2, 1
%6 = icmp eq i32 %5, 192
br i1 %6, label %7, label %1
7: ; preds = %1, %7
%8 = phi i32 [ %21, %7 ], [ 64, %1 ]
%9 = phi i32 [ %20, %7 ], [ 0, %1 ]
%10 = trunc i32 %8 to i8
%11 = tail call zeroext i8 @SL11Read(i8 zeroext %10)
%12 = icmp ne i8 %11, %10
%13 = zext i1 %12 to i32
%14 = add nsw i32 %9, %13
%15 = xor i8 %10, -1
%16 = tail call i32 @SL11Write(i8 zeroext %10, i8 zeroext %15)
%17 = tail call zeroext i8 @SL11Read(i8 zeroext %10)
%18 = icmp ne i8 %17, %15
%19 = zext i1 %18 to i32
%20 = add nsw i32 %14, %19
%21 = add nuw nsw i32 %8, 1
%22 = icmp eq i32 %21, 192
br i1 %22, label %23, label %7
23: ; preds = %7
store volatile i8 64, i8* inttoptr (i64 -1341390848 to i8*)
br label %24
24: ; preds = %24, %23
%25 = phi i32 [ 64, %23 ], [ %41, %24 ]
%26 = trunc i32 %25 to i8
store volatile i8 %26, i8* inttoptr (i64 -1341390840 to i8*)
%27 = trunc i32 %25 to i8
%28 = or i8 %27, 1
store volatile i8 %28, i8* inttoptr (i64 -1341390840 to i8*)
%29 = trunc i32 %25 to i8
%30 = or i8 %29, 2
store volatile i8 %30, i8* inttoptr (i64 -1341390840 to i8*)
%31 = trunc i32 %25 to i8
%32 = or i8 %31, 3
store volatile i8 %32, i8* inttoptr (i64 -1341390840 to i8*)
%33 = trunc i32 %25 to i8
%34 = or i8 %33, 4
store volatile i8 %34, i8* inttoptr (i64 -1341390840 to i8*)
%35 = trunc i32 %25 to i8
%36 = or i8 %35, 5
store volatile i8 %36, i8* inttoptr (i64 -1341390840 to i8*)
%37 = trunc i32 %25 to i8
%38 = or i8 %37, 6
store volatile i8 %38, i8* inttoptr (i64 -1341390840 to i8*)
%39 = trunc i32 %25 to i8
%40 = or i8 %39, 7
store volatile i8 %40, i8* inttoptr (i64 -1341390840 to i8*)
%41 = add nuw nsw i32 %25, 8
%42 = icmp eq i32 %41, 192
br i1 %42, label %43, label %24
43: ; preds = %24
store volatile i8 64, i8* inttoptr (i64 -1341390848 to i8*)
br label %44
44: ; preds = %44, %43
%45 = phi i32 [ 64, %43 ], [ %70, %44 ]
%46 = phi i32 [ %20, %43 ], [ %69, %44 ]
%47 = load volatile i8, i8* inttoptr (i64 -1341390840 to i8*)
%48 = trunc i32 %45 to i8
%49 = icmp ne i8 %47, %48
%50 = zext i1 %49 to i32
%51 = add nsw i32 %46, %50
%52 = load volatile i8, i8* inttoptr (i64 -1341390840 to i8*)
%53 = trunc i32 %45 to i8
%54 = or i8 %53, 1
%55 = icmp ne i8 %52, %54
%56 = zext i1 %55 to i32
%57 = add nsw i32 %51, %56
%58 = load volatile i8, i8* inttoptr (i64 -1341390840 to i8*)
%59 = trunc i32 %45 to i8
%60 = or i8 %59, 2
%61 = icmp ne i8 %58, %60
%62 = zext i1 %61 to i32
%63 = add nsw i32 %57, %62
%64 = load volatile i8, i8* inttoptr (i64 -1341390840 to i8*)
%65 = trunc i32 %45 to i8
%66 = or i8 %65, 3
%67 = icmp ne i8 %64, %66
%68 = zext i1 %67 to i32
%69 = add nsw i32 %63, %68
%70 = add nuw nsw i32 %45, 4
%71 = icmp eq i32 %70, 192
br i1 %71, label %72, label %44
72: ; preds = %44
store volatile i8 64, i8* inttoptr (i64 -1341390848 to i8*)
br label %73
73: ; preds = %73, %72
%74 = phi i32 [ 64, %72 ], [ %75, %73 ]
store volatile i8 0, i8* inttoptr (i64 -1341390840 to i8*)
store volatile i8 0, i8* inttoptr (i64 -1341390840 to i8*)
store volatile i8 0, i8* inttoptr (i64 -1341390840 to i8*)
store volatile i8 0, i8* inttoptr (i64 -1341390840 to i8*)
store volatile i8 0, i8* inttoptr (i64 -1341390840 to i8*)
store volatile i8 0, i8* inttoptr (i64 -1341390840 to i8*)
store volatile i8 0, i8* inttoptr (i64 -1341390840 to i8*)
store volatile i8 0, i8* inttoptr (i64 -1341390840 to i8*)
%75 = add nuw nsw i32 %74, 8
%76 = icmp eq i32 %75, 192
br i1 %76, label %77, label %73
77: ; preds = %73
ret i32 %69
}