void databingen(mode, buffer, bsize, offset) int mode;
unsigned char *buffer;
int bsize;
int offset;
{
  int ind;
  switch (mode) {
  default:
  case 'a':
    memset(buffer, 0x55, bsize);
    break;
  case 'c':
    memset(buffer, 0xf0, bsize);
    break;
  case 'C':
    for (ind = 0; ind < bsize; ind++) {
      buffer[ind] = ((offset + ind) % 8 & 0177);
    }
    break;
  case 'o':
    memset(buffer, 0xff, bsize);
    break;
  case 'z':
    memset(buffer, 0x0, bsize);
    break;
  case 'r':
    for (ind = 0; ind < bsize; ind++) {
      buffer[ind] = (rand() & 0177) | 0100;
    }
  }
}


x86 assembly (clang, -O0):
<databingen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffffbd,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x37,%eax
ja     115e <databingen+0x3e>
mov    -0x28(%rbp),%rax
lea    0xeab(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
jmp    1163 <databingen+0x43>
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rdx
mov    $0x55,%esi
call   1030 <memset@plt>
jmp    123e <databingen+0x11e>
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rdx
mov    $0xf0,%esi
call   1030 <memset@plt>
jmp    123e <databingen+0x11e>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11ce <databingen+0xae>
mov    -0x18(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
and    $0x7f,%edx
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1198 <databingen+0x78>
jmp    123e <databingen+0x11e>
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rdx
mov    $0xff,%esi
call   1030 <memset@plt>
jmp    123e <databingen+0x11e>
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rdx
xor    %esi,%esi
call   1030 <memset@plt>
jmp    123e <databingen+0x11e>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1239 <databingen+0x119>
mov    $0x0,%al
call   1040 <rand@plt>
and    $0x7f,%eax
or     $0x40,%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1205 <databingen+0xe5>
jmp    123e <databingen+0x11e>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<databingen>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
lea    -0x63(%rdi),%eax
cmp    $0x17,%eax
ja     114d <databingen+0x2d>
lea    0xf59(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movslq %edx,%rdx
mov    %r14,%rdi
mov    $0xf0,%esi
jmp    11b5 <databingen+0x95>
cmp    $0x43,%edi
jne    1168 <databingen+0x48>
test   %edx,%edx
jle    1511 <databingen+0x3f1>
mov    %edx,%eax
cmp    $0x10,%edx
jae    11bf <databingen+0x9f>
xor    %edx,%edx
jmp    14e9 <databingen+0x3c9>
movslq %edx,%rdx
mov    %r14,%rdi
mov    $0x55,%esi
jmp    11b5 <databingen+0x95>
movslq %edx,%rdx
mov    %r14,%rdi
mov    $0xff,%esi
jmp    11b5 <databingen+0x95>
test   %edx,%edx
jle    1511 <databingen+0x3f1>
mov    %edx,%r15d
xor    %ebx,%ebx
nop
xor    %eax,%eax
call   1040 <rand@plt>
and    $0x3f,%al
or     $0x40,%al
mov    %al,(%r14,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1190 <databingen+0x70>
jmp    1511 <databingen+0x3f1>
movslq %edx,%rdx
mov    %r14,%rdi
xor    %esi,%esi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <memset@plt>
mov    %eax,%edx
and    $0xfffffff0,%edx
movd   %ecx,%xmm0
pshufd $0x0,%xmm0,%xmm11
lea    -0x10(%rdx),%rsi
mov    %rsi,%r8
shr    $0x4,%r8
add    $0x1,%r8
test   %rsi,%rsi
je     13ea <databingen+0x2ca>
mov    %r8,%rdi
and    $0xfffffffffffffffe,%rdi
movdqa 0xe0a(%rip),%xmm14
movdqa 0xe11(%rip),%xmm8
movdqa 0xe18(%rip),%xmm9
movdqa 0xe1f(%rip),%xmm10
xor    %esi,%esi
movdqa 0xe24(%rip),%xmm12
movdqa 0xe2b(%rip),%xmm13
cs nopw 0x0(%rax,%rax,1)
nop
movdqa %xmm10,%xmm7
paddd  %xmm11,%xmm7
movdqa %xmm9,%xmm6
paddd  %xmm11,%xmm6
movdqa %xmm8,%xmm15
paddd  %xmm11,%xmm15
movdqa %xmm14,%xmm1
paddd  %xmm11,%xmm1
movdqa %xmm1,%xmm0
psrad  $0x1f,%xmm0
psrld  $0x1d,%xmm0
paddd  %xmm1,%xmm0
pand   %xmm12,%xmm0
movdqa %xmm1,%xmm5
psubd  %xmm0,%xmm5
movdqa %xmm15,%xmm4
psrad  $0x1f,%xmm4
psrld  $0x1d,%xmm4
paddd  %xmm15,%xmm4
pand   %xmm12,%xmm4
movdqa %xmm15,%xmm0
psubd  %xmm4,%xmm0
movdqa %xmm6,%xmm4
psrad  $0x1f,%xmm4
psrld  $0x1d,%xmm4
paddd  %xmm6,%xmm4
pand   %xmm12,%xmm4
movdqa %xmm6,%xmm3
psubd  %xmm4,%xmm3
movdqa %xmm7,%xmm4
psrad  $0x1f,%xmm4
psrld  $0x1d,%xmm4
paddd  %xmm7,%xmm4
pand   %xmm12,%xmm4
movdqa %xmm7,%xmm2
psubd  %xmm4,%xmm2
pand   %xmm13,%xmm2
pand   %xmm13,%xmm3
packuswb %xmm3,%xmm2
pand   %xmm13,%xmm0
pand   %xmm13,%xmm5
packuswb %xmm5,%xmm0
packuswb %xmm0,%xmm2
movdqa 0xd61(%rip),%xmm3
pand   %xmm3,%xmm2
movdqu %xmm2,(%r14,%rsi,1)
movdqa 0xd5f(%rip),%xmm0
paddd  %xmm0,%xmm7
paddd  %xmm0,%xmm6
paddd  %xmm0,%xmm15
paddd  %xmm0,%xmm1
movdqa %xmm1,%xmm0
psrad  $0x1f,%xmm0
psrld  $0x1d,%xmm0
paddd  %xmm1,%xmm0
pand   %xmm12,%xmm0
psubd  %xmm0,%xmm1
movdqa %xmm15,%xmm0
psrad  $0x1f,%xmm0
psrld  $0x1d,%xmm0
paddd  %xmm15,%xmm0
pand   %xmm12,%xmm0
psubd  %xmm0,%xmm15
movdqa %xmm6,%xmm0
psrad  $0x1f,%xmm0
psrld  $0x1d,%xmm0
paddd  %xmm6,%xmm0
pand   %xmm12,%xmm0
psubd  %xmm0,%xmm6
movdqa %xmm7,%xmm0
psrad  $0x1f,%xmm0
psrld  $0x1d,%xmm0
paddd  %xmm7,%xmm0
pand   %xmm12,%xmm0
psubd  %xmm0,%xmm7
pand   %xmm13,%xmm7
pand   %xmm13,%xmm6
packuswb %xmm6,%xmm7
pand   %xmm13,%xmm15
pand   %xmm13,%xmm1
packuswb %xmm1,%xmm15
packuswb %xmm15,%xmm7
pand   %xmm3,%xmm7
movdqu %xmm7,0x10(%r14,%rsi,1)
add    $0x20,%rsi
movdqa 0xcb6(%rip),%xmm0
paddd  %xmm0,%xmm10
paddd  %xmm0,%xmm9
paddd  %xmm0,%xmm8
paddd  %xmm0,%xmm14
add    $0xfffffffffffffffe,%rdi
jne    1230 <databingen+0x110>
jmp    1410 <databingen+0x2f0>
movdqa 0xc0d(%rip),%xmm14
movdqa 0xc14(%rip),%xmm8
movdqa 0xc1b(%rip),%xmm9
movdqa 0xc22(%rip),%xmm10
xor    %esi,%esi
test   $0x1,%r8b
je     14e4 <databingen+0x3c4>
paddd  %xmm11,%xmm10
paddd  %xmm11,%xmm9
paddd  %xmm11,%xmm8
paddd  %xmm11,%xmm14
movdqa %xmm14,%xmm0
psrad  $0x1f,%xmm0
psrld  $0x1d,%xmm0
paddd  %xmm14,%xmm0
movdqa 0xbf6(%rip),%xmm1
pand   %xmm1,%xmm0
psubd  %xmm0,%xmm14
movdqa %xmm8,%xmm0
psrad  $0x1f,%xmm0
psrld  $0x1d,%xmm0
paddd  %xmm8,%xmm0
pand   %xmm1,%xmm0
psubd  %xmm0,%xmm8
movdqa %xmm9,%xmm0
psrad  $0x1f,%xmm0
psrld  $0x1d,%xmm0
paddd  %xmm9,%xmm0
pand   %xmm1,%xmm0
psubd  %xmm0,%xmm9
movdqa %xmm10,%xmm0
psrad  $0x1f,%xmm0
psrld  $0x1d,%xmm0
paddd  %xmm10,%xmm0
pand   %xmm1,%xmm0
psubd  %xmm0,%xmm10
movdqa 0xb9e(%rip),%xmm0
pand   %xmm0,%xmm10
pand   %xmm0,%xmm9
packuswb %xmm9,%xmm10
pand   %xmm0,%xmm8
pand   %xmm0,%xmm14
packuswb %xmm14,%xmm8
packuswb %xmm8,%xmm10
pand   0xb82(%rip),%xmm10
movdqu %xmm10,(%r14,%rsi,1)
cmp    %rax,%rdx
je     1511 <databingen+0x3f1>
mov    %ecx,%ecx
nopl   0x0(%rax,%rax,1)
mov    %ecx,%esi
add    %edx,%esi
lea    0x7(%rcx,%rdx,1),%edi
cmovns %esi,%edi
and    $0x78,%edi
sub    %edi,%esi
and    $0x7f,%sil
mov    %sil,(%r14,%rdx,1)
add    $0x1,%rdx
cmp    %rdx,%rax
jne    14f0 <databingen+0x3d0>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @databingen(i32 %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load i32, i32* %5
switch i32 %10, label %11 [
i32 97, label %12
i32 99, label %16
i32 67, label %20
i32 111, label %40
i32 122, label %44
i32 114, label %48
]
11: ; preds = %4
br label %12
12: ; preds = %4, %11
%13 = load i8*, i8** %6
%14 = load i32, i32* %7
%15 = sext i32 %14 to i64
br label %66
16: ; preds = %4
%17 = load i8*, i8** %6
%18 = load i32, i32* %7
%19 = sext i32 %18 to i64
br label %66
20: ; preds = %4
store i32 0, i32* %9
br label %21
21: ; preds = %36, %20
%22 = load i32, i32* %9
%23 = load i32, i32* %7
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %39
25: ; preds = %21
%26 = load i32, i32* %8
%27 = load i32, i32* %9
%28 = add nsw i32 %26, %27
%29 = srem i32 %28, 8
%30 = and i32 %29, 127
%31 = trunc i32 %30 to i8
%32 = load i8*, i8** %6
%33 = load i32, i32* %9
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
store i8 %31, i8* %35
br label %36
36: ; preds = %25
%37 = load i32, i32* %9
%38 = add nsw i32 %37, 1
store i32 %38, i32* %9
br label %21
39: ; preds = %21
br label %66
40: ; preds = %4
%41 = load i8*, i8** %6
%42 = load i32, i32* %7
%43 = sext i32 %42 to i64
br label %66
44: ; preds = %4
%45 = load i8*, i8** %6
%46 = load i32, i32* %7
%47 = sext i32 %46 to i64
br label %66
48: ; preds = %4
store i32 0, i32* %9
br label %49
49: ; preds = %62, %48
%50 = load i32, i32* %9
%51 = load i32, i32* %7
%52 = icmp slt i32 %50, %51
br i1 %52, label %53, label %65
53: ; preds = %49
%54 = call i32 (...) @rand()
%55 = and i32 %54, 127
%56 = or i32 %55, 64
%57 = trunc i32 %56 to i8
%58 = load i8*, i8** %6
%59 = load i32, i32* %9
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i8, i8* %58, i64 %60
store i8 %57, i8* %61
br label %62
62: ; preds = %53
%63 = load i32, i32* %9
%64 = add nsw i32 %63, 1
store i32 %64, i32* %9
br label %49
65: ; preds = %49
br label %66
66: ; preds = %65, %44, %40, %39, %16, %12
ret void
}

LLVM IR (-O2):
define void @databingen(i32 %0, i8* nocapture writeonly %1, i32 %2, i32 %3) {
switch i32 %0, label %62 [
i32 114, label %58
i32 99, label %64
i32 67, label %5
i32 111, label %76
i32 122, label %78
]
5: ; preds = %4
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %89
7: ; preds = %5
%8 = zext i32 %2 to i64
%9 = icmp ult i32 %2, 16
br i1 %9, label %56, label %10
10: ; preds = %7
%11 = and i64 %8, 4294967280
%12 = insertelement <16 x i32> poison, i32 %3, i64 0
%13 = shufflevector <16 x i32> %12, <16 x i32> poison, <16 x i32> zeroinitializer
%14 = add nsw i64 %11, -16
%15 = lshr exact i64 %14, 4
%16 = add nuw nsw i64 %15, 1
%17 = and i64 %16, 1
%18 = icmp eq i64 %14, 0
br i1 %18, label %43, label %19
19: ; preds = %10
%20 = and i64 %16, 2305843009213693950
br label %21
21: ; preds = %21, %19
%22 = phi i64 [ 0, %19 ], [ %39, %21 ]
%23 = phi <16 x i32> [ <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>, %19 ], [ %40, %21 ]
%24 = phi i64 [ 0, %19 ], [ %41, %21 ]
%25 = add nsw <16 x i32> %23, %13
%26 = srem <16 x i32> %25, <i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8>
%27 = trunc <16 x i32> %26 to <16 x i8>
%28 = and <16 x i8> %27, <i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127>
%29 = getelementptr inbounds i8, i8* %1, i64 %22
%30 = bitcast i8* %29 to <16 x i8>*
store <16 x i8> %28, <16 x i8>* %30
%31 = or i64 %22, 16
%32 = add <16 x i32> %23, <i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16>
%33 = add nsw <16 x i32> %32, %13
%34 = srem <16 x i32> %33, <i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8>
%35 = trunc <16 x i32> %34 to <16 x i8>
%36 = and <16 x i8> %35, <i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127>
%37 = getelementptr inbounds i8, i8* %1, i64 %31
%38 = bitcast i8* %37 to <16 x i8>*
store <16 x i8> %36, <16 x i8>* %38
%39 = add nuw i64 %22, 32
%40 = add <16 x i32> %23, <i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32>
%41 = add i64 %24, 2
%42 = icmp eq i64 %41, %20
br i1 %42, label %43, label %21
43: ; preds = %21, %10
%44 = phi i64 [ 0, %10 ], [ %39, %21 ]
%45 = phi <16 x i32> [ <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>, %10 ], [ %40, %21 ]
%46 = icmp eq i64 %17, 0
br i1 %46, label %54, label %47
47: ; preds = %43
%48 = add nsw <16 x i32> %45, %13
%49 = srem <16 x i32> %48, <i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8>
%50 = trunc <16 x i32> %49 to <16 x i8>
%51 = and <16 x i8> %50, <i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127>
%52 = getelementptr inbounds i8, i8* %1, i64 %44
%53 = bitcast i8* %52 to <16 x i8>*
store <16 x i8> %51, <16 x i8>* %53
br label %54
54: ; preds = %43, %47
%55 = icmp eq i64 %11, %8
br i1 %55, label %89, label %56
56: ; preds = %7, %54
%57 = phi i64 [ 0, %7 ], [ %11, %54 ]
br label %66
58: ; preds = %4
%59 = icmp sgt i32 %2, 0
br i1 %59, label %60, label %89
60: ; preds = %58
%61 = zext i32 %2 to i64
br label %80
62: ; preds = %4
%63 = sext i32 %2 to i64
tail call void @llvm.memset.p0i8.i64(i8* align 1 %1, i8 85, i64 %63, i1 false)
br label %89
64: ; preds = %4
%65 = sext i32 %2 to i64
tail call void @llvm.memset.p0i8.i64(i8* align 1 %1, i8 -16, i64 %65, i1 false)
br label %89
66: ; preds = %56, %66
%67 = phi i64 [ %74, %66 ], [ %57, %56 ]
%68 = trunc i64 %67 to i32
%69 = add nsw i32 %68, %3
%70 = srem i32 %69, 8
%71 = trunc i32 %70 to i8
%72 = and i8 %71, 127
%73 = getelementptr inbounds i8, i8* %1, i64 %67
store i8 %72, i8* %73
%74 = add nuw nsw i64 %67, 1
%75 = icmp eq i64 %74, %8
br i1 %75, label %89, label %66
76: ; preds = %4
%77 = sext i32 %2 to i64
tail call void @llvm.memset.p0i8.i64(i8* align 1 %1, i8 -1, i64 %77, i1 false)
br label %89
78: ; preds = %4
%79 = sext i32 %2 to i64
tail call void @llvm.memset.p0i8.i64(i8* align 1 %1, i8 0, i64 %79, i1 false)
br label %89
80: ; preds = %60, %80
%81 = phi i64 [ 0, %60 ], [ %87, %80 ]
%82 = tail call i32 (...) @rand()
%83 = trunc i32 %82 to i8
%84 = and i8 %83, 63
%85 = or i8 %84, 64
%86 = getelementptr inbounds i8, i8* %1, i64 %81
store i8 %85, i8* %86
%87 = add nuw nsw i64 %81, 1
%88 = icmp eq i64 %87, %61
br i1 %88, label %89, label %80
89: ; preds = %66, %80, %54, %5, %58, %78, %76, %64, %62
ret void
}