#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 */

/* Variables and functions */
scalar_t__ RAND_MAX;
char get_random_char();
double random();
void mutate(char *str) {
  int i = 0;
  for (; i < 28; i++) {
    if (random() / (double)RAND_MAX <= 1.0 / 28.0) {
      str[i] = get_random_char();
    }
  }
}


x86 assembly (clang, -O0):
<mutate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x1c,-0xc(%rbp)
jge    1190 <mutate+0x70>
mov    $0x0,%al
call   1040 <random@plt>
movaps %xmm0,%xmm1
mov    0x2e9a(%rip),%rax
cvtsi2sdq (%rax),%xmm0
divsd  %xmm0,%xmm1
movsd  0xea1(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     117d <mutate+0x5d>
mov    $0x0,%al
call   1030 <get_random_char@plt>
mov    %al,%dl
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    1182 <mutate+0x62>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1133 <mutate+0x13>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mutate>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
mov    0x2eb9(%rip),%r15
xor    %ebx,%ebx
jmp    114a <mutate+0x2a>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbx
cmp    $0x1c,%rbx
je     1178 <mutate+0x58>
xor    %eax,%eax
call   1040 <random@plt>
xorps  %xmm1,%xmm1
cvtsi2sdq (%r15),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe9b(%rip),%xmm1
ucomisd %xmm0,%xmm1
jb     1140 <mutate+0x20>
xor    %eax,%eax
call   1030 <get_random_char@plt>
mov    %al,(%r14,%rbx,1)
jmp    1140 <mutate+0x20>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@RAND_MAX = global i64 0
define void @mutate(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
br label %4
4: ; preds = %20, %1
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 28
br i1 %6, label %7, label %23
7: ; preds = %4
%8 = call double (...) @random()
%9 = load i64, i64* @RAND_MAX
%10 = sitofp i64 %9 to double
%11 = fdiv double %8, %10
%12 = fcmp ole double %11, 0x3FA2492492492492
br i1 %12, label %13, label %19
13: ; preds = %7
%14 = call signext i8 (...) @get_random_char()
%15 = load i8*, i8** %2
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
store i8 %14, i8* %18
br label %19
19: ; preds = %13, %7
br label %20
20: ; preds = %19
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
br label %4
23: ; preds = %4
ret void
}

LLVM IR (-O2):
@RAND_MAX = global i64 0
define void @mutate(i8* nocapture writeonly %0) {
br label %2
2: ; preds = %1, %12
%3 = phi i64 [ 0, %1 ], [ %13, %12 ]
%4 = tail call double (...) @random()
%5 = load i64, i64* @RAND_MAX
%6 = sitofp i64 %5 to double
%7 = fdiv double %4, %6
%8 = fcmp ugt double %7, 0x3FA2492492492492
br i1 %8, label %12, label %9
9: ; preds = %2
%10 = tail call signext i8 (...) @get_random_char()
%11 = getelementptr inbounds i8, i8* %0, i64 %3
store i8 %10, i8* %11
br label %12
12: ; preds = %2, %9
%13 = add nuw nsw i64 %3, 1
%14 = icmp eq i64 %13, 28
br i1 %14, label %15, label %2
15: ; preds = %12
ret void
}