void sample_string_C(char *s, int i) {
  s[0] = (char)(1 + (i % 254));
  s[1] = (char)(1 + ((i / 254) % 254));
  s[2] = 'a';
  s[3] = (char)(1 + ((i * (i - 3)) % 217));
  s[4] = (char)(1 + ((17 * i + 129) % 233));
  s[5] = '\0';
}


x86 assembly (clang, -O0):
<sample_string_C>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0xfe,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %dl,%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
mov    -0xc(%rbp),%eax
mov    $0xfe,%ecx
cltd
idiv   %ecx
mov    $0xfe,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %dl,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x8(%rbp),%rax
movb   $0x61,0x2(%rax)
mov    -0xc(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x3,%ecx
imul   %ecx,%eax
mov    $0xd9,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %dl,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x3(%rax)
imul   $0x11,-0xc(%rbp),%eax
add    $0x81,%eax
mov    $0xe9,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %dl,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x4(%rax)
mov    -0x8(%rbp),%rax
movb   $0x0,0x5(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<sample_string_C>:
movslq %esi,%rax
imul   $0xffffffff81020409,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x7,%ecx
add    %edx,%ecx
lea    (%rcx,%rcx,1),%edx
add    %eax,%edx
add    $0x1,%dl
mov    %dl,(%rdi)
movslq %ecx,%rcx
imul   $0xffffffff81020409,%rcx,%rdx
shr    $0x20,%rdx
add    %ecx,%edx
mov    %edx,%esi
shr    $0x1f,%esi
shr    $0x7,%edx
add    %esi,%edx
add    %edx,%edx
add    %ecx,%edx
add    $0x1,%dl
mov    %dl,0x1(%rdi)
movb   $0x61,0x2(%rdi)
lea    -0x3(%rax),%ecx
imul   %eax,%ecx
movslq %ecx,%rcx
imul   $0xffffffff97012e03,%rcx,%rdx
shr    $0x20,%rdx
add    %ecx,%edx
mov    %edx,%esi
shr    $0x1f,%esi
shr    $0x7,%edx
add    %esi,%edx
imul   $0xd9,%edx,%edx
sub    %edx,%ecx
add    $0x1,%cl
mov    %cl,0x3(%rdi)
mov    %eax,%ecx
shl    $0x4,%ecx
lea    (%rax,%rcx,1),%edx
add    $0x81,%edx
add    %ecx,%eax
movslq %edx,%rcx
imul   $0xffffffff8ca29c05,%rcx,%rdx
shr    $0x20,%rdx
add    %edx,%eax
add    $0x81,%eax
mov    %eax,%edx
shr    $0x1f,%edx
shr    $0x7,%eax
add    %edx,%eax
imul   $0xe9,%eax,%eax
sub    %eax,%ecx
add    $0x1,%cl
mov    %cl,0x4(%rdi)
movb   $0x0,0x5(%rdi)
ret

LLVM IR (-O0):
define void @sample_string_C(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = srem i32 %5, 254
%7 = add nsw i32 1, %6
%8 = trunc i32 %7 to i8
%9 = load i8*, i8** %3
%10 = getelementptr inbounds i8, i8* %9, i64 0
store i8 %8, i8* %10
%11 = load i32, i32* %4
%12 = sdiv i32 %11, 254
%13 = srem i32 %12, 254
%14 = add nsw i32 1, %13
%15 = trunc i32 %14 to i8
%16 = load i8*, i8** %3
%17 = getelementptr inbounds i8, i8* %16, i64 1
store i8 %15, i8* %17
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i64 2
store i8 97, i8* %19
%20 = load i32, i32* %4
%21 = load i32, i32* %4
%22 = sub nsw i32 %21, 3
%23 = mul nsw i32 %20, %22
%24 = srem i32 %23, 217
%25 = add nsw i32 1, %24
%26 = trunc i32 %25 to i8
%27 = load i8*, i8** %3
%28 = getelementptr inbounds i8, i8* %27, i64 3
store i8 %26, i8* %28
%29 = load i32, i32* %4
%30 = mul nsw i32 17, %29
%31 = add nsw i32 %30, 129
%32 = srem i32 %31, 233
%33 = add nsw i32 1, %32
%34 = trunc i32 %33 to i8
%35 = load i8*, i8** %3
%36 = getelementptr inbounds i8, i8* %35, i64 4
store i8 %34, i8* %36
%37 = load i8*, i8** %3
%38 = getelementptr inbounds i8, i8* %37, i64 5
store i8 0, i8* %38
ret void
}

LLVM IR (-O2):
define void @sample_string_C(i8* nocapture writeonly %0, i32 %1) {
%3 = srem i32 %1, 254
%4 = trunc i32 %3 to i8
%5 = add i8 %4, 1
store i8 %5, i8* %0
%6 = sdiv i32 %1, 254
%7 = srem i32 %6, 254
%8 = trunc i32 %7 to i8
%9 = add i8 %8, 1
%10 = getelementptr inbounds i8, i8* %0, i64 1
store i8 %9, i8* %10
%11 = getelementptr inbounds i8, i8* %0, i64 2
store i8 97, i8* %11
%12 = add nsw i32 %1, -3
%13 = mul nsw i32 %12, %1
%14 = srem i32 %13, 217
%15 = trunc i32 %14 to i8
%16 = add i8 %15, 1
%17 = getelementptr inbounds i8, i8* %0, i64 3
store i8 %16, i8* %17
%18 = mul nsw i32 %1, 17
%19 = add nsw i32 %18, 129
%20 = srem i32 %19, 233
%21 = trunc i32 %20 to i8
%22 = add i8 %21, 1
%23 = getelementptr inbounds i8, i8* %0, i64 4
store i8 %22, i8* %23
%24 = getelementptr inbounds i8, i8* %0, i64 5
store i8 0, i8* %24
ret void
}