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

/* Variables and functions */
int el_lrc8(int, int *, int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, const char *argv[]) {
  uint8_t data[] = {1, 2, 3, 4};
  uint8_t expected = 0xff ^ 1 ^ 2 ^ 3 ^ 4;
  uint8_t actual = el_lrc8(0xFF, data, (sizeof(data) / sizeof(data[0])));
  if (expected != actual)
    printf("Failed, Expected:%02x Actual:%02x\n", expected, actual);
  else
    printf("Success\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xec3(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xec0(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0xfb,-0x24(%rbp)
lea    -0x20(%rbp),%rsi
mov    $0xff,%edi
mov    $0x4,%edx
call   1040 <el_lrc8@plt>
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
je     118e <main+0x6e>
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    119c <main+0x7c>
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
movaps 0xec5(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rsi
mov    $0xff,%edi
mov    $0x4,%edx
call   1050 <el_lrc8@plt>
cmp    $0xfb,%eax
jne    1166 <main+0x36>
lea    0xed4(%rip),%rdi
call   1030 <puts@plt>
jmp    117b <main+0x4b>
lea    0xea3(%rip),%rdi
mov    $0xfb,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@__const.main.data = [4 x i32] [i32 1, i32 2, i32 3, i32 4]
@.str = [35 x i8] c"Failed, Expected:%02x Actual:%02x\0A\00"
@.str.1 = [9 x i8] c"Success\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [4 x i32]
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = bitcast [4 x i32]* %6 to i8*
store i32 251, i32* %7
%10 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 0
%11 = call i32 @el_lrc8(i32 255, i32* %10, i32 4)
store i32 %11, i32* %8
%12 = load i32, i32* %7
%13 = load i32, i32* %8
%14 = icmp ne i32 %12, %13
br i1 %14, label %15, label %19
15: ; preds = %2
%16 = load i32, i32* %7
%17 = load i32, i32* %8
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %16, i32 %17)
br label %21
19: ; preds = %2
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %21
21: ; preds = %19, %15
ret i32 0
}

LLVM IR (-O2):
@__const.main.data = [4 x i32] [i32 1, i32 2, i32 3, i32 4]
@.str = [35 x i8] c"Failed, Expected:%02x Actual:%02x\0A\00"
@str = [8 x i8] c"Success\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [4 x i32]
%4 = bitcast [4 x i32]* %3 to i8*
%5 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 0
%6 = call i32 @el_lrc8(i32 255, i32* %5, i32 4)
%7 = icmp eq i32 %6, 251
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 251, i32 %6)
br label %12
10: ; preds = %2
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
br label %12
12: ; preds = %10, %8
ret i32 0
}