#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 *fgets(char *, int, int /*<<< orphan*/ *);
scalar_t__ my_alloc(int, int, char *);
scalar_t__ realloc(char **, int);
char **get_words(FILE *fp, int *nwords, char **orig_line) {
  int i, j;
  static char str[4096];
  static char str_copy[4096];
  char **words;
  int max_words = 10;
  int num_words = 0;
  char *ptr, *ptr2;
  char *result;
  words =
      (char **)my_alloc((sizeof(char *) * max_words), 1911,
                        "/scratch/repos/new/home/jordi_armengol_estape/"
                        "c-scraper/outputs/2022-01-22/02-19-57/repos/alexbaden/"
                        "go-plyfile/refs/heads/master/lib/plyfile.c");
  result = fgets(str, 4096, fp);
  if (result == NULL) {
    *nwords = 0;
    *orig_line = NULL;
    return (NULL);
  }
  str[4096 - 2] = ' ';
  str[4096 - 1] = '\0';
  for (ptr = str, ptr2 = str_copy; *ptr != '\0'; ptr++, ptr2++) {
    *ptr2 = *ptr;
    if (*ptr == '\t') {
      *ptr = ' ';
      *ptr2 = ' ';
    } else if (*ptr == '\n') {
      *ptr = ' ';
      *ptr2 = '\0';
      break;
    }
  }
  ptr = str;
  while (*ptr != '\0') {
    while (*ptr == ' ')
      ptr++;
    if (*ptr == '\0')
      break;
    if (num_words >= max_words) {
      max_words += 10;
      words = (char **)realloc(words, sizeof(char *) * max_words);
    }
    words[num_words++] = ptr;
    while (*ptr != ' ')
      ptr++;
    *ptr++ = '\0';
  }
  *nwords = num_words;
  *orig_line = str_copy;
  return (words);
}


x86 assembly (clang, -O0):
<get_words>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0xa,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
movslq -0x34(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
mov    $0x777,%esi
lea    0xe98(%rip),%rdx
call   1030 <my_alloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdx
lea    0x2ed4(%rip),%rdi
mov    $0x1000,%esi
call   1040 <fgets@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    11b7 <get_words+0x87>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x20(%rbp),%rax
movq   $0x0,(%rax)
movq   $0x0,-0x8(%rbp)
jmp    1357 <get_words+0x227>
movb   $0x20,0x3e90(%rip)
movb   $0x0,0x3e8a(%rip)
lea    0x2e84(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0x3e79(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    -0x40(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1264 <get_words+0x134>
mov    -0x40(%rbp),%rax
mov    (%rax),%cl
mov    -0x48(%rbp),%rax
mov    %cl,(%rax)
mov    -0x40(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
jne    121a <get_words+0xea>
mov    -0x40(%rbp),%rax
movb   $0x20,(%rax)
mov    -0x48(%rbp),%rax
movb   $0x20,(%rax)
jmp    1242 <get_words+0x112>
mov    -0x40(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    123d <get_words+0x10d>
mov    -0x40(%rbp),%rax
movb   $0x20,(%rax)
mov    -0x48(%rbp),%rax
movb   $0x0,(%rax)
jmp    1264 <get_words+0x134>
jmp    1242 <get_words+0x112>
jmp    1247 <get_words+0x117>
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
jmp    11db <get_words+0xab>
lea    0x2de5(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1338 <get_words+0x208>
jmp    1284 <get_words+0x154>
mov    -0x40(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    12a5 <get_words+0x175>
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    1284 <get_words+0x154>
mov    -0x40(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    12ba <get_words+0x18a>
jmp    1338 <get_words+0x208>
mov    -0x38(%rbp),%eax
cmp    -0x34(%rbp),%eax
jl     12e6 <get_words+0x1b6>
mov    -0x34(%rbp),%eax
add    $0xa,%eax
mov    %eax,-0x34(%rbp)
mov    -0x30(%rbp),%rdi
movslq -0x34(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%esi
call   1050 <realloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x40(%rbp),%rdx
mov    -0x30(%rbp),%rax
mov    -0x38(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x38(%rbp)
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x40(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
je     1321 <get_words+0x1f1>
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    1300 <get_words+0x1d0>
mov    -0x40(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x40(%rbp)
movb   $0x0,(%rax)
jmp    126f <get_words+0x13f>
mov    -0x38(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
lea    0x3d04(%rip),%rcx
mov    %rcx,(%rax)
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_words>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r13
lea    0xeb5(%rip),%rdx
mov    $0x50,%edi
mov    $0x777,%esi
call   1030 <my_alloc@plt>
mov    %rax,%r12
lea    0x2eec(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1000,%esi
mov    %r13,%rdx
call   1040 <fgets@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     1249 <get_words+0x119>
movw   $0x20,0x3ec6(%rip)
mov    0x2ec2(%rip),%cl
test   %cl,%cl
je     1251 <get_words+0x121>
xor    %eax,%eax
lea    0x3eb1(%rip),%r13
jmp    11c6 <get_words+0x96>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movb   $0x20,(%rax,%rbx,1)
movb   $0x20,(%rax,%r13,1)
movzbl 0x1(%rax,%rbx,1),%ecx
add    $0x1,%rax
test   %cl,%cl
je     11dd <get_words+0xad>
mov    %cl,(%rax,%r13,1)
cmp    $0x9,%cl
je     11b0 <get_words+0x80>
cmp    $0xa,%cl
jne    11b9 <get_words+0x89>
movb   $0x20,(%rax,%rbx,1)
movb   $0x0,(%rax,%r13,1)
mov    0x2e6d(%rip),%cl
test   %cl,%cl
je     125a <get_words+0x12a>
mov    $0xa,%eax
xor    %ebp,%ebp
jmp    11f7 <get_words+0xc7>
mov    0x1(%rbx),%cl
add    $0x1,%rbx
cmp    $0x20,%cl
je     11f0 <get_words+0xc0>
test   %cl,%cl
je     125c <get_words+0x12c>
movslq %eax,%rcx
cmp    %rcx,%rbp
jl     122c <get_words+0xfc>
mov    %r14,(%rsp)
mov    %eax,%r14d
add    $0xa,%r14d
lea    0x50(,%rax,8),%esi
mov    %r12,%rdi
call   1050 <realloc@plt>
mov    %rax,%r12
mov    %r14d,%eax
mov    (%rsp),%r14
mov    %rbx,(%r12,%rbp,8)
cmpb   $0x20,(%rbx)
lea    0x1(%rbx),%rbx
jne    1230 <get_words+0x100>
add    $0x1,%rbp
movb   $0x0,-0x1(%rbx)
mov    (%rbx),%cl
test   %cl,%cl
jne    11f7 <get_words+0xc7>
jmp    125c <get_words+0x12c>
xor    %r13d,%r13d
xor    %r12d,%r12d
jmp    125c <get_words+0x12c>
lea    0x3df8(%rip),%r13
jmp    125c <get_words+0x12c>
xor    %ebp,%ebp
mov    %ebp,(%r15)
mov    %r13,(%r14)
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@get_words.str = internal global [4096 x i8] zeroinitializer
@get_words.str_copy = internal global [4096 x i8] zeroinitializer
@.str = [143 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/alexbaden/go-plyfile/refs/heads/master/lib/plyfile.c\00"
define i8** @get_words(i32* %0, i32* %1, i8** %2) {
%4 = alloca i8**
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i8**
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8**
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i8*
store i32* %0, i32** %5
store i32* %1, i32** %6
store i8** %2, i8*** %7
store i32 10, i32* %11
store i32 0, i32* %12
%16 = load i32, i32* %11
%17 = sext i32 %16 to i64
%18 = mul i64 8, %17
%19 = trunc i64 %18 to i32
%20 = call i64 @my_alloc(i32 %19, i32 1911, i8* getelementptr inbounds ([143 x i8], [143 x i8]* @.str, i64 0, i64 0))
%21 = inttoptr i64 %20 to i8**
store i8** %21, i8*** %10
%22 = load i32*, i32** %5
%23 = call i8* @fgets(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @get_words.str, i64 0, i64 0), i32 4096, i32* %22)
store i8* %23, i8** %15
%24 = load i8*, i8** %15
%25 = icmp eq i8* %24, null
br i1 %25, label %26, label %29
26: ; preds = %3
%27 = load i32*, i32** %6
store i32 0, i32* %27
%28 = load i8**, i8*** %7
store i8* null, i8** %28
store i8** null, i8*** %4
br label %119
29: ; preds = %3
store i8 32, i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @get_words.str, i64 0, i64 4094)
store i8 0, i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @get_words.str, i64 0, i64 4095)
store i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @get_words.str, i64 0, i64 0), i8** %13
store i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @get_words.str_copy, i64 0, i64 0), i8** %14
br label %30
30: ; preds = %56, %29
%31 = load i8*, i8** %13
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %61
35: ; preds = %30
%36 = load i8*, i8** %13
%37 = load i8, i8* %36
%38 = load i8*, i8** %14
store i8 %37, i8* %38
%39 = load i8*, i8** %13
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = icmp eq i32 %41, 9
br i1 %42, label %43, label %46
43: ; preds = %35
%44 = load i8*, i8** %13
store i8 32, i8* %44
%45 = load i8*, i8** %14
store i8 32, i8* %45
br label %55
46: ; preds = %35
%47 = load i8*, i8** %13
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = icmp eq i32 %49, 10
br i1 %50, label %51, label %54
51: ; preds = %46
%52 = load i8*, i8** %13
store i8 32, i8* %52
%53 = load i8*, i8** %14
store i8 0, i8* %53
br label %61
54: ; preds = %46
br label %55
55: ; preds = %54, %43
br label %56
56: ; preds = %55
%57 = load i8*, i8** %13
%58 = getelementptr inbounds i8, i8* %57, i32 1
store i8* %58, i8** %13
%59 = load i8*, i8** %14
%60 = getelementptr inbounds i8, i8* %59, i32 1
store i8* %60, i8** %14
br label %30
61: ; preds = %51, %30
store i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @get_words.str, i64 0, i64 0), i8** %13
br label %62
62: ; preds = %111, %61
%63 = load i8*, i8** %13
%64 = load i8, i8* %63
%65 = sext i8 %64 to i32
%66 = icmp ne i32 %65, 0
br i1 %66, label %67, label %114
67: ; preds = %62
br label %68
68: ; preds = %73, %67
%69 = load i8*, i8** %13
%70 = load i8, i8* %69
%71 = sext i8 %70 to i32
%72 = icmp eq i32 %71, 32
br i1 %72, label %73, label %76
73: ; preds = %68
%74 = load i8*, i8** %13
%75 = getelementptr inbounds i8, i8* %74, i32 1
store i8* %75, i8** %13
br label %68
76: ; preds = %68
%77 = load i8*, i8** %13
%78 = load i8, i8* %77
%79 = sext i8 %78 to i32
%80 = icmp eq i32 %79, 0
br i1 %80, label %81, label %82
81: ; preds = %76
br label %114
82: ; preds = %76
%83 = load i32, i32* %12
%84 = load i32, i32* %11
%85 = icmp sge i32 %83, %84
br i1 %85, label %86, label %96
86: ; preds = %82
%87 = load i32, i32* %11
%88 = add nsw i32 %87, 10
store i32 %88, i32* %11
%89 = load i8**, i8*** %10
%90 = load i32, i32* %11
%91 = sext i32 %90 to i64
%92 = mul i64 8, %91
%93 = trunc i64 %92 to i32
%94 = call i64 @realloc(i8** %89, i32 %93)
%95 = inttoptr i64 %94 to i8**
store i8** %95, i8*** %10
br label %96
96: ; preds = %86, %82
%97 = load i8*, i8** %13
%98 = load i8**, i8*** %10
%99 = load i32, i32* %12
%100 = add nsw i32 %99, 1
store i32 %100, i32* %12
%101 = sext i32 %99 to i64
%102 = getelementptr inbounds i8*, i8** %98, i64 %101
store i8* %97, i8** %102
br label %103
103: ; preds = %108, %96
%104 = load i8*, i8** %13
%105 = load i8, i8* %104
%106 = sext i8 %105 to i32
%107 = icmp ne i32 %106, 32
br i1 %107, label %108, label %111
108: ; preds = %103
%109 = load i8*, i8** %13
%110 = getelementptr inbounds i8, i8* %109, i32 1
store i8* %110, i8** %13
br label %103
111: ; preds = %103
%112 = load i8*, i8** %13
%113 = getelementptr inbounds i8, i8* %112, i32 1
store i8* %113, i8** %13
store i8 0, i8* %112
br label %62
114: ; preds = %81, %62
%115 = load i32, i32* %12
%116 = load i32*, i32** %6
store i32 %115, i32* %116
%117 = load i8**, i8*** %7
store i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @get_words.str_copy, i64 0, i64 0), i8** %117
%118 = load i8**, i8*** %10
store i8** %118, i8*** %4
br label %119
119: ; preds = %114, %26
%120 = load i8**, i8*** %4
ret i8** %120
}

LLVM IR (-O2):
@get_words.str = internal global [4096 x i8] zeroinitializer
@get_words.str_copy = internal global [4096 x i8] zeroinitializer
@.str = [143 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/alexbaden/go-plyfile/refs/heads/master/lib/plyfile.c\00"
define i8** @get_words(i32* nocapture %0, i32* nocapture writeonly %1, i8** nocapture writeonly %2) {
%4 = tail call i64 @my_alloc(i32 80, i32 1911, i8* getelementptr inbounds ([143 x i8], [143 x i8]* @.str, i64 0, i64 0))
%5 = inttoptr i64 %4 to i8**
%6 = tail call i8* @fgets(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @get_words.str, i64 0, i64 0), i32 4096, i32* %0)
%7 = icmp eq i8* %6, null
br i1 %7, label %62, label %8
8: ; preds = %3
store i8 32, i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @get_words.str, i64 0, i64 4094)
store i8 0, i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @get_words.str, i64 0, i64 4095)
%9 = load i8, i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @get_words.str, i64 0, i64 0)
%10 = icmp eq i8 %9, 0
br i1 %10, label %62, label %11
11: ; preds = %8, %17
%12 = phi i8 [ %20, %17 ], [ %9, %8 ]
%13 = phi i8* [ %19, %17 ], [ getelementptr inbounds ([4096 x i8], [4096 x i8]* @get_words.str_copy, i64 0, i64 0), %8 ]
%14 = phi i8* [ %18, %17 ], [ getelementptr inbounds ([4096 x i8], [4096 x i8]* @get_words.str, i64 0, i64 0), %8 ]
store i8 %12, i8* %13
switch i8 %12, label %17 [
i8 9, label %15
i8 10, label %16
]
15: ; preds = %11
store i8 32, i8* %14
store i8 32, i8* %13
br label %17
16: ; preds = %11
store i8 32, i8* %14
store i8 0, i8* %13
br label %22
17: ; preds = %11, %15
%18 = getelementptr inbounds i8, i8* %14, i64 1
%19 = getelementptr inbounds i8, i8* %13, i64 1
%20 = load i8, i8* %18
%21 = icmp eq i8 %20, 0
br i1 %21, label %22, label %11
22: ; preds = %17, %16
%23 = load i8, i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @get_words.str, i64 0, i64 0)
%24 = icmp eq i8 %23, 0
br i1 %24, label %62, label %25
25: ; preds = %22, %54
%26 = phi i64 [ %55, %54 ], [ 0, %22 ]
%27 = phi i8 [ %56, %54 ], [ %23, %22 ]
%28 = phi i8* [ %53, %54 ], [ getelementptr inbounds ([4096 x i8], [4096 x i8]* @get_words.str, i64 0, i64 0), %22 ]
%29 = phi i32 [ %47, %54 ], [ 10, %22 ]
%30 = phi i8** [ %46, %54 ], [ %5, %22 ]
br label %31
31: ; preds = %25, %34
%32 = phi i8 [ %36, %34 ], [ %27, %25 ]
%33 = phi i8* [ %35, %34 ], [ %28, %25 ]
switch i8 %32, label %37 [
i8 32, label %34
i8 0, label %58
]
34: ; preds = %31
%35 = getelementptr inbounds i8, i8* %33, i64 1
%36 = load i8, i8* %35
br label %31
37: ; preds = %31
%38 = sext i32 %29 to i64
%39 = icmp slt i64 %26, %38
br i1 %39, label %45, label %40
40: ; preds = %37
%41 = add nsw i32 %29, 10
%42 = shl i32 %41, 3
%43 = tail call i64 @realloc(i8** %30, i32 %42)
%44 = inttoptr i64 %43 to i8**
br label %45
45: ; preds = %40, %37
%46 = phi i8** [ %44, %40 ], [ %30, %37 ]
%47 = phi i32 [ %41, %40 ], [ %29, %37 ]
%48 = getelementptr inbounds i8*, i8** %46, i64 %26
store i8* %33, i8** %48
br label %49
49: ; preds = %49, %45
%50 = phi i8* [ %33, %45 ], [ %53, %49 ]
%51 = load i8, i8* %50
%52 = icmp eq i8 %51, 32
%53 = getelementptr inbounds i8, i8* %50, i64 1
br i1 %52, label %54, label %49
54: ; preds = %49
%55 = add nuw i64 %26, 1
store i8 0, i8* %50
%56 = load i8, i8* %53
%57 = icmp eq i8 %56, 0
br i1 %57, label %60, label %25
58: ; preds = %31
%59 = trunc i64 %26 to i32
br label %62
60: ; preds = %54
%61 = trunc i64 %55 to i32
br label %62
62: ; preds = %8, %60, %58, %22, %3
%63 = phi i32 [ 0, %3 ], [ 0, %22 ], [ %59, %58 ], [ %61, %60 ], [ 0, %8 ]
%64 = phi i8* [ null, %3 ], [ getelementptr inbounds ([4096 x i8], [4096 x i8]* @get_words.str_copy, i64 0, i64 0), %22 ], [ getelementptr inbounds ([4096 x i8], [4096 x i8]* @get_words.str_copy, i64 0, i64 0), %58 ], [ getelementptr inbounds ([4096 x i8], [4096 x i8]* @get_words.str_copy, i64 0, i64 0), %60 ], [ getelementptr inbounds ([4096 x i8], [4096 x i8]* @get_words.str_copy, i64 0, i64 0), %8 ]
%65 = phi i8** [ null, %3 ], [ %5, %22 ], [ %30, %58 ], [ %46, %60 ], [ %5, %8 ]
store i32 %63, i32* %1
store i8* %64, i8** %2
ret i8** %65
}