#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 EINVAL;
int EIO;
unsigned char *four_numbering_system_decode(unsigned char *, int);
unsigned char *four_numbering_system_encode(unsigned char *, int);
int /*<<< orphan*/ free(unsigned char *);
scalar_t__ strcmp(char *, char *);
int four_numbering_system_test(unsigned char *data, int len) {
  int ret;
  unsigned char *tmp1 = NULL;
  unsigned char *tmp2 = NULL;
  if ((tmp1 = four_numbering_system_encode(data, len)) == NULL)
    return -EIO;
  if ((tmp2 = four_numbering_system_decode(tmp1, len * 4)) == NULL) {
    free(tmp1);
    return -EINVAL;
  }
  ret = (strcmp((char *)data, (char *)tmp2) != 0);
  free(tmp1);
  free(tmp2);
  return ret;
}


x86 assembly (clang, -O0):
<four_numbering_system_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <four_numbering_system_encode@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    118c <four_numbering_system_test+0x4c>
xor    %eax,%eax
mov    0x2e5e(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    11f9 <four_numbering_system_test+0xb9>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
shl    $0x2,%esi
call   1060 <four_numbering_system_decode@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    11c5 <four_numbering_system_test+0x85>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
mov    0x2e1d(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    11f9 <four_numbering_system_test+0xb9>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x18(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<four_numbering_system_test>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%r14
call   1040 <four_numbering_system_encode@plt>
test   %rax,%rax
je     1194 <four_numbering_system_test+0x54>
mov    %rax,%rbx
shl    $0x2,%ebp
mov    %rax,%rdi
mov    %ebp,%esi
call   1060 <four_numbering_system_decode@plt>
test   %rax,%rax
je     119d <four_numbering_system_test+0x5d>
mov    %rax,%r15
mov    %r14,%rdi
mov    %rax,%rsi
call   1050 <strcmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
setne  %bpl
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
jmp    11b0 <four_numbering_system_test+0x70>
mov    0x2e45(%rip),%rax
jmp    11ac <four_numbering_system_test+0x6c>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x2e2c(%rip),%rax
xor    %ebp,%ebp
sub    (%rax),%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EIO = global i32 0
@EINVAL = global i32 0
define i32 @four_numbering_system_test(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
store i8* %0, i8** %4
store i32 %1, i32* %5
store i8* null, i8** %7
store i8* null, i8** %8
%9 = load i8*, i8** %4
%10 = load i32, i32* %5
%11 = call i8* @four_numbering_system_encode(i8* %9, i32 %10)
store i8* %11, i8** %7
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = load i32, i32* @EIO
%15 = sub nsw i32 0, %14
store i32 %15, i32* %3
br label %38
16: ; preds = %2
%17 = load i8*, i8** %7
%18 = load i32, i32* %5
%19 = mul nsw i32 %18, 4
%20 = call i8* @four_numbering_system_decode(i8* %17, i32 %19)
store i8* %20, i8** %8
%21 = icmp eq i8* %20, null
br i1 %21, label %22, label %27
22: ; preds = %16
%23 = load i8*, i8** %7
%24 = call i32 @free(i8* %23)
%25 = load i32, i32* @EINVAL
%26 = sub nsw i32 0, %25
store i32 %26, i32* %3
br label %38
27: ; preds = %16
%28 = load i8*, i8** %4
%29 = load i8*, i8** %8
%30 = call i64 @strcmp(i8* %28, i8* %29)
%31 = icmp ne i64 %30, 0
%32 = zext i1 %31 to i32
store i32 %32, i32* %6
%33 = load i8*, i8** %7
%34 = call i32 @free(i8* %33)
%35 = load i8*, i8** %8
%36 = call i32 @free(i8* %35)
%37 = load i32, i32* %6
store i32 %37, i32* %3
br label %38
38: ; preds = %27, %22, %13
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
@EIO = global i32 0
@EINVAL = global i32 0
define i32 @four_numbering_system_test(i8* %0, i32 %1) {
%3 = tail call i8* @four_numbering_system_encode(i8* %0, i32 %1)
%4 = icmp eq i8* %3, null
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = load i32, i32* @EIO
%7 = sub nsw i32 0, %6
br label %22
8: ; preds = %2
%9 = shl nsw i32 %1, 2
%10 = tail call i8* @four_numbering_system_decode(i8* %3, i32 %9)
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %16
12: ; preds = %8
%13 = tail call i32 @free(i8* %3)
%14 = load i32, i32* @EINVAL
%15 = sub nsw i32 0, %14
br label %22
16: ; preds = %8
%17 = tail call i64 @strcmp(i8* %0, i8* %10)
%18 = icmp ne i64 %17, 0
%19 = zext i1 %18 to i32
%20 = tail call i32 @free(i8* %3)
%21 = tail call i32 @free(i8* %10)
br label %22
22: ; preds = %16, %12, %5
%23 = phi i32 [ %7, %5 ], [ %15, %12 ], [ %19, %16 ]
ret i32 %23
}