#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) {
  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), 1691,
                        "/scratch/repos/new/home/jordi_armengol_estape/"
                        "c-scraper/outputs/2022-01-22/02-19-57/repos/uDeviceX/"
                        "uDeviceX/refs/heads/master/lib/ply/src/main.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,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
movslq -0x2c(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
mov    $0x69b,%esi
lea    0xe98(%rip),%rdx
call   1030 <my_alloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdx
lea    0x2ed4(%rip),%rdi
mov    $0x1000,%esi
call   1040 <fgets@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%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,-0x38(%rbp)
lea    0x3e79(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1264 <get_words+0x134>
mov    -0x38(%rbp),%rax
mov    (%rax),%cl
mov    -0x40(%rbp),%rax
mov    %cl,(%rax)
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
jne    121a <get_words+0xea>
mov    -0x38(%rbp),%rax
movb   $0x20,(%rax)
mov    -0x40(%rbp),%rax
movb   $0x20,(%rax)
jmp    1242 <get_words+0x112>
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    123d <get_words+0x10d>
mov    -0x38(%rbp),%rax
movb   $0x20,(%rax)
mov    -0x40(%rbp),%rax
movb   $0x0,(%rax)
jmp    1264 <get_words+0x134>
jmp    1242 <get_words+0x112>
jmp    1247 <get_words+0x117>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    11db <get_words+0xab>
lea    0x2de5(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1338 <get_words+0x208>
jmp    1284 <get_words+0x154>
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    12a5 <get_words+0x175>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    1284 <get_words+0x154>
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    12ba <get_words+0x18a>
jmp    1338 <get_words+0x208>
mov    -0x30(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jl     12e6 <get_words+0x1b6>
mov    -0x2c(%rbp),%eax
add    $0xa,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%rdi
movslq -0x2c(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%esi
call   1050 <realloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x38(%rbp),%rdx
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x30(%rbp)
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
je     1321 <get_words+0x1f1>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    1300 <get_words+0x1d0>
mov    -0x38(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x38(%rbp)
movb   $0x0,(%rax)
jmp    126f <get_words+0x13f>
mov    -0x30(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
lea    0x3d04(%rip),%rcx
mov    %rcx,(%rax)
mov    -0x28(%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    $0x69b,%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 = [145 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/uDeviceX/uDeviceX/refs/heads/master/lib/ply/src/main.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 i8**
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
store i32* %0, i32** %5
store i32* %1, i32** %6
store i8** %2, i8*** %7
store i32 10, i32* %9
store i32 0, i32* %10
%14 = load i32, i32* %9
%15 = sext i32 %14 to i64
%16 = mul i64 8, %15
%17 = trunc i64 %16 to i32
%18 = call i64 @my_alloc(i32 %17, i32 1691, i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str, i64 0, i64 0))
%19 = inttoptr i64 %18 to i8**
store i8** %19, i8*** %8
%20 = load i32*, i32** %5
%21 = call i8* @fgets(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @get_words.str, i64 0, i64 0), i32 4096, i32* %20)
store i8* %21, i8** %13
%22 = load i8*, i8** %13
%23 = icmp eq i8* %22, null
br i1 %23, label %24, label %27
24: ; preds = %3
%25 = load i32*, i32** %6
store i32 0, i32* %25
%26 = load i8**, i8*** %7
store i8* null, i8** %26
store i8** null, i8*** %4
br label %117
27: ; 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** %11
store i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @get_words.str_copy, i64 0, i64 0), i8** %12
br label %28
28: ; preds = %54, %27
%29 = load i8*, i8** %11
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %59
33: ; preds = %28
%34 = load i8*, i8** %11
%35 = load i8, i8* %34
%36 = load i8*, i8** %12
store i8 %35, i8* %36
%37 = load i8*, i8** %11
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 9
br i1 %40, label %41, label %44
41: ; preds = %33
%42 = load i8*, i8** %11
store i8 32, i8* %42
%43 = load i8*, i8** %12
store i8 32, i8* %43
br label %53
44: ; preds = %33
%45 = load i8*, i8** %11
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = icmp eq i32 %47, 10
br i1 %48, label %49, label %52
49: ; preds = %44
%50 = load i8*, i8** %11
store i8 32, i8* %50
%51 = load i8*, i8** %12
store i8 0, i8* %51
br label %59
52: ; preds = %44
br label %53
53: ; preds = %52, %41
br label %54
54: ; preds = %53
%55 = load i8*, i8** %11
%56 = getelementptr inbounds i8, i8* %55, i32 1
store i8* %56, i8** %11
%57 = load i8*, i8** %12
%58 = getelementptr inbounds i8, i8* %57, i32 1
store i8* %58, i8** %12
br label %28
59: ; preds = %49, %28
store i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @get_words.str, i64 0, i64 0), i8** %11
br label %60
60: ; preds = %109, %59
%61 = load i8*, i8** %11
%62 = load i8, i8* %61
%63 = sext i8 %62 to i32
%64 = icmp ne i32 %63, 0
br i1 %64, label %65, label %112
65: ; preds = %60
br label %66
66: ; preds = %71, %65
%67 = load i8*, i8** %11
%68 = load i8, i8* %67
%69 = sext i8 %68 to i32
%70 = icmp eq i32 %69, 32
br i1 %70, label %71, label %74
71: ; preds = %66
%72 = load i8*, i8** %11
%73 = getelementptr inbounds i8, i8* %72, i32 1
store i8* %73, i8** %11
br label %66
74: ; preds = %66
%75 = load i8*, i8** %11
%76 = load i8, i8* %75
%77 = sext i8 %76 to i32
%78 = icmp eq i32 %77, 0
br i1 %78, label %79, label %80
79: ; preds = %74
br label %112
80: ; preds = %74
%81 = load i32, i32* %10
%82 = load i32, i32* %9
%83 = icmp sge i32 %81, %82
br i1 %83, label %84, label %94
84: ; preds = %80
%85 = load i32, i32* %9
%86 = add nsw i32 %85, 10
store i32 %86, i32* %9
%87 = load i8**, i8*** %8
%88 = load i32, i32* %9
%89 = sext i32 %88 to i64
%90 = mul i64 8, %89
%91 = trunc i64 %90 to i32
%92 = call i64 @realloc(i8** %87, i32 %91)
%93 = inttoptr i64 %92 to i8**
store i8** %93, i8*** %8
br label %94
94: ; preds = %84, %80
%95 = load i8*, i8** %11
%96 = load i8**, i8*** %8
%97 = load i32, i32* %10
%98 = add nsw i32 %97, 1
store i32 %98, i32* %10
%99 = sext i32 %97 to i64
%100 = getelementptr inbounds i8*, i8** %96, i64 %99
store i8* %95, i8** %100
br label %101
101: ; preds = %106, %94
%102 = load i8*, i8** %11
%103 = load i8, i8* %102
%104 = sext i8 %103 to i32
%105 = icmp ne i32 %104, 32
br i1 %105, label %106, label %109
106: ; preds = %101
%107 = load i8*, i8** %11
%108 = getelementptr inbounds i8, i8* %107, i32 1
store i8* %108, i8** %11
br label %101
109: ; preds = %101
%110 = load i8*, i8** %11
%111 = getelementptr inbounds i8, i8* %110, i32 1
store i8* %111, i8** %11
store i8 0, i8* %110
br label %60
112: ; preds = %79, %60
%113 = load i32, i32* %10
%114 = load i32*, i32** %6
store i32 %113, i32* %114
%115 = load i8**, i8*** %7
store i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @get_words.str_copy, i64 0, i64 0), i8** %115
%116 = load i8**, i8*** %8
store i8** %116, i8*** %4
br label %117
117: ; preds = %112, %24
%118 = load i8**, i8*** %4
ret i8** %118
}

LLVM IR (-O2):
@get_words.str = internal global [4096 x i8] zeroinitializer
@get_words.str_copy = internal global [4096 x i8] zeroinitializer
@.str = [145 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/uDeviceX/uDeviceX/refs/heads/master/lib/ply/src/main.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 1691, i8* getelementptr inbounds ([145 x i8], [145 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
}