int main(void) {
  unsigned i;
  for (i = 0; i < sizeof(0ull); i++) {
    unsigned long long m = ((1ull << (((i)*8) - 1) << 1) - 1);
    unsigned long long s1 = ((1ull << (((i)*8 - 1) - 1) << 1) - 1);
    unsigned long long s2 = byte_width_max_2c_2(i);
    printf("%u : %llu %llu %llu\n", i, m, s1, s2);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    $0x8,%rax
jae    11c3 <main+0xa3>
mov    -0x8(%rbp),%eax
shl    $0x3,%eax
sub    $0x1,%eax
mov    %eax,%eax
mov    %eax,%ecx
mov    $0x1,%eax
shl    %cl,%rax
shl    $0x1,%rax
sub    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
shl    $0x3,%eax
sub    $0x1,%eax
sub    $0x1,%eax
mov    %eax,%eax
mov    %eax,%ecx
mov    $0x1,%eax
shl    %cl,%rax
shl    $0x1,%rax
sub    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x0,%al
call   1040 <byte_width_max_2c_2@plt>
cltq
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1136 <main+0x16>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %edi,%edi
xor    %eax,%eax
call   1040 <byte_width_max_2c_2@plt>
movslq %eax,%r8
lea    0xecc(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%edi
xor    %eax,%eax
call   1040 <byte_width_max_2c_2@plt>
movslq %eax,%r8
mov    $0xff,%edx
mov    $0x7f,%ecx
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x2,%edi
xor    %eax,%eax
call   1040 <byte_width_max_2c_2@plt>
movslq %eax,%r8
mov    $0xffff,%edx
mov    $0x7fff,%ecx
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x3,%edi
xor    %eax,%eax
call   1040 <byte_width_max_2c_2@plt>
movslq %eax,%r8
mov    $0xffffff,%edx
mov    $0x7fffff,%ecx
mov    %rbx,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x4,%edi
xor    %eax,%eax
call   1040 <byte_width_max_2c_2@plt>
movslq %eax,%r8
mov    $0xffffffff,%edx
mov    $0x7fffffff,%ecx
mov    %rbx,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x5,%edi
xor    %eax,%eax
call   1040 <byte_width_max_2c_2@plt>
movslq %eax,%r8
movabs $0xffffffffff,%rdx
movabs $0x7fffffffff,%rcx
mov    %rbx,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x6,%edi
xor    %eax,%eax
call   1040 <byte_width_max_2c_2@plt>
movslq %eax,%r8
movabs $0xffffffffffff,%rdx
movabs $0x7fffffffffff,%rcx
mov    %rbx,%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x7,%edi
xor    %eax,%eax
call   1040 <byte_width_max_2c_2@plt>
movslq %eax,%r8
movabs $0xffffffffffffff,%rdx
movabs $0x7fffffffffffff,%rcx
mov    %rbx,%rdi
mov    $0x7,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [21 x i8] c"%u : %llu %llu %llu\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
store i32 0, i32* %1
store i32 0, i32* %2
br label %6
6: ; preds = %34, %0
%7 = load i32, i32* %2
%8 = zext i32 %7 to i64
%9 = icmp ult i64 %8, 8
br i1 %9, label %10, label %37
10: ; preds = %6
%11 = load i32, i32* %2
%12 = mul i32 %11, 8
%13 = sub i32 %12, 1
%14 = zext i32 %13 to i64
%15 = shl i64 1, %14
%16 = shl i64 %15, 1
%17 = sub i64 %16, 1
store i64 %17, i64* %3
%18 = load i32, i32* %2
%19 = mul i32 %18, 8
%20 = sub i32 %19, 1
%21 = sub i32 %20, 1
%22 = zext i32 %21 to i64
%23 = shl i64 1, %22
%24 = shl i64 %23, 1
%25 = sub i64 %24, 1
store i64 %25, i64* %4
%26 = load i32, i32* %2
%27 = call i32 (i32, ...) bitcast (i32 (...)* @byte_width_max_2c_2 to i32 (i32, ...)*)(i32 %26)
%28 = sext i32 %27 to i64
store i64 %28, i64* %5
%29 = load i32, i32* %2
%30 = load i64, i64* %3
%31 = load i64, i64* %4
%32 = load i64, i64* %5
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %29, i64 %30, i64 %31, i64 %32)
br label %34
34: ; preds = %10
%35 = load i32, i32* %2
%36 = add i32 %35, 1
store i32 %36, i32* %2
br label %6
37: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c"%u : %llu %llu %llu\0A\00"
define i32 @main() {
%1 = tail call i32 (i32, ...) bitcast (i32 (...)* @byte_width_max_2c_2 to i32 (i32, ...)*)(i32 0)
%2 = sext i32 %1 to i64
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 0, i64 poison, i64 poison, i64 %2)
%4 = tail call i32 (i32, ...) bitcast (i32 (...)* @byte_width_max_2c_2 to i32 (i32, ...)*)(i32 1)
%5 = sext i32 %4 to i64
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 1, i64 255, i64 127, i64 %5)
%7 = tail call i32 (i32, ...) bitcast (i32 (...)* @byte_width_max_2c_2 to i32 (i32, ...)*)(i32 2)
%8 = sext i32 %7 to i64
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 2, i64 65535, i64 32767, i64 %8)
%10 = tail call i32 (i32, ...) bitcast (i32 (...)* @byte_width_max_2c_2 to i32 (i32, ...)*)(i32 3)
%11 = sext i32 %10 to i64
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 3, i64 16777215, i64 8388607, i64 %11)
%13 = tail call i32 (i32, ...) bitcast (i32 (...)* @byte_width_max_2c_2 to i32 (i32, ...)*)(i32 4)
%14 = sext i32 %13 to i64
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 4, i64 4294967295, i64 2147483647, i64 %14)
%16 = tail call i32 (i32, ...) bitcast (i32 (...)* @byte_width_max_2c_2 to i32 (i32, ...)*)(i32 5)
%17 = sext i32 %16 to i64
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 5, i64 1099511627775, i64 549755813887, i64 %17)
%19 = tail call i32 (i32, ...) bitcast (i32 (...)* @byte_width_max_2c_2 to i32 (i32, ...)*)(i32 6)
%20 = sext i32 %19 to i64
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 6, i64 281474976710655, i64 140737488355327, i64 %20)
%22 = tail call i32 (i32, ...) bitcast (i32 (...)* @byte_width_max_2c_2 to i32 (i32, ...)*)(i32 7)
%23 = sext i32 %22 to i64
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 7, i64 72057594037927935, i64 36028797018963967, i64 %23)
ret i32 0
}