#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*/ FILE;

/* Variables and functions */
char EOF;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
char getc(int /*<<< orphan*/ *);
scalar_t__ isalpha(char);
scalar_t__ isspace(char);
scalar_t__ malloc(int);
scalar_t__ realloc(char *, int);
int /*<<< orphan*/ stderr;
char *getWord(FILE *ifp) {
  int wLen = 10;
  char *readChars = NULL;
  if (ifp != NULL) {
    readChars = (char *)malloc(sizeof(char) * wLen);
    if (readChars == NULL) {
      fprintf(stderr, "Traceback most recent call at line: %d ", 16);
      fprintf(stderr, "of file: %s\n\033[31m%s\033[00m\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/odeke-em/utils/refs/heads/master/"
              "dataStructures/hashlist/testHash.c",
              "\"Run out of memory\"");
      exit(-2);
    };
    int i = 0;
    char c;
    while ((c = getc(ifp)) != EOF) {
      if (i >= wLen) {
        wLen += 10;
        readChars = (char *)realloc(readChars, sizeof(char) * wLen);
      }
      if (isspace(c)) {
        break;
      } else if (isalpha(c)) {
        readChars[i++] = c;
      }
    }
    if (i) {
      readChars[i] = '\0';
      readChars = (char *)realloc(readChars, sizeof(char) * (i + 1));
    }
  }
  return readChars;
}


x86 assembly (clang, -O0):
<getWord>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0xa,-0xc(%rbp)
movq   $0x0,-0x18(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     12d6 <getWord+0x166>
movslq -0xc(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11ff <getWord+0x8f>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
lea    0xe3c(%rip),%rsi
mov    $0x10,%edx
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
lea    0xe48(%rip),%rsi
lea    0xe5b(%rip),%rdx
lea    0xef2(%rip),%rcx
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0xfffffffe,%edi
call   1080 <exit@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1090 <getc@plt>
mov    %al,-0x1d(%rbp)
movsbl %al,%eax
mov    0x2dcc(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     12a0 <getWord+0x130>
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jl     1253 <getWord+0xe3>
mov    -0xc(%rbp),%eax
add    $0xa,%eax
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%rdi
movslq -0xc(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%esi
call   1060 <realloc@plt>
mov    %rax,-0x18(%rbp)
movsbl -0x1d(%rbp),%edi
call   1030 <isspace@plt>
cmp    $0x0,%rax
je     126b <getWord+0xfb>
jmp    12a0 <getWord+0x130>
movsbl -0x1d(%rbp),%edi
call   1070 <isalpha@plt>
cmp    $0x0,%rax
je     1296 <getWord+0x126>
mov    -0x1d(%rbp),%dl
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x1c(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
jmp    129b <getWord+0x12b>
jmp    1206 <getWord+0x96>
cmpl   $0x0,-0x1c(%rbp)
je     12d1 <getWord+0x161>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%esi
call   1060 <realloc@plt>
mov    %rax,-0x18(%rbp)
jmp    12d6 <getWord+0x166>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getWord>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rdi,%rdi
je     1224 <getWord+0xb4>
mov    %rdi,%r14
mov    $0xa,%edi
call   1050 <malloc@plt>
test   %rax,%rax
je     125a <getWord+0xea>
mov    %rax,%r15
mov    %r14,%rdi
call   1090 <getc@plt>
mov    %eax,%ebx
mov    0x2e3a(%rip),%rax
cmp    (%rax),%bl
je     1248 <getWord+0xd8>
xor    %r13d,%r13d
mov    $0xa,%r12d
jmp    11e5 <getWord+0x75>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1090 <getc@plt>
mov    %eax,%ebx
mov    0x2e07(%rip),%rax
cmp    (%rax),%bl
je     1229 <getWord+0xb9>
cmp    %r12d,%r13d
jl     11fc <getWord+0x8c>
add    $0xa,%r12d
mov    %r15,%rdi
mov    %r12d,%esi
call   1060 <realloc@plt>
mov    %rax,%r15
movsbl %bl,%ebp
mov    %ebp,%edi
call   1030 <isspace@plt>
test   %rax,%rax
jne    1229 <getWord+0xb9>
mov    %ebp,%edi
call   1070 <isalpha@plt>
test   %rax,%rax
je     11d0 <getWord+0x60>
movslq %r13d,%rax
add    $0x1,%r13d
mov    %bl,(%r15,%rax,1)
jmp    11d0 <getWord+0x60>
xor    %r15d,%r15d
jmp    1248 <getWord+0xd8>
test   %r13d,%r13d
je     1248 <getWord+0xd8>
movslq %r13d,%rax
movb   $0x0,(%r15,%rax,1)
add    $0x1,%r13d
mov    %r15,%rdi
mov    %r13d,%esi
call   1060 <realloc@plt>
mov    %rax,%r15
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d77(%rip),%rbx
mov    (%rbx),%edi
lea    0xd96(%rip),%rsi
mov    $0x10,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%rbx),%edi
lea    0xda9(%rip),%rsi
lea    0xdbc(%rip),%rdx
lea    0xe53(%rip),%rcx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0xfffffffe,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [40 x i8] c"Traceback most recent call at line: %d \00"
@.str.1 = [26 x i8] c"of file: %s\0A\1B[31m%s\1B[00m\0A\00"
@.str.2 = [158 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/odeke-em/utils/refs/heads/master/dataStructures/hashlist/testHash.c\00"
@.str.3 = [20 x i8] c"\22Run out of memory\22\00"
@EOF = global i8 0
define i8* @getWord(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8
store i32* %0, i32** %2
store i32 10, i32* %3
store i8* null, i8** %4
%7 = load i32*, i32** %2
%8 = icmp ne i32* %7, null
br i1 %8, label %9, label %81
9: ; preds = %1
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = mul i64 1, %11
%13 = trunc i64 %12 to i32
%14 = call i64 @malloc(i32 %13)
%15 = inttoptr i64 %14 to i8*
store i8* %15, i8** %4
%16 = load i8*, i8** %4
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %24
18: ; preds = %9
%19 = load i32, i32* @stderr
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 16)
%21 = load i32, i32* @stderr
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([158 x i8], [158 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%23 = call i32 @exit(i32 -2)
unreachable
24: ; preds = %9
store i32 0, i32* %5
br label %25
25: ; preds = %63, %24
%26 = load i32*, i32** %2
%27 = call signext i8 @getc(i32* %26)
store i8 %27, i8* %6
%28 = sext i8 %27 to i32
%29 = load i8, i8* @EOF
%30 = sext i8 %29 to i32
%31 = icmp ne i32 %28, %30
br i1 %31, label %32, label %64
32: ; preds = %25
%33 = load i32, i32* %5
%34 = load i32, i32* %3
%35 = icmp sge i32 %33, %34
br i1 %35, label %36, label %46
36: ; preds = %32
%37 = load i32, i32* %3
%38 = add nsw i32 %37, 10
store i32 %38, i32* %3
%39 = load i8*, i8** %4
%40 = load i32, i32* %3
%41 = sext i32 %40 to i64
%42 = mul i64 1, %41
%43 = trunc i64 %42 to i32
%44 = call i64 @realloc(i8* %39, i32 %43)
%45 = inttoptr i64 %44 to i8*
store i8* %45, i8** %4
br label %46
46: ; preds = %36, %32
%47 = load i8, i8* %6
%48 = call i64 @isspace(i8 signext %47)
%49 = icmp ne i64 %48, 0
br i1 %49, label %50, label %51
50: ; preds = %46
br label %64
51: ; preds = %46
%52 = load i8, i8* %6
%53 = call i64 @isalpha(i8 signext %52)
%54 = icmp ne i64 %53, 0
br i1 %54, label %55, label %62
55: ; preds = %51
%56 = load i8, i8* %6
%57 = load i8*, i8** %4
%58 = load i32, i32* %5
%59 = add nsw i32 %58, 1
store i32 %59, i32* %5
%60 = sext i32 %58 to i64
%61 = getelementptr inbounds i8, i8* %57, i64 %60
store i8 %56, i8* %61
br label %62
62: ; preds = %55, %51
br label %63
63: ; preds = %62
br label %25
64: ; preds = %50, %25
%65 = load i32, i32* %5
%66 = icmp ne i32 %65, 0
br i1 %66, label %67, label %80
67: ; preds = %64
%68 = load i8*, i8** %4
%69 = load i32, i32* %5
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i8, i8* %68, i64 %70
store i8 0, i8* %71
%72 = load i8*, i8** %4
%73 = load i32, i32* %5
%74 = add nsw i32 %73, 1
%75 = sext i32 %74 to i64
%76 = mul i64 1, %75
%77 = trunc i64 %76 to i32
%78 = call i64 @realloc(i8* %72, i32 %77)
%79 = inttoptr i64 %78 to i8*
store i8* %79, i8** %4
br label %80
80: ; preds = %67, %64
br label %81
81: ; preds = %80, %1
%82 = load i8*, i8** %4
ret i8* %82
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [40 x i8] c"Traceback most recent call at line: %d \00"
@.str.1 = [26 x i8] c"of file: %s\0A\1B[31m%s\1B[00m\0A\00"
@.str.2 = [158 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/odeke-em/utils/refs/heads/master/dataStructures/hashlist/testHash.c\00"
@.str.3 = [20 x i8] c"\22Run out of memory\22\00"
@EOF = global i8 0
define i8* @getWord(i32* %0) {
%2 = icmp eq i32* %0, null
br i1 %2, label %53, label %3
3: ; preds = %1
%4 = tail call i64 @malloc(i32 10)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %12
6: ; preds = %3
%7 = load i32, i32* @stderr
%8 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 16)
%9 = load i32, i32* @stderr
%10 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([158 x i8], [158 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%11 = tail call i32 @exit(i32 -2)
unreachable
12: ; preds = %3
%13 = inttoptr i64 %4 to i8*
%14 = tail call signext i8 @getc(i32* %0)
%15 = load i8, i8* @EOF
%16 = icmp eq i8 %14, %15
br i1 %16, label %53, label %17
17: ; preds = %12, %39
%18 = phi i8 [ %41, %39 ], [ %14, %12 ]
%19 = phi i32 [ %29, %39 ], [ 10, %12 ]
%20 = phi i32 [ %40, %39 ], [ 0, %12 ]
%21 = phi i8* [ %28, %39 ], [ %13, %12 ]
%22 = icmp slt i32 %20, %19
br i1 %22, label %27, label %23
23: ; preds = %17
%24 = add nsw i32 %19, 10
%25 = tail call i64 @realloc(i8* %21, i32 %24)
%26 = inttoptr i64 %25 to i8*
br label %27
27: ; preds = %23, %17
%28 = phi i8* [ %26, %23 ], [ %21, %17 ]
%29 = phi i32 [ %24, %23 ], [ %19, %17 ]
%30 = tail call i64 @isspace(i8 signext %18)
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %44
32: ; preds = %27
%33 = tail call i64 @isalpha(i8 signext %18)
%34 = icmp eq i64 %33, 0
br i1 %34, label %39, label %35
35: ; preds = %32
%36 = add nsw i32 %20, 1
%37 = sext i32 %20 to i64
%38 = getelementptr inbounds i8, i8* %28, i64 %37
store i8 %18, i8* %38
br label %39
39: ; preds = %32, %35
%40 = phi i32 [ %36, %35 ], [ %20, %32 ]
%41 = tail call signext i8 @getc(i32* %0)
%42 = load i8, i8* @EOF
%43 = icmp eq i8 %41, %42
br i1 %43, label %44, label %17
44: ; preds = %39, %27
%45 = phi i32 [ %40, %39 ], [ %20, %27 ]
%46 = icmp eq i32 %45, 0
br i1 %46, label %53, label %47
47: ; preds = %44
%48 = sext i32 %45 to i64
%49 = getelementptr inbounds i8, i8* %28, i64 %48
store i8 0, i8* %49
%50 = add nsw i32 %45, 1
%51 = tail call i64 @realloc(i8* %28, i32 %50)
%52 = inttoptr i64 %51 to i8*
br label %53
53: ; preds = %12, %44, %47, %1
%54 = phi i8* [ null, %1 ], [ %52, %47 ], [ %28, %44 ], [ %13, %12 ]
ret i8* %54
}