#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*/ assert(int);
int create_dictionary(char *, float *);
int /*<<< orphan*/ printf(char *, ...);
void test_create_dictionary() {
  int total_words, i, max_index = 0;
  float dictionary[(128 * 128)];
  printf("test_create_dictionary...");
  total_words = create_dictionary("ZZZzzz ZZZzzz ZZZzzz ", dictionary);
  if (total_words != 2) {
    printf("\nTotal words %d\n", total_words);
  }
  assert(total_words == 2);
  for (i = 0; i < (128 * 128); i++) {
    if (dictionary[i] > 0)
      max_index = i;
  }
  if (max_index <= (128 * 128) * 95 / 100) {
    printf("\nMax index %d%%\n", max_index * 100 / (128 * 128));
  }
  assert(max_index > (128 * 128) * 95 / 100);
  printf("Ok\n");
}


x86 assembly (clang, -O0):
<test_create_dictionary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10010,%rsp
movl   $0x0,-0xc(%rbp)
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x10010(%rbp),%rsi
lea    0xebc(%rip),%rdi
call   1030 <create_dictionary@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x2,-0x4(%rbp)
je     1181 <test_create_dictionary+0x51>
mov    -0x4(%rbp),%esi
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x2,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x4000,-0x8(%rbp)
jge    11d8 <test_create_dictionary+0xa8>
movslq -0x8(%rbp),%rax
movss  -0x10010(%rbp,%rax,4),%xmm0
fe ff
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    11c5 <test_create_dictionary+0x95>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11ca <test_create_dictionary+0x9a>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1199 <test_create_dictionary+0x69>
cmpl   $0x3ccc,-0xc(%rbp)
jg     1201 <test_create_dictionary+0xd1>
imul   $0x64,-0xc(%rbp),%eax
mov    $0x4000,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x3ccc,-0xc(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x10010,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_create_dictionary>:
push   %rbp
push   %rbx
sub    $0x10008,%rsp
lea    0xeb0(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeba(%rip),%rdi
mov    %rsp,%rsi
call   1040 <create_dictionary@plt>
mov    %eax,%ebp
cmp    $0x2,%eax
je     117f <test_create_dictionary+0x3f>
lea    0xeba(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %edi,%edi
cmp    $0x2,%ebp
sete   %dil
call   1060 <assert@plt>
xorps  %xmm0,%xmm0
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movss  (%rsp,%rax,4),%xmm1
ucomiss %xmm0,%xmm1
cmova  %eax,%ebx
movss  0x4(%rsp,%rax,4),%xmm1
ucomiss %xmm0,%xmm1
lea    0x1(%rax),%ecx
cmovbe %ebx,%ecx
movss  0x8(%rsp,%rax,4),%xmm1
ucomiss %xmm0,%xmm1
lea    0x2(%rax),%edx
cmovbe %ecx,%edx
movss  0xc(%rsp,%rax,4),%xmm1
ucomiss %xmm0,%xmm1
lea    0x3(%rax),%ebx
cmovbe %edx,%ebx
add    $0x4,%rax
cmp    $0x4000,%rax
jne    11a0 <test_create_dictionary+0x60>
cmp    $0x3ccc,%ebx
jg     120b <test_create_dictionary+0xcb>
imul   $0x64,%ebx,%eax
lea    0x3fff(%rax),%esi
test   %eax,%eax
cmovns %eax,%esi
sar    $0xe,%esi
lea    0xe3d(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %edi,%edi
cmp    $0x3ccd,%ebx
setge  %dil
call   1060 <assert@plt>
lea    0xe2f(%rip),%rdi
call   1030 <puts@plt>
add    $0x10008,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"test_create_dictionary...\00"
@.str.1 = [22 x i8] c"ZZZzzz ZZZzzz ZZZzzz \00"
@.str.2 = [17 x i8] c"\0ATotal words %d\0A\00"
@.str.3 = [17 x i8] c"\0AMax index %d%%\0A\00"
@.str.4 = [4 x i8] c"Ok\0A\00"
define void @test_create_dictionary() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [16384 x float]
store i32 0, i32* %3
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [16384 x float], [16384 x float]* %4, i64 0, i64 0
%7 = call i32 @create_dictionary(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), float* %6)
store i32 %7, i32* %1
%8 = load i32, i32* %1
%9 = icmp ne i32 %8, 2
br i1 %9, label %10, label %13
10: ; preds = %0
%11 = load i32, i32* %1
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %11)
br label %13
13: ; preds = %10, %0
%14 = load i32, i32* %1
%15 = icmp eq i32 %14, 2
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
store i32 0, i32* %2
br label %18
18: ; preds = %30, %13
%19 = load i32, i32* %2
%20 = icmp slt i32 %19, 16384
br i1 %20, label %21, label %33
21: ; preds = %18
%22 = load i32, i32* %2
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [16384 x float], [16384 x float]* %4, i64 0, i64 %23
%25 = load float, float* %24
%26 = fcmp ogt float %25, 0.000000e+00
br i1 %26, label %27, label %29
27: ; preds = %21
%28 = load i32, i32* %2
store i32 %28, i32* %3
br label %29
29: ; preds = %27, %21
br label %30
30: ; preds = %29
%31 = load i32, i32* %2
%32 = add nsw i32 %31, 1
store i32 %32, i32* %2
br label %18
33: ; preds = %18
%34 = load i32, i32* %3
%35 = icmp sle i32 %34, 15564
br i1 %35, label %36, label %41
36: ; preds = %33
%37 = load i32, i32* %3
%38 = mul nsw i32 %37, 100
%39 = sdiv i32 %38, 16384
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %39)
br label %41
41: ; preds = %36, %33
%42 = load i32, i32* %3
%43 = icmp sgt i32 %42, 15564
%44 = zext i1 %43 to i32
%45 = call i32 @assert(i32 %44)
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [26 x i8] c"test_create_dictionary...\00"
@.str.1 = [22 x i8] c"ZZZzzz ZZZzzz ZZZzzz \00"
@.str.2 = [17 x i8] c"\0ATotal words %d\0A\00"
@.str.3 = [17 x i8] c"\0AMax index %d%%\0A\00"
@str = [3 x i8] c"Ok\00"
define void @test_create_dictionary() {
%1 = alloca [16384 x float]
%2 = bitcast [16384 x float]* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [16384 x float], [16384 x float]* %1, i64 0, i64 0
%5 = call i32 @create_dictionary(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), float* %4)
%6 = icmp eq i32 %5, 2
br i1 %6, label %9, label %7
7: ; preds = %0
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %5)
br label %9
9: ; preds = %7, %0
%10 = zext i1 %6 to i32
%11 = call i32 @assert(i32 %10)
br label %12
12: ; preds = %12, %9
%13 = phi i64 [ 0, %9 ], [ %38, %12 ]
%14 = phi i32 [ 0, %9 ], [ %37, %12 ]
%15 = getelementptr inbounds [16384 x float], [16384 x float]* %1, i64 0, i64 %13
%16 = load float, float* %15
%17 = fcmp ogt float %16, 0.000000e+00
%18 = trunc i64 %13 to i32
%19 = select i1 %17, i32 %18, i32 %14
%20 = or i64 %13, 1
%21 = getelementptr inbounds [16384 x float], [16384 x float]* %1, i64 0, i64 %20
%22 = load float, float* %21
%23 = fcmp ogt float %22, 0.000000e+00
%24 = trunc i64 %20 to i32
%25 = select i1 %23, i32 %24, i32 %19
%26 = or i64 %13, 2
%27 = getelementptr inbounds [16384 x float], [16384 x float]* %1, i64 0, i64 %26
%28 = load float, float* %27
%29 = fcmp ogt float %28, 0.000000e+00
%30 = trunc i64 %26 to i32
%31 = select i1 %29, i32 %30, i32 %25
%32 = or i64 %13, 3
%33 = getelementptr inbounds [16384 x float], [16384 x float]* %1, i64 0, i64 %32
%34 = load float, float* %33
%35 = fcmp ogt float %34, 0.000000e+00
%36 = trunc i64 %32 to i32
%37 = select i1 %35, i32 %36, i32 %31
%38 = add nuw nsw i64 %13, 4
%39 = icmp eq i64 %38, 16384
br i1 %39, label %40, label %12
40: ; preds = %12
%41 = icmp slt i32 %37, 15565
br i1 %41, label %42, label %46
42: ; preds = %40
%43 = mul nsw i32 %37, 100
%44 = sdiv i32 %43, 16384
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %44)
br label %46
46: ; preds = %42, %40
%47 = icmp sgt i32 %37, 15564
%48 = zext i1 %47 to i32
%49 = call i32 @assert(i32 %48)
%50 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
ret void
}