#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 int rotl(unsigned int const, int);
unsigned int encode(const unsigned int value) {
  unsigned int i, j;
  for (i = 0; i < 16; i++) {
    j = rotl(value, 2 * i);
    if (j < 256) {
      return ((i << 8) | j);
    }
  }
  return 0x1fe;
}


x86 assembly (clang, -O0):
<encode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x10,-0xc(%rbp)
jae    116e <encode+0x5e>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
shl    $0x1,%esi
call   1030 <rotl@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x100,-0x10(%rbp)
jae    115b <encode+0x4b>
mov    -0xc(%rbp),%eax
shl    $0x8,%eax
or     -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1175 <encode+0x65>
jmp    1160 <encode+0x50>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1122 <encode+0x12>
movl   $0x1fe,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<encode>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
xor    %ebp,%ebp
xor    %esi,%esi
call   1030 <rotl@plt>
cmp    $0xff,%eax
jbe    12d0 <encode+0x1c0>
mov    %ebx,%edi
mov    $0x2,%esi
call   1030 <rotl@plt>
cmp    $0x100,%eax
jae    1146 <encode+0x36>
mov    $0x100,%ebp
jmp    12d0 <encode+0x1c0>
mov    %ebx,%edi
mov    $0x4,%esi
call   1030 <rotl@plt>
cmp    $0x100,%eax
jae    1163 <encode+0x53>
mov    $0x200,%ebp
jmp    12d0 <encode+0x1c0>
mov    %ebx,%edi
mov    $0x6,%esi
call   1030 <rotl@plt>
cmp    $0x100,%eax
jae    1180 <encode+0x70>
mov    $0x300,%ebp
jmp    12d0 <encode+0x1c0>
mov    %ebx,%edi
mov    $0x8,%esi
call   1030 <rotl@plt>
cmp    $0x100,%eax
jae    119d <encode+0x8d>
mov    $0x400,%ebp
jmp    12d0 <encode+0x1c0>
mov    %ebx,%edi
mov    $0xa,%esi
call   1030 <rotl@plt>
cmp    $0x100,%eax
jae    11ba <encode+0xaa>
mov    $0x500,%ebp
jmp    12d0 <encode+0x1c0>
mov    %ebx,%edi
mov    $0xc,%esi
call   1030 <rotl@plt>
cmp    $0x100,%eax
jae    11d7 <encode+0xc7>
mov    $0x600,%ebp
jmp    12d0 <encode+0x1c0>
mov    %ebx,%edi
mov    $0xe,%esi
call   1030 <rotl@plt>
cmp    $0x100,%eax
jae    11f4 <encode+0xe4>
mov    $0x700,%ebp
jmp    12d0 <encode+0x1c0>
mov    %ebx,%edi
mov    $0x10,%esi
call   1030 <rotl@plt>
cmp    $0x100,%eax
jae    1211 <encode+0x101>
mov    $0x800,%ebp
jmp    12d0 <encode+0x1c0>
mov    %ebx,%edi
mov    $0x12,%esi
call   1030 <rotl@plt>
cmp    $0x100,%eax
jae    122e <encode+0x11e>
mov    $0x900,%ebp
jmp    12d0 <encode+0x1c0>
mov    %ebx,%edi
mov    $0x14,%esi
call   1030 <rotl@plt>
cmp    $0x100,%eax
jae    124b <encode+0x13b>
mov    $0xa00,%ebp
jmp    12d0 <encode+0x1c0>
mov    %ebx,%edi
mov    $0x16,%esi
call   1030 <rotl@plt>
cmp    $0x100,%eax
jae    1265 <encode+0x155>
mov    $0xb00,%ebp
jmp    12d0 <encode+0x1c0>
mov    %ebx,%edi
mov    $0x18,%esi
call   1030 <rotl@plt>
cmp    $0x100,%eax
jae    127f <encode+0x16f>
mov    $0xc00,%ebp
jmp    12d0 <encode+0x1c0>
mov    %ebx,%edi
mov    $0x1a,%esi
call   1030 <rotl@plt>
cmp    $0x100,%eax
jae    1299 <encode+0x189>
mov    $0xd00,%ebp
jmp    12d0 <encode+0x1c0>
mov    %ebx,%edi
mov    $0x1c,%esi
call   1030 <rotl@plt>
cmp    $0x100,%eax
jae    12b3 <encode+0x1a3>
mov    $0xe00,%ebp
jmp    12d0 <encode+0x1c0>
mov    %ebx,%edi
mov    $0x1e,%esi
call   1030 <rotl@plt>
mov    $0x1fe,%ebp
cmp    $0x100,%eax
jae    12d2 <encode+0x1c2>
mov    $0xf00,%ebp
or     %eax,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @encode(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 0, i32* %4
br label %6
6: ; preds = %22, %1
%7 = load i32, i32* %4
%8 = icmp ult i32 %7, 16
br i1 %8, label %9, label %25
9: ; preds = %6
%10 = load i32, i32* %3
%11 = load i32, i32* %4
%12 = mul i32 2, %11
%13 = call i32 @rotl(i32 %10, i32 %12)
store i32 %13, i32* %5
%14 = load i32, i32* %5
%15 = icmp ult i32 %14, 256
br i1 %15, label %16, label %21
16: ; preds = %9
%17 = load i32, i32* %4
%18 = shl i32 %17, 8
%19 = load i32, i32* %5
%20 = or i32 %18, %19
store i32 %20, i32* %2
br label %26
21: ; preds = %9
br label %22
22: ; preds = %21
%23 = load i32, i32* %4
%24 = add i32 %23, 1
store i32 %24, i32* %4
br label %6
25: ; preds = %6
store i32 510, i32* %2
br label %26
26: ; preds = %25, %16
%27 = load i32, i32* %2
ret i32 %27
}

LLVM IR (-O2):
define i32 @encode(i32 %0) {
%2 = tail call i32 @rotl(i32 %0, i32 0)
%3 = icmp ult i32 %2, 256
br i1 %3, label %4, label %8
4: ; preds = %50, %47, %44, %41, %38, %35, %32, %29, %26, %23, %20, %17, %14, %11, %8, %1
%5 = phi i32 [ 0, %1 ], [ 256, %8 ], [ 512, %11 ], [ 768, %14 ], [ 1024, %17 ], [ 1280, %20 ], [ 1536, %23 ], [ 1792, %26 ], [ 2048, %29 ], [ 2304, %32 ], [ 2560, %35 ], [ 2816, %38 ], [ 3072, %41 ], [ 3328, %44 ], [ 3584, %47 ], [ 3840, %50 ]
%6 = phi i32 [ %2, %1 ], [ %9, %8 ], [ %12, %11 ], [ %15, %14 ], [ %18, %17 ], [ %21, %20 ], [ %24, %23 ], [ %27, %26 ], [ %30, %29 ], [ %33, %32 ], [ %36, %35 ], [ %39, %38 ], [ %42, %41 ], [ %45, %44 ], [ %48, %47 ], [ %51, %50 ]
%7 = or i32 %6, %5
br label %53
8: ; preds = %1
%9 = tail call i32 @rotl(i32 %0, i32 2)
%10 = icmp ult i32 %9, 256
br i1 %10, label %4, label %11
11: ; preds = %8
%12 = tail call i32 @rotl(i32 %0, i32 4)
%13 = icmp ult i32 %12, 256
br i1 %13, label %4, label %14
14: ; preds = %11
%15 = tail call i32 @rotl(i32 %0, i32 6)
%16 = icmp ult i32 %15, 256
br i1 %16, label %4, label %17
17: ; preds = %14
%18 = tail call i32 @rotl(i32 %0, i32 8)
%19 = icmp ult i32 %18, 256
br i1 %19, label %4, label %20
20: ; preds = %17
%21 = tail call i32 @rotl(i32 %0, i32 10)
%22 = icmp ult i32 %21, 256
br i1 %22, label %4, label %23
23: ; preds = %20
%24 = tail call i32 @rotl(i32 %0, i32 12)
%25 = icmp ult i32 %24, 256
br i1 %25, label %4, label %26
26: ; preds = %23
%27 = tail call i32 @rotl(i32 %0, i32 14)
%28 = icmp ult i32 %27, 256
br i1 %28, label %4, label %29
29: ; preds = %26
%30 = tail call i32 @rotl(i32 %0, i32 16)
%31 = icmp ult i32 %30, 256
br i1 %31, label %4, label %32
32: ; preds = %29
%33 = tail call i32 @rotl(i32 %0, i32 18)
%34 = icmp ult i32 %33, 256
br i1 %34, label %4, label %35
35: ; preds = %32
%36 = tail call i32 @rotl(i32 %0, i32 20)
%37 = icmp ult i32 %36, 256
br i1 %37, label %4, label %38
38: ; preds = %35
%39 = tail call i32 @rotl(i32 %0, i32 22)
%40 = icmp ult i32 %39, 256
br i1 %40, label %4, label %41
41: ; preds = %38
%42 = tail call i32 @rotl(i32 %0, i32 24)
%43 = icmp ult i32 %42, 256
br i1 %43, label %4, label %44
44: ; preds = %41
%45 = tail call i32 @rotl(i32 %0, i32 26)
%46 = icmp ult i32 %45, 256
br i1 %46, label %4, label %47
47: ; preds = %44
%48 = tail call i32 @rotl(i32 %0, i32 28)
%49 = icmp ult i32 %48, 256
br i1 %49, label %4, label %50
50: ; preds = %47
%51 = tail call i32 @rotl(i32 %0, i32 30)
%52 = icmp ult i32 %51, 256
br i1 %52, label %4, label %53
53: ; preds = %50, %4
%54 = phi i32 [ %7, %4 ], [ 510, %50 ]
ret i32 %54
}