#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 */
char LayerRandByte(char, int);
int /*<<< orphan*/ Next4Rands();
int strlen(char *);
void FilloutCode(char *code, int size) {
  int l, i, j, k;
  l = strlen(code);
  for (i = l, j = 0, k = 0; i < size; i++, j++) {
    if (j >= l) {
      j = 0;
      k++;
      if (k > 3) {
        k = 0;
        Next4Rands();
      }
    }
    code[i] = LayerRandByte(code[j], k);
  }
}


x86 assembly (clang, -O0):
<FilloutCode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11de <FilloutCode+0xae>
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jl     11a4 <FilloutCode+0x74>
movl   $0x0,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x3,-0x1c(%rbp)
jle    119f <FilloutCode+0x6f>
movl   $0x0,-0x1c(%rbp)
mov    $0x0,%al
call   1050 <Next4Rands@plt>
jmp    11a4 <FilloutCode+0x74>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    -0x1c(%rbp),%esi
movsbl %al,%edi
call   1030 <LayerRandByte@plt>
mov    %al,%dl
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    115f <FilloutCode+0x2f>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FilloutCode>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r15d
mov    %rdi,(%rsp)
call   1040 <strlen@plt>
cmp    %r15d,%eax
jge    11b2 <FilloutCode+0x82>
mov    %eax,%r13d
movslq %eax,%r12
add    (%rsp),%r12
sub    %eax,%r15d
xor    %ebp,%ebp
xor    %ebx,%ebx
xor    %r14d,%r14d
jmp    119a <FilloutCode+0x6a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%ebx
xor    %r14d,%r14d
movslq %r14d,%r14
mov    (%rsp),%rax
movsbl (%rax,%r14,1),%edi
mov    %ebx,%esi
call   1030 <LayerRandByte@plt>
mov    %al,(%r12,%rbp,1)
add    $0x1,%r14d
add    $0x1,%rbp
cmp    %ebp,%r15d
je     11b2 <FilloutCode+0x82>
cmp    %r13d,%r14d
jl     1176 <FilloutCode+0x46>
cmp    $0x3,%ebx
jl     1170 <FilloutCode+0x40>
xor    %r14d,%r14d
xor    %eax,%eax
call   1050 <Next4Rands@plt>
xor    %ebx,%ebx
jmp    1176 <FilloutCode+0x46>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @FilloutCode(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%9 = load i8*, i8** %3
%10 = call i32 @strlen(i8* %9)
store i32 %10, i32* %5
%11 = load i32, i32* %5
store i32 %11, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
br label %12
12: ; preds = %40, %2
%13 = load i32, i32* %6
%14 = load i32, i32* %4
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %45
16: ; preds = %12
%17 = load i32, i32* %7
%18 = load i32, i32* %5
%19 = icmp sge i32 %17, %18
br i1 %19, label %20, label %28
20: ; preds = %16
store i32 0, i32* %7
%21 = load i32, i32* %8
%22 = add nsw i32 %21, 1
store i32 %22, i32* %8
%23 = load i32, i32* %8
%24 = icmp sgt i32 %23, 3
br i1 %24, label %25, label %27
25: ; preds = %20
store i32 0, i32* %8
%26 = call i32 (...) @Next4Rands()
br label %27
27: ; preds = %25, %20
br label %28
28: ; preds = %27, %16
%29 = load i8*, i8** %3
%30 = load i32, i32* %7
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
%33 = load i8, i8* %32
%34 = load i32, i32* %8
%35 = call signext i8 @LayerRandByte(i8 signext %33, i32 %34)
%36 = load i8*, i8** %3
%37 = load i32, i32* %6
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %36, i64 %38
store i8 %35, i8* %39
br label %40
40: ; preds = %28
%41 = load i32, i32* %6
%42 = add nsw i32 %41, 1
store i32 %42, i32* %6
%43 = load i32, i32* %7
%44 = add nsw i32 %43, 1
store i32 %44, i32* %7
br label %12
45: ; preds = %12
ret void
}

LLVM IR (-O2):
define void @FilloutCode(i8* %0, i32 %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = icmp slt i32 %3, %1
br i1 %4, label %5, label %29
5: ; preds = %2
%6 = sext i32 %3 to i64
br label %7
7: ; preds = %5, %17
%8 = phi i64 [ %6, %5 ], [ %25, %17 ]
%9 = phi i32 [ 0, %5 ], [ %19, %17 ]
%10 = phi i32 [ 0, %5 ], [ %26, %17 ]
%11 = icmp slt i32 %10, %3
br i1 %11, label %17, label %12
12: ; preds = %7
%13 = add nsw i32 %9, 1
%14 = icmp sgt i32 %9, 2
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = tail call i32 (...) @Next4Rands()
br label %17
17: ; preds = %12, %15, %7
%18 = phi i32 [ 0, %15 ], [ 0, %12 ], [ %10, %7 ]
%19 = phi i32 [ 0, %15 ], [ %13, %12 ], [ %9, %7 ]
%20 = sext i32 %18 to i64
%21 = getelementptr inbounds i8, i8* %0, i64 %20
%22 = load i8, i8* %21
%23 = tail call signext i8 @LayerRandByte(i8 signext %22, i32 %19)
%24 = getelementptr inbounds i8, i8* %0, i64 %8
store i8 %23, i8* %24
%25 = add nsw i64 %8, 1
%26 = add nsw i32 %18, 1
%27 = trunc i64 %25 to i32
%28 = icmp eq i32 %27, %1
br i1 %28, label %29, label %7
29: ; preds = %17, %2
ret void
}