#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 *indexedWordFromAlphabet(int, char *, int, int, int);
int /*<<< orphan*/ memcpy(char *, char *, int);
int numberOfStrings(int, int, int);
int strlen(char *);
int charset_readWordsBlock(int block_size, char *alphabet, int minlength,
                           int maxlength, char *words, int *words_init,
                           int *words_length) {
  char *buffer;
  static int count = 0;
  int i;
  if (count >= numberOfStrings(strlen(alphabet), minlength, maxlength))
    return 0;
  for (i = 0;
       i < block_size &&
       count + i < numberOfStrings(strlen(alphabet), minlength, maxlength);
       i++) {
    if (i == 0)
      words_init[0] = 0;
    else
      words_init[i] = words_init[i - 1] + words_length[i - 1];
    buffer = indexedWordFromAlphabet(i + count, alphabet, strlen(alphabet),
                                     minlength, maxlength);
    words_length[i] = strlen(buffer);
    memcpy(words + words_init[i], buffer, strlen(buffer));
    words[words_init[i] + strlen(buffer)] = '\0';
  }
  count += i;
  return i;
}


x86 assembly (clang, -O0):
<charset_readWordsBlock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    0x10(%rbp),%rax
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
mov    0x2edd(%rip),%eax
mov    %eax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%edi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1040 <numberOfStrings@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
cmp    %ecx,%eax
jl     1199 <charset_readWordsBlock+0x59>
movl   $0x0,-0x4(%rbp)
jmp    130b <charset_readWordsBlock+0x1cb>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%ecx
xor    %eax,%eax
cmp    -0x8(%rbp),%ecx
mov    %al,-0x39(%rbp)
jge    11e0 <charset_readWordsBlock+0xa0>
mov    0x2e8d(%rip),%eax
add    -0x34(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%edi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1040 <numberOfStrings@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%eax
cmp    %ecx,%eax
setl   %al
mov    %al,-0x39(%rbp)
mov    -0x39(%rbp),%al
test   $0x1,%al
jne    11f0 <charset_readWordsBlock+0xb0>
jmp    12f6 <charset_readWordsBlock+0x1b6>
cmpl   $0x0,-0x34(%rbp)
jne    1209 <charset_readWordsBlock+0xc9>
mov    -0x28(%rbp),%rax
movl   $0x0,(%rax)
jmp    1234 <charset_readWordsBlock+0xf4>
mov    -0x28(%rbp),%rax
mov    -0x34(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
mov    0x10(%rbp),%rax
mov    -0x34(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
add    (%rax,%rcx,4),%edx
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x34(%rbp),%eax
add    0x2e07(%rip),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x6c(%rbp),%edi
mov    -0x68(%rbp),%rsi
mov    %eax,%edx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
call   1050 <indexedWordFromAlphabet@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%edx
mov    0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
movslq -0x34(%rbp),%rdx
movslq (%rcx,%rdx,4),%rcx
add    %rcx,%rax
mov    %rax,-0x60(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x60(%rbp),%rdi
mov    -0x58(%rbp),%rsi
mov    %eax,%edx
call   1060 <memcpy@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x4c(%rbp),%ecx
mov    %eax,%edx
mov    -0x48(%rbp),%rax
add    %edx,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11a0 <charset_readWordsBlock+0x60>
mov    -0x34(%rbp),%eax
add    0x2d45(%rip),%eax
mov    %eax,0x2d3f(%rip)
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<charset_readWordsBlock>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9,%r14
mov    %r8,0x20(%rsp)
mov    %ecx,%ebp
mov    %edx,%r12d
mov    %rsi,%r15
mov    %edi,%r13d
mov    0x2edd(%rip),%ebx
mov    %rsi,%rdi
call   1030 <strlen@plt>
mov    %eax,%edi
mov    %r12d,%esi
mov    %ebp,(%rsp)
mov    %ebp,%edx
call   1040 <numberOfStrings@plt>
xor    %ebp,%ebp
cmp    %eax,%ebx
jge    12a4 <charset_readWordsBlock+0x164>
test   %r13d,%r13d
jle    1295 <charset_readWordsBlock+0x155>
mov    %r14,0x8(%rsp)
mov    %r13d,%eax
mov    %rax,0x10(%rsp)
xor    %ebp,%ebp
mov    %r15,0x18(%rsp)
mov    %r12d,0x4(%rsp)
mov    0x18(%rsp),%r13
jmp    1255 <charset_readWordsBlock+0x115>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x60(%rsp),%rbx
mov    -0x4(%rbx,%rbp,4),%eax
mov    0x8(%rsp),%r15
add    -0x4(%r15,%rbp,4),%eax
mov    %eax,(%r15,%rbp,4)
mov    0x2e66(%rip),%r14d
add    %ebp,%r14d
mov    %r13,%rdi
call   1030 <strlen@plt>
mov    %r14d,%edi
mov    %r13,%rsi
mov    %eax,%edx
mov    %r12d,%ecx
mov    (%rsp),%r8d
call   1050 <indexedWordFromAlphabet@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1030 <strlen@plt>
mov    %eax,(%rbx,%rbp,4)
movslq (%r15,%rbp,4),%rbx
mov    0x20(%rsp),%r12
add    %r12,%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1060 <memcpy@plt>
movslq (%r15,%rbp,4),%rbx
mov    %r13,%r15
mov    %r14,%rdi
call   1030 <strlen@plt>
cltq
add    %rbx,%rax
movb   $0x0,(%r12,%rax,1)
mov    0x4(%rsp),%r12d
add    $0x1,%rbp
cmp    %rbp,0x10(%rsp)
je     1299 <charset_readWordsBlock+0x159>
mov    0x2de9(%rip),%ebx
add    %ebp,%ebx
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %eax,%edi
mov    %r12d,%esi
mov    (%rsp),%edx
call   1040 <numberOfStrings@plt>
cmp    %eax,%ebx
jge    129e <charset_readWordsBlock+0x15e>
test   %rbp,%rbp
jne    11c0 <charset_readWordsBlock+0x80>
mov    0x8(%rsp),%r15
movl   $0x0,(%r15)
mov    0x60(%rsp),%rbx
jmp    11d7 <charset_readWordsBlock+0x97>
xor    %ebp,%ebp
jmp    129e <charset_readWordsBlock+0x15e>
mov    0x10(%rsp),%rbp
add    %ebp,0x2da0(%rip)
mov    %ebp,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@charset_readWordsBlock.count = internal global i32 0
define i32 @charset_readWordsBlock(i32 %0, i8* %1, i32 %2, i32 %3, i8* %4, i32* %5, i32* %6) {
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i32*
%15 = alloca i32*
%16 = alloca i8*
%17 = alloca i32
store i32 %0, i32* %9
store i8* %1, i8** %10
store i32 %2, i32* %11
store i32 %3, i32* %12
store i8* %4, i8** %13
store i32* %5, i32** %14
store i32* %6, i32** %15
%18 = load i32, i32* @charset_readWordsBlock.count
%19 = load i8*, i8** %10
%20 = call i32 @strlen(i8* %19)
%21 = load i32, i32* %11
%22 = load i32, i32* %12
%23 = call i32 @numberOfStrings(i32 %20, i32 %21, i32 %22)
%24 = icmp sge i32 %18, %23
br i1 %24, label %25, label %26
25: ; preds = %7
store i32 0, i32* %8
br label %114
26: ; preds = %7
store i32 0, i32* %17
br label %27
27: ; preds = %106, %26
%28 = load i32, i32* %17
%29 = load i32, i32* %9
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %41
31: ; preds = %27
%32 = load i32, i32* @charset_readWordsBlock.count
%33 = load i32, i32* %17
%34 = add nsw i32 %32, %33
%35 = load i8*, i8** %10
%36 = call i32 @strlen(i8* %35)
%37 = load i32, i32* %11
%38 = load i32, i32* %12
%39 = call i32 @numberOfStrings(i32 %36, i32 %37, i32 %38)
%40 = icmp slt i32 %34, %39
br label %41
41: ; preds = %31, %27
%42 = phi i1 [ false, %27 ], [ %40, %31 ]
br i1 %42, label %43, label %109
43: ; preds = %41
%44 = load i32, i32* %17
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %49
46: ; preds = %43
%47 = load i32*, i32** %14
%48 = getelementptr inbounds i32, i32* %47, i64 0
store i32 0, i32* %48
br label %67
49: ; preds = %43
%50 = load i32*, i32** %14
%51 = load i32, i32* %17
%52 = sub nsw i32 %51, 1
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i32, i32* %50, i64 %53
%55 = load i32, i32* %54
%56 = load i32*, i32** %15
%57 = load i32, i32* %17
%58 = sub nsw i32 %57, 1
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i32, i32* %56, i64 %59
%61 = load i32, i32* %60
%62 = add nsw i32 %55, %61
%63 = load i32*, i32** %14
%64 = load i32, i32* %17
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i32, i32* %63, i64 %65
store i32 %62, i32* %66
br label %67
67: ; preds = %49, %46
%68 = load i32, i32* %17
%69 = load i32, i32* @charset_readWordsBlock.count
%70 = add nsw i32 %68, %69
%71 = load i8*, i8** %10
%72 = load i8*, i8** %10
%73 = call i32 @strlen(i8* %72)
%74 = load i32, i32* %11
%75 = load i32, i32* %12
%76 = call i8* @indexedWordFromAlphabet(i32 %70, i8* %71, i32 %73, i32 %74, i32 %75)
store i8* %76, i8** %16
%77 = load i8*, i8** %16
%78 = call i32 @strlen(i8* %77)
%79 = load i32*, i32** %15
%80 = load i32, i32* %17
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds i32, i32* %79, i64 %81
store i32 %78, i32* %82
%83 = load i8*, i8** %13
%84 = load i32*, i32** %14
%85 = load i32, i32* %17
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds i32, i32* %84, i64 %86
%88 = load i32, i32* %87
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds i8, i8* %83, i64 %89
%91 = load i8*, i8** %16
%92 = load i8*, i8** %16
%93 = call i32 @strlen(i8* %92)
%94 = call i32 @memcpy(i8* %90, i8* %91, i32 %93)
%95 = load i8*, i8** %13
%96 = load i32*, i32** %14
%97 = load i32, i32* %17
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds i32, i32* %96, i64 %98
%100 = load i32, i32* %99
%101 = load i8*, i8** %16
%102 = call i32 @strlen(i8* %101)
%103 = add nsw i32 %100, %102
%104 = sext i32 %103 to i64
%105 = getelementptr inbounds i8, i8* %95, i64 %104
store i8 0, i8* %105
br label %106
106: ; preds = %67
%107 = load i32, i32* %17
%108 = add nsw i32 %107, 1
store i32 %108, i32* %17
br label %27
109: ; preds = %41
%110 = load i32, i32* %17
%111 = load i32, i32* @charset_readWordsBlock.count
%112 = add nsw i32 %111, %110
store i32 %112, i32* @charset_readWordsBlock.count
%113 = load i32, i32* %17
store i32 %113, i32* %8
br label %114
114: ; preds = %109, %25
%115 = load i32, i32* %8
ret i32 %115
}

LLVM IR (-O2):
@charset_readWordsBlock.count = internal unnamed_addr global i32 0
define i32 @charset_readWordsBlock(i32 %0, i8* %1, i32 %2, i32 %3, i8* %4, i32* nocapture %5, i32* nocapture %6) {
%8 = load i32, i32* @charset_readWordsBlock.count
%9 = tail call i32 @strlen(i8* %1)
%10 = tail call i32 @numberOfStrings(i32 %9, i32 %2, i32 %3)
%11 = icmp slt i32 %8, %10
br i1 %11, label %12, label %61
12: ; preds = %7
%13 = icmp sgt i32 %0, 0
br i1 %13, label %14, label %57
14: ; preds = %12
%15 = zext i32 %0 to i64
br label %16
16: ; preds = %14, %35
%17 = phi i64 [ 0, %14 ], [ %53, %35 ]
%18 = trunc i64 %17 to i32
%19 = load i32, i32* @charset_readWordsBlock.count
%20 = add nsw i32 %19, %18
%21 = tail call i32 @strlen(i8* %1)
%22 = tail call i32 @numberOfStrings(i32 %21, i32 %2, i32 %3)
%23 = icmp slt i32 %20, %22
br i1 %23, label %24, label %55
24: ; preds = %16
%25 = icmp eq i64 %17, 0
br i1 %25, label %26, label %27
26: ; preds = %24
store i32 0, i32* %5
br label %35
27: ; preds = %24
%28 = add nsw i64 %17, -1
%29 = getelementptr inbounds i32, i32* %5, i64 %28
%30 = load i32, i32* %29
%31 = getelementptr inbounds i32, i32* %6, i64 %28
%32 = load i32, i32* %31
%33 = add nsw i32 %32, %30
%34 = getelementptr inbounds i32, i32* %5, i64 %17
store i32 %33, i32* %34
br label %35
35: ; preds = %27, %26
%36 = load i32, i32* @charset_readWordsBlock.count
%37 = add nsw i32 %36, %18
%38 = tail call i32 @strlen(i8* %1)
%39 = tail call i8* @indexedWordFromAlphabet(i32 %37, i8* %1, i32 %38, i32 %2, i32 %3)
%40 = tail call i32 @strlen(i8* %39)
%41 = getelementptr inbounds i32, i32* %6, i64 %17
store i32 %40, i32* %41
%42 = getelementptr inbounds i32, i32* %5, i64 %17
%43 = load i32, i32* %42
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %4, i64 %44
%46 = tail call i32 @strlen(i8* %39)
%47 = tail call i32 @memcpy(i8* %45, i8* %39, i32 %46)
%48 = load i32, i32* %42
%49 = tail call i32 @strlen(i8* %39)
%50 = add nsw i32 %49, %48
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8, i8* %4, i64 %51
store i8 0, i8* %52
%53 = add nuw nsw i64 %17, 1
%54 = icmp eq i64 %53, %15
br i1 %54, label %57, label %16
55: ; preds = %16
%56 = trunc i64 %17 to i32
br label %57
57: ; preds = %35, %55, %12
%58 = phi i32 [ 0, %12 ], [ %56, %55 ], [ %0, %35 ]
%59 = load i32, i32* @charset_readWordsBlock.count
%60 = add nsw i32 %59, %58
store i32 %60, i32* @charset_readWordsBlock.count
br label %61
61: ; preds = %7, %57
%62 = phi i32 [ %58, %57 ], [ 0, %7 ]
ret i32 %62
}