#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 */
int /*<<< orphan*/ util_random(int, char *);
void util_randomtext(int length, char *result) {
  int l;
  util_random(length, result);
  for (l = 0; l < length; l++)
    result[l] = (unsigned char)((((unsigned char)result[l]) % 10) + '0');
}


x86 assembly (clang, -O0):
<util_randomtext>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <util_random@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    116e <util_randomtext+0x5e>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x30,%edx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1132 <util_randomtext+0x22>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<util_randomtext>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
call   1030 <util_random@plt>
test   %ebp,%ebp
jle    13d5 <util_randomtext+0x2c5>
mov    %ebp,%eax
cmp    $0x8,%ebp
jae    1133 <util_randomtext+0x23>
xor    %ecx,%ecx
jmp    13b0 <util_randomtext+0x2a0>
cmp    $0x10,%ebp
jae    11d7 <util_randomtext+0xc7>
xor    %ecx,%ecx
mov    %rcx,%rdx
mov    %eax,%ecx
and    $0xfffffff8,%ecx
pxor   %xmm0,%xmm0
movdqa 0xeae(%rip),%xmm1
movdqa 0xeb6(%rip),%xmm2
movdqa 0xebe(%rip),%xmm3
movdqa 0xec6(%rip),%xmm4
movdqa 0xede(%rip),%xmm5
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movq   (%rbx,%rdx,1),%xmm6
movdqa %xmm6,%xmm7
punpcklbw %xmm0,%xmm7
pmullw %xmm1,%xmm7
psrlw  $0x8,%xmm7
packuswb %xmm7,%xmm7
psrlw  $0x3,%xmm7
pand   %xmm2,%xmm7
punpcklbw %xmm7,%xmm7
pmullw %xmm3,%xmm7
pand   %xmm4,%xmm7
packuswb %xmm7,%xmm7
psubb  %xmm7,%xmm6
por    %xmm5,%xmm6
movq   %xmm6,(%rbx,%rdx,1)
add    $0x8,%rdx
cmp    %rdx,%rcx
jne    1180 <util_randomtext+0x70>
cmp    %rax,%rcx
jne    13b0 <util_randomtext+0x2a0>
jmp    13d5 <util_randomtext+0x2c5>
mov    %eax,%ecx
and    $0xfffffff0,%ecx
lea    -0x10(%rcx),%rdx
mov    %rdx,%rsi
shr    $0x4,%rsi
add    $0x1,%rsi
test   %rdx,%rdx
je     13dc <util_randomtext+0x2cc>
mov    %rsi,%rdi
and    $0xfffffffffffffffe,%rdi
xor    %edx,%edx
pxor   %xmm0,%xmm0
movdqa 0xdf7(%rip),%xmm1
movdqa 0xdfe(%rip),%xmm8
movdqa 0xe06(%rip),%xmm3
movdqa 0xe0e(%rip),%xmm4
movdqa 0xe15(%rip),%xmm9
nopl   0x0(%rax,%rax,1)
movdqu (%rbx,%rdx,1),%xmm5
movdqu 0x10(%rbx,%rdx,1),%xmm6
movdqa %xmm5,%xmm7
punpckhbw %xmm0,%xmm7
pmullw %xmm1,%xmm7
psrlw  $0x8,%xmm7
movdqa %xmm5,%xmm2
punpcklbw %xmm0,%xmm2
pmullw %xmm1,%xmm2
psrlw  $0x8,%xmm2
packuswb %xmm7,%xmm2
psrlw  $0x3,%xmm2
pand   %xmm8,%xmm2
movdqa %xmm2,%xmm7
punpckhbw %xmm7,%xmm7
pmullw %xmm3,%xmm7
pand   %xmm4,%xmm7
punpcklbw %xmm2,%xmm2
pmullw %xmm3,%xmm2
pand   %xmm4,%xmm2
packuswb %xmm7,%xmm2
psubb  %xmm2,%xmm5
por    %xmm9,%xmm5
movdqu %xmm5,(%rbx,%rdx,1)
movdqa %xmm6,%xmm2
punpckhbw %xmm0,%xmm2
pmullw %xmm1,%xmm2
psrlw  $0x8,%xmm2
movdqa %xmm6,%xmm5
punpcklbw %xmm0,%xmm5
pmullw %xmm1,%xmm5
psrlw  $0x8,%xmm5
packuswb %xmm2,%xmm5
psrlw  $0x3,%xmm5
pand   %xmm8,%xmm5
movdqa %xmm5,%xmm2
punpckhbw %xmm2,%xmm2
pmullw %xmm3,%xmm2
pand   %xmm4,%xmm2
punpcklbw %xmm5,%xmm5
pmullw %xmm3,%xmm5
pand   %xmm4,%xmm5
packuswb %xmm2,%xmm5
psubb  %xmm5,%xmm6
por    %xmm9,%xmm6
movdqu %xmm6,0x10(%rbx,%rdx,1)
add    $0x20,%rdx
add    $0xfffffffffffffffe,%rdi
jne    1230 <util_randomtext+0x120>
test   $0x1,%sil
je     1395 <util_randomtext+0x285>
movdqu (%rbx,%rdx,1),%xmm0
pxor   %xmm1,%xmm1
movdqa %xmm0,%xmm2
punpckhbw %xmm1,%xmm2
movdqa 0xcd7(%rip),%xmm3
pmullw %xmm3,%xmm2
psrlw  $0x8,%xmm2
movdqa %xmm0,%xmm4
punpcklbw %xmm1,%xmm4
pmullw %xmm3,%xmm4
psrlw  $0x8,%xmm4
packuswb %xmm2,%xmm4
psrlw  $0x3,%xmm4
pand   0xcbc(%rip),%xmm4
movdqa %xmm4,%xmm1
punpckhbw %xmm1,%xmm1
movdqa 0xcbc(%rip),%xmm2
pmullw %xmm2,%xmm1
movdqa 0xcc0(%rip),%xmm3
pand   %xmm3,%xmm1
punpcklbw %xmm4,%xmm4
pmullw %xmm2,%xmm4
pand   %xmm3,%xmm4
packuswb %xmm1,%xmm4
psubb  %xmm4,%xmm0
por    0xcb0(%rip),%xmm0
movdqu %xmm0,(%rbx,%rdx,1)
cmp    %rax,%rcx
je     13d5 <util_randomtext+0x2c5>
test   $0x8,%al
jne    113e <util_randomtext+0x2e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl (%rbx,%rcx,1),%edx
imul   $0xcd,%edx,%esi
shr    $0xa,%esi
and    $0xfffffffe,%esi
lea    (%rsi,%rsi,4),%esi
sub    %sil,%dl
or     $0x30,%dl
mov    %dl,(%rbx,%rcx,1)
add    $0x1,%rcx
cmp    %rcx,%rax
jne    13b0 <util_randomtext+0x2a0>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
xor    %edx,%edx
test   $0x1,%sil
jne    1310 <util_randomtext+0x200>
jmp    1395 <util_randomtext+0x285>

LLVM IR (-O0):
define void @util_randomtext(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
%6 = load i32, i32* %3
%7 = load i8*, i8** %4
%8 = call i32 @util_random(i32 %6, i8* %7)
store i32 0, i32* %5
br label %9
9: ; preds = %27, %2
%10 = load i32, i32* %5
%11 = load i32, i32* %3
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %30
13: ; preds = %9
%14 = load i8*, i8** %4
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = srem i32 %19, 10
%21 = add nsw i32 %20, 48
%22 = trunc i32 %21 to i8
%23 = load i8*, i8** %4
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
store i8 %22, i8* %26
br label %27
27: ; preds = %13
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
store i32 %29, i32* %5
br label %9
30: ; preds = %9
ret void
}

LLVM IR (-O2):
define void @util_randomtext(i32 %0, i8* %1) {
%3 = tail call i32 @util_random(i32 %0, i8* %1)
%4 = icmp sgt i32 %0, 0
br i1 %4, label %5, label %78
5: ; preds = %2
%6 = zext i32 %0 to i64
%7 = icmp ult i32 %0, 8
br i1 %7, label %68, label %8
8: ; preds = %5
%9 = icmp ult i32 %0, 16
br i1 %9, label %53, label %10
10: ; preds = %8
%11 = and i64 %6, 4294967280
%12 = add nsw i64 %11, -16
%13 = lshr exact i64 %12, 4
%14 = add nuw nsw i64 %13, 1
%15 = and i64 %14, 1
%16 = icmp eq i64 %12, 0
br i1 %16, label %38, label %17
17: ; preds = %10
%18 = and i64 %14, 2305843009213693950
br label %19
19: ; preds = %19, %17
%20 = phi i64 [ 0, %17 ], [ %35, %19 ]
%21 = phi i64 [ 0, %17 ], [ %36, %19 ]
%22 = getelementptr inbounds i8, i8* %1, i64 %20
%23 = bitcast i8* %22 to <16 x i8>*
%24 = load <16 x i8>, <16 x i8>* %23
%25 = urem <16 x i8> %24, <i8 10, i8 10, i8 10, i8 10, i8 10, i8 10, i8 10, i8 10, i8 10, i8 10, i8 10, i8 10, i8 10, i8 10, i8 10, i8 10>
%26 = or <16 x i8> %25, <i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48>
%27 = bitcast i8* %22 to <16 x i8>*
store <16 x i8> %26, <16 x i8>* %27
%28 = or i64 %20, 16
%29 = getelementptr inbounds i8, i8* %1, i64 %28
%30 = bitcast i8* %29 to <16 x i8>*
%31 = load <16 x i8>, <16 x i8>* %30
%32 = urem <16 x i8> %31, <i8 10, i8 10, i8 10, i8 10, i8 10, i8 10, i8 10, i8 10, i8 10, i8 10, i8 10, i8 10, i8 10, i8 10, i8 10, i8 10>
%33 = or <16 x i8> %32, <i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48>
%34 = bitcast i8* %29 to <16 x i8>*
store <16 x i8> %33, <16 x i8>* %34
%35 = add nuw i64 %20, 32
%36 = add i64 %21, 2
%37 = icmp eq i64 %36, %18
br i1 %37, label %38, label %19
38: ; preds = %19, %10
%39 = phi i64 [ 0, %10 ], [ %35, %19 ]
%40 = icmp eq i64 %15, 0
br i1 %40, label %48, label %41
41: ; preds = %38
%42 = getelementptr inbounds i8, i8* %1, i64 %39
%43 = bitcast i8* %42 to <16 x i8>*
%44 = load <16 x i8>, <16 x i8>* %43
%45 = urem <16 x i8> %44, <i8 10, i8 10, i8 10, i8 10, i8 10, i8 10, i8 10, i8 10, i8 10, i8 10, i8 10, i8 10, i8 10, i8 10, i8 10, i8 10>
%46 = or <16 x i8> %45, <i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48>
%47 = bitcast i8* %42 to <16 x i8>*
store <16 x i8> %46, <16 x i8>* %47
br label %48
48: ; preds = %38, %41
%49 = icmp eq i64 %11, %6
br i1 %49, label %78, label %50
50: ; preds = %48
%51 = and i64 %6, 8
%52 = icmp eq i64 %51, 0
br i1 %52, label %68, label %53
53: ; preds = %8, %50
%54 = phi i64 [ %11, %50 ], [ 0, %8 ]
%55 = and i64 %6, 4294967288
br label %56
56: ; preds = %56, %53
%57 = phi i64 [ %54, %53 ], [ %64, %56 ]
%58 = getelementptr inbounds i8, i8* %1, i64 %57
%59 = bitcast i8* %58 to <8 x i8>*
%60 = load <8 x i8>, <8 x i8>* %59
%61 = urem <8 x i8> %60, <i8 10, i8 10, i8 10, i8 10, i8 10, i8 10, i8 10, i8 10>
%62 = or <8 x i8> %61, <i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48>
%63 = bitcast i8* %58 to <8 x i8>*
store <8 x i8> %62, <8 x i8>* %63
%64 = add nuw i64 %57, 8
%65 = icmp eq i64 %64, %55
br i1 %65, label %66, label %56
66: ; preds = %56
%67 = icmp eq i64 %55, %6
br i1 %67, label %78, label %68
68: ; preds = %5, %50, %66
%69 = phi i64 [ 0, %5 ], [ %11, %50 ], [ %55, %66 ]
br label %70
70: ; preds = %68, %70
%71 = phi i64 [ %76, %70 ], [ %69, %68 ]
%72 = getelementptr inbounds i8, i8* %1, i64 %71
%73 = load i8, i8* %72
%74 = urem i8 %73, 10
%75 = or i8 %74, 48
store i8 %75, i8* %72
%76 = add nuw nsw i64 %71, 1
%77 = icmp eq i64 %76, %6
br i1 %77, label %78, label %70
78: ; preds = %70, %48, %66, %2
ret void
}