#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*/ fail_test(int);
int int_dec(unsigned char *);
int /*<<< orphan*/ int_enc(unsigned char *, int);
int real_dec(unsigned char *);
int /*<<< orphan*/ real_enc(unsigned char *, int);
void test_codec() {
  int idx;
  unsigned char i[sizeof(int)];
  unsigned char d[sizeof(double)];
  int_enc(i, 0x0AFF0C0D);
  if (0x0AFF0C0D != int_dec(i))
    fail_test(29);
  ;
  for (idx = -500; idx < 500; ++idx) {
    int_enc(i, idx);
    if (idx != int_dec(i))
      fail_test(34);
    ;
  }
  real_enc(d, 1);
  if (1 != real_dec(d))
    fail_test(39);
  ;
  for (idx = -500; idx < 500; ++idx) {
    real_enc(d, idx);
    if (idx != (int)real_dec(d))
      fail_test(44);
    ;
  }
}


x86 assembly (clang, -O0):
<test_codec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    -0x8(%rbp),%rdi
mov    $0xaff0c0d,%esi
call   1050 <int_enc@plt>
lea    -0x8(%rbp),%rdi
call   1060 <int_dec@plt>
mov    %eax,%ecx
mov    $0xaff0c0d,%eax
cmp    %ecx,%eax
je     1188 <test_codec+0x38>
mov    $0x1d,%edi
call   1030 <fail_test@plt>
movl   $0xfffffe0c,-0x4(%rbp)
cmpl   $0x1f4,-0x4(%rbp)
jge    11e1 <test_codec+0x91>
lea    -0x8(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1050 <int_enc@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
lea    -0x8(%rbp),%rdi
call   1060 <int_dec@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
je     11ce <test_codec+0x7e>
mov    $0x22,%edi
call   1030 <fail_test@plt>
jmp    11d3 <test_codec+0x83>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    118f <test_codec+0x3f>
lea    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1070 <real_enc@plt>
lea    -0x10(%rbp),%rdi
call   1040 <real_dec@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
je     1211 <test_codec+0xc1>
mov    $0x27,%edi
call   1030 <fail_test@plt>
movl   $0xfffffe0c,-0x4(%rbp)
cmpl   $0x1f4,-0x4(%rbp)
jge    126a <test_codec+0x11a>
lea    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1070 <real_enc@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x18(%rbp)
lea    -0x10(%rbp),%rdi
call   1040 <real_dec@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
je     1257 <test_codec+0x107>
mov    $0x2c,%edi
call   1030 <fail_test@plt>
jmp    125c <test_codec+0x10c>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1218 <test_codec+0xc8>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_codec>:
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xaff0c0d,%esi
call   1050 <int_enc@plt>
mov    %rbx,%rdi
call   1060 <int_dec@plt>
cmp    $0xaff0c0d,%eax
je     1182 <test_codec+0x32>
mov    $0x1d,%edi
call   1030 <fail_test@plt>
mov    $0xfffffe0c,%ebx
lea    0xc(%rsp),%r14
jmp    119b <test_codec+0x4b>
xchg   %ax,%ax
add    $0x1,%ebx
cmp    $0x1f4,%ebx
je     11bd <test_codec+0x6d>
mov    %r14,%rdi
mov    %ebx,%esi
call   1050 <int_enc@plt>
mov    %r14,%rdi
call   1060 <int_dec@plt>
cmp    %eax,%ebx
je     1190 <test_codec+0x40>
mov    $0x22,%edi
call   1030 <fail_test@plt>
jmp    1190 <test_codec+0x40>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
call   1070 <real_enc@plt>
mov    %rbx,%rdi
call   1040 <real_dec@plt>
cmp    $0x1,%eax
je     11e6 <test_codec+0x96>
mov    $0x27,%edi
call   1030 <fail_test@plt>
mov    $0xfffffe0c,%ebx
lea    0x10(%rsp),%r14
jmp    120b <test_codec+0xbb>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%ebx
cmp    $0x1f4,%ebx
je     122d <test_codec+0xdd>
mov    %r14,%rdi
mov    %ebx,%esi
call   1070 <real_enc@plt>
mov    %r14,%rdi
call   1040 <real_dec@plt>
cmp    %eax,%ebx
je     1200 <test_codec+0xb0>
mov    $0x2c,%edi
call   1030 <fail_test@plt>
jmp    1200 <test_codec+0xb0>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @test_codec() {
%1 = alloca i32
%2 = alloca [4 x i8]
%3 = alloca [8 x i8]
%4 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%5 = call i32 @int_enc(i8* %4, i32 184486925)
%6 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%7 = call i32 @int_dec(i8* %6)
%8 = icmp ne i32 184486925, %7
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 @fail_test(i32 29)
br label %11
11: ; preds = %9, %0
store i32 -500, i32* %1
br label %12
12: ; preds = %26, %11
%13 = load i32, i32* %1
%14 = icmp slt i32 %13, 500
br i1 %14, label %15, label %29
15: ; preds = %12
%16 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%17 = load i32, i32* %1
%18 = call i32 @int_enc(i8* %16, i32 %17)
%19 = load i32, i32* %1
%20 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%21 = call i32 @int_dec(i8* %20)
%22 = icmp ne i32 %19, %21
br i1 %22, label %23, label %25
23: ; preds = %15
%24 = call i32 @fail_test(i32 34)
br label %25
25: ; preds = %23, %15
br label %26
26: ; preds = %25
%27 = load i32, i32* %1
%28 = add nsw i32 %27, 1
store i32 %28, i32* %1
br label %12
29: ; preds = %12
%30 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%31 = call i32 @real_enc(i8* %30, i32 1)
%32 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%33 = call i32 @real_dec(i8* %32)
%34 = icmp ne i32 1, %33
br i1 %34, label %35, label %37
35: ; preds = %29
%36 = call i32 @fail_test(i32 39)
br label %37
37: ; preds = %35, %29
store i32 -500, i32* %1
br label %38
38: ; preds = %52, %37
%39 = load i32, i32* %1
%40 = icmp slt i32 %39, 500
br i1 %40, label %41, label %55
41: ; preds = %38
%42 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%43 = load i32, i32* %1
%44 = call i32 @real_enc(i8* %42, i32 %43)
%45 = load i32, i32* %1
%46 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%47 = call i32 @real_dec(i8* %46)
%48 = icmp ne i32 %45, %47
br i1 %48, label %49, label %51
49: ; preds = %41
%50 = call i32 @fail_test(i32 44)
br label %51
51: ; preds = %49, %41
br label %52
52: ; preds = %51
%53 = load i32, i32* %1
%54 = add nsw i32 %53, 1
store i32 %54, i32* %1
br label %38
55: ; preds = %38
ret void
}

LLVM IR (-O2):
define void @test_codec() {
%1 = alloca [4 x i8]
%2 = alloca [8 x i8]
%3 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%5 = call i32 @int_enc(i8* %3, i32 184486925)
%6 = call i32 @int_dec(i8* %3)
%7 = icmp eq i32 %6, 184486925
br i1 %7, label %10, label %8
8: ; preds = %0
%9 = call i32 @fail_test(i32 29)
br label %10
10: ; preds = %8, %0
br label %11
11: ; preds = %10, %18
%12 = phi i32 [ %19, %18 ], [ -500, %10 ]
%13 = call i32 @int_enc(i8* %3, i32 %12)
%14 = call i32 @int_dec(i8* %3)
%15 = icmp eq i32 %12, %14
br i1 %15, label %18, label %16
16: ; preds = %11
%17 = call i32 @fail_test(i32 34)
br label %18
18: ; preds = %11, %16
%19 = add nsw i32 %12, 1
%20 = icmp eq i32 %19, 500
br i1 %20, label %21, label %11
21: ; preds = %18
%22 = call i32 @real_enc(i8* %4, i32 1)
%23 = call i32 @real_dec(i8* %4)
%24 = icmp eq i32 %23, 1
br i1 %24, label %27, label %25
25: ; preds = %21
%26 = call i32 @fail_test(i32 39)
br label %27
27: ; preds = %25, %21
br label %28
28: ; preds = %27, %35
%29 = phi i32 [ %36, %35 ], [ -500, %27 ]
%30 = call i32 @real_enc(i8* %4, i32 %29)
%31 = call i32 @real_dec(i8* %4)
%32 = icmp eq i32 %29, %31
br i1 %32, label %35, label %33
33: ; preds = %28
%34 = call i32 @fail_test(i32 44)
br label %35
35: ; preds = %28, %33
%36 = add nsw i32 %29, 1
%37 = icmp eq i32 %36, 500
br i1 %37, label %38, label %28
38: ; preds = %35
ret void
}