#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 */
typedef int /*<<< orphan*/ results;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ getRhymeIdFromDictEntry(char *);
int /*<<< orphan*/ getWordFromDictEntry(char *);
void *malloc(int);
int rand();
scalar_t__ strcmp(int /*<<< orphan*/, char *);
int /*<<< orphan*/ strcpy(char *, int /*<<< orphan*/);
int /*<<< orphan*/ *strstr(char *, int /*<<< orphan*/);
int /*<<< orphan*/ toUpper(char *);
char *getRhymeId(char *str) {
  FILE *fp = fopen("dicts/editedRhymeDict.csv", "r");
  char **results = malloc(sizeof(char *) * 32);
  int size = 0;
  char *temp = malloc(sizeof(char) * 256);
  char *curr = malloc(sizeof(char) * 256);
  while (fgets(temp, 128, fp) != NULL) {
    if (strstr(temp, toUpper(str)) != NULL) {
      strcpy(curr, getWordFromDictEntry(temp));
      if (strcmp(toUpper(str), curr) == 0) {
        results[size] = malloc(sizeof(char) * 256);
        strcpy(results[size], getRhymeIdFromDictEntry(temp));
        size++;
      }
    }
  }
  fclose(fp);
  if (results[0] != NULL) {
    return results[rand() % (sizeof(results) / sizeof(results[0]))];
  } else {
    return "?";
  }
}


x86 assembly (clang, -O0):
<getRhymeId>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xe3d(%rip),%rdi
lea    0xe50(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    $0x100,%edi
call   1080 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    $0x100,%edi
call   1080 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    $0x100,%edi
call   1080 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x80,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     12d0 <getRhymeId+0x120>
mov    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <toUpper@plt>
mov    -0x40(%rbp),%rdi
mov    %eax,%esi
call   10b0 <strstr@plt>
cmp    $0x0,%rax
je     12cb <getRhymeId+0x11b>
mov    -0x38(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x30(%rbp),%rdi
call   10c0 <getWordFromDictEntry@plt>
mov    -0x48(%rbp),%rdi
mov    %eax,%esi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rdi
call   1070 <toUpper@plt>
mov    %eax,%edi
mov    -0x38(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    12c6 <getRhymeId+0x116>
mov    $0x100,%edi
call   1080 <malloc@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x50(%rbp)
mov    -0x30(%rbp),%rdi
call   1090 <getRhymeIdFromDictEntry@plt>
mov    -0x50(%rbp),%rdi
mov    %eax,%esi
call   1030 <strcpy@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    12cb <getRhymeId+0x11b>
jmp    1204 <getRhymeId+0x54>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
je     1310 <getRhymeId+0x160>
mov    -0x20(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    $0x0,%al
call   10d0 <rand@plt>
mov    %eax,%ecx
mov    -0x58(%rbp),%rax
movslq %ecx,%rcx
and    $0x0,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x8(%rbp)
jmp    131b <getRhymeId+0x16b>
lea    0xd05(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getRhymeId>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r12
lea    0xe3b(%rip),%rdi
lea    0xe4e(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%r14
mov    $0x100,%edi
call   1080 <malloc@plt>
mov    %rax,(%rsp)
mov    $0x100,%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
mov    $0x100,%edi
call   1080 <malloc@plt>
mov    %rax,%r13
mov    %rbx,%rdi
mov    $0x80,%esi
mov    %r14,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     12a8 <getRhymeId+0xf8>
xor    %r15d,%r15d
jmp    1235 <getRhymeId+0x85>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x80,%esi
mov    %r14,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     12a8 <getRhymeId+0xf8>
mov    %r12,%rdi
call   1070 <toUpper@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   10b0 <strstr@plt>
test   %rax,%rax
je     1220 <getRhymeId+0x70>
mov    %rbx,%rdi
call   10c0 <getWordFromDictEntry@plt>
mov    %r13,%rdi
mov    %eax,%esi
call   1030 <strcpy@plt>
mov    %r12,%rdi
call   1070 <toUpper@plt>
mov    %eax,%edi
mov    %r13,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    1220 <getRhymeId+0x70>
mov    $0x100,%edi
call   1080 <malloc@plt>
mov    %rax,%rbp
movslq %r15d,%r15
mov    (%rsp),%rax
mov    %rbp,(%rax,%r15,8)
mov    %rbx,%rdi
call   1090 <getRhymeIdFromDictEntry@plt>
mov    %rbp,%rdi
mov    %eax,%esi
call   1030 <strcpy@plt>
add    $0x1,%r15d
jmp    1220 <getRhymeId+0x70>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    (%rsp),%rax
mov    (%rax),%rbx
test   %rbx,%rbx
je     12c5 <getRhymeId+0x115>
xor    %eax,%eax
call   10d0 <rand@plt>
jmp    12cc <getRhymeId+0x11c>
lea    0xd50(%rip),%rbx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"dicts/editedRhymeDict.csv\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"?\00"
define i8* @getRhymeId(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
store i8* %0, i8** %3
%9 = call i32* @fopen(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %4
%10 = call i8* @malloc(i32 256)
%11 = bitcast i8* %10 to i8**
store i8** %11, i8*** %5
store i32 0, i32* %6
%12 = call i8* @malloc(i32 256)
store i8* %12, i8** %7
%13 = call i8* @malloc(i32 256)
store i8* %13, i8** %8
br label %14
14: ; preds = %52, %1
%15 = load i8*, i8** %7
%16 = load i32*, i32** %4
%17 = call i32* @fgets(i8* %15, i32 128, i32* %16)
%18 = icmp ne i32* %17, null
br i1 %18, label %19, label %53
19: ; preds = %14
%20 = load i8*, i8** %7
%21 = load i8*, i8** %3
%22 = call i32 @toUpper(i8* %21)
%23 = call i32* @strstr(i8* %20, i32 %22)
%24 = icmp ne i32* %23, null
br i1 %24, label %25, label %52
25: ; preds = %19
%26 = load i8*, i8** %8
%27 = load i8*, i8** %7
%28 = call i32 @getWordFromDictEntry(i8* %27)
%29 = call i32 @strcpy(i8* %26, i32 %28)
%30 = load i8*, i8** %3
%31 = call i32 @toUpper(i8* %30)
%32 = load i8*, i8** %8
%33 = call i64 @strcmp(i32 %31, i8* %32)
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %51
35: ; preds = %25
%36 = call i8* @malloc(i32 256)
%37 = load i8**, i8*** %5
%38 = load i32, i32* %6
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8*, i8** %37, i64 %39
store i8* %36, i8** %40
%41 = load i8**, i8*** %5
%42 = load i32, i32* %6
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8*, i8** %41, i64 %43
%45 = load i8*, i8** %44
%46 = load i8*, i8** %7
%47 = call i32 @getRhymeIdFromDictEntry(i8* %46)
%48 = call i32 @strcpy(i8* %45, i32 %47)
%49 = load i32, i32* %6
%50 = add nsw i32 %49, 1
store i32 %50, i32* %6
br label %51
51: ; preds = %35, %25
br label %52
52: ; preds = %51, %19
br label %14
53: ; preds = %14
%54 = load i32*, i32** %4
%55 = call i32 @fclose(i32* %54)
%56 = load i8**, i8*** %5
%57 = getelementptr inbounds i8*, i8** %56, i64 0
%58 = load i8*, i8** %57
%59 = icmp ne i8* %58, null
br i1 %59, label %60, label %67
60: ; preds = %53
%61 = load i8**, i8*** %5
%62 = call i32 (...) @rand()
%63 = sext i32 %62 to i64
%64 = urem i64 %63, 1
%65 = getelementptr inbounds i8*, i8** %61, i64 %64
%66 = load i8*, i8** %65
store i8* %66, i8** %2
br label %68
67: ; preds = %53
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %68
68: ; preds = %67, %60
%69 = load i8*, i8** %2
ret i8* %69
}

LLVM IR (-O2):
@.str = [26 x i8] c"dicts/editedRhymeDict.csv\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"?\00"
define i8* @getRhymeId(i8* %0) {
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call dereferenceable_or_null(256) i8* @malloc(i32 256)
%4 = bitcast i8* %3 to i8**
%5 = tail call dereferenceable_or_null(256) i8* @malloc(i32 256)
%6 = tail call dereferenceable_or_null(256) i8* @malloc(i32 256)
%7 = tail call i32* @fgets(i8* %5, i32 128, i32* %2)
%8 = icmp eq i32* %7, null
br i1 %8, label %31, label %9
9: ; preds = %1, %27
%10 = phi i32 [ %28, %27 ], [ 0, %1 ]
%11 = tail call i32 @toUpper(i8* %0)
%12 = tail call i32* @strstr(i8* %5, i32 %11)
%13 = icmp eq i32* %12, null
br i1 %13, label %27, label %14
14: ; preds = %9
%15 = tail call i32 @getWordFromDictEntry(i8* %5)
%16 = tail call i32 @strcpy(i8* %6, i32 %15)
%17 = tail call i32 @toUpper(i8* %0)
%18 = tail call i64 @strcmp(i32 %17, i8* %6)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %27
20: ; preds = %14
%21 = tail call dereferenceable_or_null(256) i8* @malloc(i32 256)
%22 = sext i32 %10 to i64
%23 = getelementptr inbounds i8*, i8** %4, i64 %22
store i8* %21, i8** %23
%24 = tail call i32 @getRhymeIdFromDictEntry(i8* %5)
%25 = tail call i32 @strcpy(i8* %21, i32 %24)
%26 = add nsw i32 %10, 1
br label %27
27: ; preds = %14, %20, %9
%28 = phi i32 [ %26, %20 ], [ %10, %14 ], [ %10, %9 ]
%29 = tail call i32* @fgets(i8* %5, i32 128, i32* %2)
%30 = icmp eq i32* %29, null
br i1 %30, label %31, label %9
31: ; preds = %27, %1
%32 = tail call i32 @fclose(i32* %2)
%33 = load i8*, i8** %4
%34 = icmp eq i8* %33, null
br i1 %34, label %37, label %35
35: ; preds = %31
%36 = tail call i32 (...) @rand()
br label %37
37: ; preds = %31, %35
%38 = phi i8* [ %33, %35 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), %31 ]
ret i8* %38
}