#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 /*<<< orphan*/ uint32_t;

/* Variables and functions */
int is_bit_set(int /*<<< orphan*/, int);
char class(uint32_t ip) {
  int i;
  char c[5] = {'A', 'B', 'C', 'D', 'E'};
  for (i = 0; i < 5; i++) {
    if (is_bit_set(ip, 31 - i) == false) {
      break;
    }
  }
  return c[i];
}


x86 assembly (clang, -O0):
<class>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    0xedf(%rip),%eax
mov    %eax,-0xd(%rbp)
mov    0xeda(%rip),%al
mov    %al,-0x9(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    116f <class+0x5f>
mov    -0x4(%rbp),%edi
mov    $0x1f,%esi
sub    -0x8(%rbp),%esi
call   1030 <is_bit_set@plt>
cmp    $0x0,%eax
jne    115c <class+0x4c>
jmp    116f <class+0x5f>
jmp    1161 <class+0x51>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1134 <class+0x24>
movslq -0x8(%rbp),%rax
movsbl -0xd(%rbp,%rax,1),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<class>:
push   %rbx
mov    %edi,%ebx
mov    $0x1f,%esi
call   1030 <is_bit_set@plt>
test   %eax,%eax
je     116b <class+0x5b>
mov    %ebx,%edi
mov    $0x1e,%esi
call   1030 <is_bit_set@plt>
test   %eax,%eax
je     116f <class+0x5f>
mov    %ebx,%edi
mov    $0x1d,%esi
call   1030 <is_bit_set@plt>
test   %eax,%eax
je     1176 <class+0x66>
mov    %ebx,%edi
mov    $0x1c,%esi
call   1030 <is_bit_set@plt>
test   %eax,%eax
je     117d <class+0x6d>
mov    %ebx,%edi
mov    $0x1b,%esi
call   1030 <is_bit_set@plt>
cmp    $0x1,%eax
mov    $0x5,%eax
sbb    $0x0,%rax
jmp    1182 <class+0x72>
xor    %eax,%eax
jmp    1182 <class+0x72>
mov    $0x1,%eax
jmp    1182 <class+0x72>
mov    $0x2,%eax
jmp    1182 <class+0x72>
mov    $0x3,%eax
lea    0xe77(%rip),%rcx
mov    (%rax,%rcx,1),%al
pop    %rbx
ret

LLVM IR (-O0):
@__const.class.c = [5 x i8] c"ABCDE"
define signext i8 @class(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [5 x i8]
store i32 %0, i32* %2
%5 = bitcast [5 x i8]* %4 to i8*
store i32 0, i32* %3
br label %6
6: ; preds = %17, %1
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 5
br i1 %8, label %9, label %20
9: ; preds = %6
%10 = load i32, i32* %2
%11 = load i32, i32* %3
%12 = sub nsw i32 31, %11
%13 = call i32 @is_bit_set(i32 %10, i32 %12)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %9
br label %20
16: ; preds = %9
br label %17
17: ; preds = %16
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
store i32 %19, i32* %3
br label %6
20: ; preds = %15, %6
%21 = load i32, i32* %3
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 %22
%24 = load i8, i8* %23
ret i8 %24
}

LLVM IR (-O2):
@__const.class.c = [5 x i8] c"ABCDE"
define signext i8 @class(i32 %0) {
%2 = tail call i32 @is_bit_set(i32 %0, i32 31)
%3 = icmp eq i32 %2, 0
br i1 %3, label %17, label %4
4: ; preds = %1
%5 = tail call i32 @is_bit_set(i32 %0, i32 30)
%6 = icmp eq i32 %5, 0
br i1 %6, label %17, label %7
7: ; preds = %4
%8 = tail call i32 @is_bit_set(i32 %0, i32 29)
%9 = icmp eq i32 %8, 0
br i1 %9, label %17, label %10
10: ; preds = %7
%11 = tail call i32 @is_bit_set(i32 %0, i32 28)
%12 = icmp eq i32 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %10
%14 = tail call i32 @is_bit_set(i32 %0, i32 27)
%15 = icmp eq i32 %14, 0
%16 = select i1 %15, i64 4, i64 5
br label %17
17: ; preds = %13, %10, %7, %4, %1
%18 = phi i64 [ 0, %1 ], [ 1, %4 ], [ 2, %7 ], [ 3, %10 ], [ %16, %13 ]
%19 = getelementptr inbounds [5 x i8], [5 x i8]* @__const.class.c, i64 0, i64 %18
%20 = load i8, i8* %19
ret i8 %20
}