#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 uint32_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
unsigned char byte_num_or_die(uint32_t octet) {
  if (!(octet & (~((int)0) << (7))))
    return 1;
  if (!(octet & (~((int)0) << (11))))
    return 2;
  if (!(octet & (~((int)0) << (16))))
    return 3;
  if (!(octet & (~((int)0) << (21))))
    return 4;
  if (!(octet & (~((int)0) << (26))))
    return 5;
  if (!(octet & (~((int)0) << (31))))
    return 6;
  do {
    fprintf(stderr, "not supported");
    exit(EXIT_FAILURE);
  } while (0);
}


x86 assembly (clang, -O0):
<byte_num_or_die>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
and    $0xffffff80,%eax
cmp    $0x0,%eax
jne    1143 <byte_num_or_die+0x23>
movb   $0x1,-0x1(%rbp)
jmp    11ed <byte_num_or_die+0xcd>
mov    -0x8(%rbp),%eax
and    $0xfffff800,%eax
cmp    $0x0,%eax
jne    115d <byte_num_or_die+0x3d>
movb   $0x2,-0x1(%rbp)
jmp    11ed <byte_num_or_die+0xcd>
mov    -0x8(%rbp),%eax
and    $0xffff0000,%eax
cmp    $0x0,%eax
jne    1177 <byte_num_or_die+0x57>
movb   $0x3,-0x1(%rbp)
jmp    11ed <byte_num_or_die+0xcd>
mov    -0x8(%rbp),%eax
and    $0xffe00000,%eax
cmp    $0x0,%eax
jne    1191 <byte_num_or_die+0x71>
movb   $0x4,-0x1(%rbp)
jmp    11ed <byte_num_or_die+0xcd>
mov    -0x8(%rbp),%eax
and    $0xfc000000,%eax
cmp    $0x0,%eax
jne    11ab <byte_num_or_die+0x8b>
movb   $0x5,-0x1(%rbp)
jmp    11ed <byte_num_or_die+0xcd>
mov    -0x8(%rbp),%eax
and    $0x80000000,%eax
cmp    $0x0,%eax
jne    11c5 <byte_num_or_die+0xa5>
movb   $0x6,-0x1(%rbp)
jmp    11ed <byte_num_or_die+0xcd>
jmp    11ca <byte_num_or_die+0xaa>
mov    0x2e0f(%rip),%rax
mov    (%rax),%edi
lea    0xe26(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2df2(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>
movzbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<byte_num_or_die>:
mov    $0x1,%al
cmp    $0x80,%edi
jb     1158 <byte_num_or_die+0x38>
mov    $0x2,%al
cmp    $0x800,%edi
jb     1158 <byte_num_or_die+0x38>
mov    $0x3,%al
cmp    $0x10000,%edi
jb     1158 <byte_num_or_die+0x38>
mov    $0x4,%al
cmp    $0x200000,%edi
jb     1158 <byte_num_or_die+0x38>
mov    $0x5,%al
cmp    $0x4000000,%edi
jb     1158 <byte_num_or_die+0x38>
mov    $0x6,%al
test   %edi,%edi
js     1159 <byte_num_or_die+0x39>
ret
push   %rax
mov    0x2e7f(%rip),%rax
mov    (%rax),%edi
lea    0xe96(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e62(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [14 x i8] c"not supported\00"
@EXIT_FAILURE = global i32 0
define zeroext i8 @byte_num_or_die(i32 %0) {
%2 = alloca i8
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = and i32 %4, -128
%6 = icmp ne i32 %5, 0
br i1 %6, label %8, label %7
7: ; preds = %1
store i8 1, i8* %2
br label %39
8: ; preds = %1
%9 = load i32, i32* %3
%10 = and i32 %9, -2048
%11 = icmp ne i32 %10, 0
br i1 %11, label %13, label %12
12: ; preds = %8
store i8 2, i8* %2
br label %39
13: ; preds = %8
%14 = load i32, i32* %3
%15 = and i32 %14, -65536
%16 = icmp ne i32 %15, 0
br i1 %16, label %18, label %17
17: ; preds = %13
store i8 3, i8* %2
br label %39
18: ; preds = %13
%19 = load i32, i32* %3
%20 = and i32 %19, -2097152
%21 = icmp ne i32 %20, 0
br i1 %21, label %23, label %22
22: ; preds = %18
store i8 4, i8* %2
br label %39
23: ; preds = %18
%24 = load i32, i32* %3
%25 = and i32 %24, -67108864
%26 = icmp ne i32 %25, 0
br i1 %26, label %28, label %27
27: ; preds = %23
store i8 5, i8* %2
br label %39
28: ; preds = %23
%29 = load i32, i32* %3
%30 = and i32 %29, -2147483648
%31 = icmp ne i32 %30, 0
br i1 %31, label %33, label %32
32: ; preds = %28
store i8 6, i8* %2
br label %39
33: ; preds = %28
br label %34
34: ; preds = %33
%35 = load i32, i32* @stderr
%36 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%37 = load i32, i32* @EXIT_FAILURE
%38 = call i32 @exit(i32 %37)
unreachable
39: ; preds = %7, %12, %17, %22, %27, %32
%40 = load i8, i8* %2
ret i8 %40
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [14 x i8] c"not supported\00"
@EXIT_FAILURE = global i32 0
define zeroext i8 @byte_num_or_die(i32 %0) {
%2 = icmp ult i32 %0, 128
br i1 %2, label %18, label %3
3: ; preds = %1
%4 = icmp ult i32 %0, 2048
br i1 %4, label %18, label %5
5: ; preds = %3
%6 = icmp ult i32 %0, 65536
br i1 %6, label %18, label %7
7: ; preds = %5
%8 = icmp ult i32 %0, 2097152
br i1 %8, label %18, label %9
9: ; preds = %7
%10 = icmp ult i32 %0, 67108864
br i1 %10, label %18, label %11
11: ; preds = %9
%12 = icmp sgt i32 %0, -1
br i1 %12, label %18, label %13
13: ; preds = %11
%14 = load i32, i32* @stderr
%15 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%16 = load i32, i32* @EXIT_FAILURE
%17 = tail call i32 @exit(i32 %16)
unreachable
18: ; preds = %11, %9, %7, %5, %3, %1
%19 = phi i8 [ 1, %1 ], [ 2, %3 ], [ 3, %5 ], [ 4, %7 ], [ 5, %9 ], [ 6, %11 ]
ret i8 %19
}