void doit(char *probe) {
  for (int off = 0; off < 64; off++) {
    unsigned int hist[256] = {0};
    ridl_byte(probe, off, hist);
    volatile unsigned char c = max_char(hist);
    asm volatile("mov $1, %%rax\n\t"
                 "mov $1, %%rdi\n\t"
                 "mov %0, %%rsi\n\t"
                 "mov $1, %%rdx\n\t"
                 "syscall\n\t" ::"r"(&c)
                 : "rax", "rdi", "rsi", "rdx", "rcx", "r11");
  }
}


x86 assembly (clang, -O0):
<doit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x40,-0xc(%rbp)
jge    11bb <doit+0x8b>
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1040 <memset@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
lea    -0x410(%rbp),%rdx
mov    $0x0,%al
call   1050 <ridl_byte@plt>
lea    -0x410(%rbp),%rdi
mov    $0x0,%al
call   1030 <max_char@plt>
mov    %al,-0x411(%rbp)
lea    -0x411(%rbp),%r8
mov    $0x1,%rax
mov    $0x1,%rdi
mov    %r8,%rsi
mov    $0x1,%rdx
syscall
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1146 <doit+0x16>
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<doit>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x418,%rsp
mov    %rdi,%r14
lea    0x10(%rsp),%rbx
lea    0xf(%rsp),%r15
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    $0x400,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <ridl_byte@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <max_char@plt>
mov    %al,0xf(%rsp)
mov    $0x1,%rax
mov    $0x1,%rdi
mov    %r15,%rsi
mov    $0x1,%rdx
syscall
add    $0x1,%ebp
cmp    $0x40,%ebp
jne    1150 <doit+0x20>
add    $0x418,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @doit(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca [256 x i32]
%5 = alloca i8
store i8* %0, i8** %2
store i32 0, i32* %3
br label %6
6: ; preds = %18, %1
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 64
br i1 %8, label %9, label %21
9: ; preds = %6
%10 = bitcast [256 x i32]* %4 to i8*
%11 = load i8*, i8** %2
%12 = load i32, i32* %3
%13 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 0
%14 = call i32 (i8*, i32, i32*, ...) bitcast (i32 (...)* @ridl_byte to i32 (i8*, i32, i32*, ...)*)(i8* %11, i32 %12, i32* %13)
%15 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 0
%16 = call i32 (i32*, ...) bitcast (i32 (...)* @max_char to i32 (i32*, ...)*)(i32* %15)
%17 = trunc i32 %16 to i8
store volatile i8 %17, i8* %5
br label %18
18: ; preds = %9
%19 = load i32, i32* %3
%20 = add nsw i32 %19, 1
store i32 %20, i32* %3
br label %6
21: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @doit(i8* %0) {
%2 = alloca [256 x i32]
%3 = alloca i8
%4 = bitcast [256 x i32]* %2 to i8*
%5 = getelementptr inbounds [256 x i32], [256 x i32]* %2, i64 0, i64 0
br label %7
6: ; preds = %7
ret void
7: ; preds = %1, %7
%8 = phi i32 [ 0, %1 ], [ %12, %7 ]
%9 = call i32 (i8*, i32, i32*, ...) bitcast (i32 (...)* @ridl_byte to i32 (i8*, i32, i32*, ...)*)(i8* %0, i32 %8, i32* %5)
%10 = call i32 (i32*, ...) bitcast (i32 (...)* @max_char to i32 (i32*, ...)*)(i32* %5)
%11 = trunc i32 %10 to i8
store volatile i8 %11, i8* %3
%12 = add nuw nsw i32 %8, 1
%13 = icmp eq i32 %12, 64
br i1 %13, label %6, label %7
}