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

/* Variables and functions */
char *calloc(scalar_t__, int);
int /*<<< orphan*/ delnewline(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
int getword(FILE *wordlist, char **word) {
  char buffer[512];
  memset(buffer, 0, sizeof(buffer));
  if (fgets(buffer, 512 - 1, wordlist) == NULL)
    return (0);
  while (buffer[0] == '#') {
    if (fgets(buffer, 512 - 1, wordlist) == NULL)
      return (0);
  }
  delnewline(buffer);
  (*word) = calloc(strlen(buffer) + 1, sizeof(char));
  if ((*word) == NULL) {
    fprintf(stderr, "\n%s\n", "Memory Error");
    exit(1);
  };
  strcpy(*word, buffer);
  return (1);
}


x86 assembly (clang, -O0):
<getword>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x220(%rbp),%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1060 <memset@plt>
lea    -0x220(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x1ff,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
jne    11d1 <getword+0x51>
movl   $0x0,-0x4(%rbp)
jmp    1297 <getword+0x117>
jmp    11d6 <getword+0x56>
movsbl -0x220(%rbp),%eax
cmp    $0x23,%eax
jne    1216 <getword+0x96>
lea    -0x220(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x1ff,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
jne    1211 <getword+0x91>
movl   $0x0,-0x4(%rbp)
jmp    1297 <getword+0x117>
jmp    11d6 <getword+0x56>
lea    -0x220(%rbp),%rdi
call   1040 <delnewline@plt>
lea    -0x220(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
mov    $0x1,%esi
call   1080 <calloc@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
jne    127d <getword+0xfd>
mov    0x2d82(%rip),%rax
mov    (%rax),%edi
lea    0xd99(%rip),%rsi
lea    0xd97(%rip),%rdx
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
lea    -0x220(%rbp),%rsi
call   1030 <strcpy@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getword>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x208,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsp,%rbp
xor    %r15d,%r15d
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1060 <memset@plt>
mov    %rbp,%rdi
mov    $0x1ff,%esi
mov    %rbx,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     1217 <getword+0x97>
mov    %rsp,%rbp
cmpb   $0x23,(%rsp)
jne    11dd <getword+0x5d>
mov    %rbp,%rdi
mov    $0x1ff,%esi
mov    %rbx,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
jne    11c0 <getword+0x40>
jmp    1217 <getword+0x97>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <delnewline@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%rdi
mov    $0x1,%r15d
mov    $0x1,%esi
call   1080 <calloc@plt>
mov    %rax,(%r14)
test   %rax,%rax
je     1228 <getword+0xa8>
mov    %rsp,%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
mov    %r15d,%eax
add    $0x208,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2db1(%rip),%rax
mov    (%rax),%edi
lea    0xdc8(%rip),%rsi
lea    0xdc6(%rip),%rdx
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [5 x i8] c"\0A%s\0A\00"
@.str.1 = [13 x i8] c"Memory Error\00"
define i32 @getword(i32* %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8**
%6 = alloca [512 x i8]
store i32* %0, i32** %4
store i8** %1, i8*** %5
%7 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%8 = call i32 @memset(i8* %7, i32 0, i32 512)
%9 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%10 = load i32*, i32** %4
%11 = call i32* @fgets(i8* %9, i32 511, i32* %10)
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %14
13: ; preds = %2
store i32 0, i32* %3
br label %47
14: ; preds = %2
br label %15
15: ; preds = %26, %14
%16 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 35
br i1 %19, label %20, label %27
20: ; preds = %15
%21 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%22 = load i32*, i32** %4
%23 = call i32* @fgets(i8* %21, i32 511, i32* %22)
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %26
25: ; preds = %20
store i32 0, i32* %3
br label %47
26: ; preds = %20
br label %15
27: ; preds = %15
%28 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%29 = call i32 @delnewline(i8* %28)
%30 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%31 = call i64 @strlen(i8* %30)
%32 = add nsw i64 %31, 1
%33 = call i8* @calloc(i64 %32, i32 1)
%34 = load i8**, i8*** %5
store i8* %33, i8** %34
%35 = load i8**, i8*** %5
%36 = load i8*, i8** %35
%37 = icmp eq i8* %36, null
br i1 %37, label %38, label %42
38: ; preds = %27
%39 = load i32, i32* @stderr
%40 = call i32 @fprintf(i32 %39, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%41 = call i32 @exit(i32 1)
unreachable
42: ; preds = %27
%43 = load i8**, i8*** %5
%44 = load i8*, i8** %43
%45 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%46 = call i32 @strcpy(i8* %44, i8* %45)
store i32 1, i32* %3
br label %47
47: ; preds = %42, %25, %13
%48 = load i32, i32* %3
ret i32 %48
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [5 x i8] c"\0A%s\0A\00"
@.str.1 = [13 x i8] c"Memory Error\00"
define i32 @getword(i32* nocapture %0, i8** nocapture writeonly %1) {
%3 = alloca [512 x i8]
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%5 = call i32 @memset(i8* %4, i32 0, i32 512)
%6 = call i32* @fgets(i8* %4, i32 511, i32* %0)
%7 = icmp eq i32* %6, null
br i1 %7, label %26, label %8
8: ; preds = %2, %11
%9 = load i8, i8* %4
%10 = icmp eq i8 %9, 35
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = call i32* @fgets(i8* %4, i32 511, i32* %0)
%13 = icmp eq i32* %12, null
br i1 %13, label %26, label %8
14: ; preds = %8
%15 = call i32 @delnewline(i8* %4)
%16 = call i64 @strlen(i8* %4)
%17 = add nsw i64 %16, 1
%18 = call i8* @calloc(i64 %17, i32 1)
store i8* %18, i8** %1
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %24
20: ; preds = %14
%21 = load i32, i32* @stderr
%22 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%23 = call i32 @exit(i32 1)
unreachable
24: ; preds = %14
%25 = call i32 @strcpy(i8* %18, i8* %4)
br label %26
26: ; preds = %11, %2, %24
%27 = phi i32 [ 1, %24 ], [ 0, %2 ], [ 0, %11 ]
ret i32 %27
}