#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 countBytes(unsigned int);
unsigned int setIByte(unsigned int, int);
unsigned int initRanks(unsigned int e) {
  int bits = countBytes(e);
  if (bits >= 4) {
    e = setIByte(e, 32);
    e = setIByte(e, 32 - 1);
  } else if (bits == 3) {
    e = setIByte(e, 32);
  } else if (bits == 2) {
    e = setIByte(e, 32 - 1);
  }
  return e;
}


x86 assembly (clang, -O0):
<initRanks>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <countBytes@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x4,-0x8(%rbp)
jl     1165 <initRanks+0x45>
mov    -0x4(%rbp),%edi
mov    $0x20,%esi
call   1040 <setIByte@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x1f,%esi
call   1040 <setIByte@plt>
mov    %eax,-0x4(%rbp)
jmp    11a8 <initRanks+0x88>
cmpl   $0x3,-0x8(%rbp)
jne    1184 <initRanks+0x64>
mov    -0x4(%rbp),%edi
mov    $0x20,%esi
call   1040 <setIByte@plt>
mov    %eax,-0x4(%rbp)
jmp    11a3 <initRanks+0x83>
cmpl   $0x2,-0x8(%rbp)
jne    119e <initRanks+0x7e>
mov    -0x4(%rbp),%edi
mov    $0x1f,%esi
call   1040 <setIByte@plt>
mov    %eax,-0x4(%rbp)
jmp    11a3 <initRanks+0x83>
jmp    11a8 <initRanks+0x88>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<initRanks>:
push   %rbx
mov    %edi,%ebx
call   1030 <countBytes@plt>
cmp    $0x4,%eax
jl     113d <initRanks+0x1d>
mov    %ebx,%edi
mov    $0x20,%esi
call   1040 <setIByte@plt>
mov    %eax,%edi
jmp    1156 <initRanks+0x36>
cmp    $0x2,%eax
je     1154 <initRanks+0x34>
cmp    $0x3,%eax
jne    1161 <initRanks+0x41>
mov    %ebx,%edi
mov    $0x20,%esi
pop    %rbx
jmp    1040 <setIByte@plt>
mov    %ebx,%edi
mov    $0x1f,%esi
pop    %rbx
jmp    1040 <setIByte@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @initRanks(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = call i32 @countBytes(i32 %4)
store i32 %5, i32* %3
%6 = load i32, i32* %3
%7 = icmp sge i32 %6, 4
br i1 %7, label %8, label %13
8: ; preds = %1
%9 = load i32, i32* %2
%10 = call i32 @setIByte(i32 %9, i32 32)
store i32 %10, i32* %2
%11 = load i32, i32* %2
%12 = call i32 @setIByte(i32 %11, i32 31)
store i32 %12, i32* %2
br label %27
13: ; preds = %1
%14 = load i32, i32* %3
%15 = icmp eq i32 %14, 3
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = load i32, i32* %2
%18 = call i32 @setIByte(i32 %17, i32 32)
store i32 %18, i32* %2
br label %26
19: ; preds = %13
%20 = load i32, i32* %3
%21 = icmp eq i32 %20, 2
br i1 %21, label %22, label %25
22: ; preds = %19
%23 = load i32, i32* %2
%24 = call i32 @setIByte(i32 %23, i32 31)
store i32 %24, i32* %2
br label %25
25: ; preds = %22, %19
br label %26
26: ; preds = %25, %16
br label %27
27: ; preds = %26, %8
%28 = load i32, i32* %2
ret i32 %28
}

LLVM IR (-O2):
define i32 @initRanks(i32 %0) {
%2 = tail call i32 @countBytes(i32 %0)
%3 = icmp sgt i32 %2, 3
br i1 %3, label %4, label %7
4: ; preds = %1
%5 = tail call i32 @setIByte(i32 %0, i32 32)
%6 = tail call i32 @setIByte(i32 %5, i32 31)
br label %12
7: ; preds = %1
switch i32 %2, label %12 [
i32 3, label %8
i32 2, label %10
]
8: ; preds = %7
%9 = tail call i32 @setIByte(i32 %0, i32 32)
br label %12
10: ; preds = %7
%11 = tail call i32 @setIByte(i32 %0, i32 31)
br label %12
12: ; preds = %7, %8, %10, %4
%13 = phi i32 [ %6, %4 ], [ %9, %8 ], [ %11, %10 ], [ %0, %7 ]
ret i32 %13
}