#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 */
int EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int getWords(char *, int, char **);
int getc(int /*<<< orphan*/ *);
scalar_t__ isalnum(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int main(void) {
  FILE *srcf;
  int ch1, counter = 0, word_size = 0;
  srcf = fopen("main.c", "r");
  if (srcf == NULL)
    printf("Cannot open main.c for reading\n");
  else {
    ch1 = getc(srcf);
    while (ch1 != EOF) {
      if (isalnum(ch1)) {
        counter++;
        if (counter > word_size)
          word_size = counter;
      } else
        counter = 0;
      ch1 = getc(srcf);
    }
    fclose(srcf);
  }
  char a[1000][word_size];
  int n = getWords("main.c", word_size, a);
  if (n > 0) {
    puts("gevonden woorden:");
    for (int i = 0; i < n; i++) {
      printf("%3d %s\n", i, a[i]);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xe6c(%rip),%rdi
lea    0xe6c(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11c2 <main+0x52>
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1233 <main+0xc3>
mov    -0x10(%rbp),%rdi
call   1090 <getc@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e10(%rip),%rcx
cmp    (%rcx),%eax
je     122a <main+0xba>
mov    -0x14(%rbp),%edi
call   1060 <isalnum@plt>
cmp    $0x0,%rax
je     1212 <main+0xa2>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jle    120d <main+0x9d>
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    1219 <main+0xa9>
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1090 <getc@plt>
mov    %eax,-0x14(%rbp)
jmp    11ce <main+0x5e>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x1c(%rbp),%eax
mov    %rax,-0x48(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
imul   $0x3e8,%rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdx
sub    %rcx,%rdx
mov    %rdx,-0x40(%rbp)
mov    %rdx,%rsp
mov    %rax,-0x30(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xd95(%rip),%rdi
call   1070 <getWords@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jle    12d3 <main+0x163>
lea    0xda5(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    12ce <main+0x15e>
mov    -0x40(%rbp),%rdx
mov    -0x48(%rbp),%rcx
mov    -0x38(%rbp),%esi
movslq -0x38(%rbp),%rax
imul   %rcx,%rax
add    %rax,%rdx
lea    0xd82(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1290 <main+0x120>
jmp    12d3 <main+0x163>
movl   $0x0,-0x4(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe7b(%rip),%rdi
lea    0xe7b(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1200 <main+0x90>
mov    %rax,%r14
mov    %rax,%rdi
call   1090 <getc@plt>
mov    0x2e40(%rip),%r13
xor    %r15d,%r15d
cmp    0x0(%r13),%eax
je     11f6 <main+0x86>
xor    %ebx,%ebx
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
mov    %eax,%edi
call   1060 <isalnum@plt>
lea    0x1(%rbx),%r12d
cmp    %r15d,%ebx
mov    %r12d,%ecx
cmovl  %r15d,%ecx
test   %rax,%rax
cmovne %ecx,%r15d
mov    $0x0,%eax
cmove  %eax,%r12d
mov    %r14,%rdi
call   1090 <getc@plt>
mov    %r12d,%ebx
cmp    0x0(%r13),%eax
jne    11c0 <main+0x50>
mov    %r14,%rdi
call   1040 <fclose@plt>
jmp    120f <main+0x9f>
lea    0xe1c(%rip),%rdi
call   1030 <puts@plt>
xor    %r15d,%r15d
mov    %r15d,%r13d
mov    %rsp,%r12
imul   $0x3e8,%r13,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
lea    0xdcf(%rip),%rdi
mov    %r15d,%esi
mov    %r12,%rdx
call   1070 <getWords@plt>
test   %eax,%eax
jle    127b <main+0x10b>
mov    %eax,%ebx
lea    0xdc0(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%r15d
lea    0xdc3(%rip),%r14
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebx,%esi
mov    %r12,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
add    %r13,%r12
cmp    %rbx,%r15
jne    1260 <main+0xf0>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"main.c\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [32 x i8] c"Cannot open main.c for reading\0A\00"
@EOF = global i32 0
@.str.3 = [18 x i8] c"gevonden woorden:\00"
@.str.4 = [8 x i8] c"%3d %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
store i32 0, i32* %5
%10 = call i32* @fopen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %10, i32** %2
%11 = load i32*, i32** %2
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %15
13: ; preds = %0
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
br label %42
15: ; preds = %0
%16 = load i32*, i32** %2
%17 = call i32 @getc(i32* %16)
store i32 %17, i32* %3
br label %18
18: ; preds = %36, %15
%19 = load i32, i32* %3
%20 = load i32, i32* @EOF
%21 = icmp ne i32 %19, %20
br i1 %21, label %22, label %39
22: ; preds = %18
%23 = load i32, i32* %3
%24 = call i64 @isalnum(i32 %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %35
26: ; preds = %22
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 1
store i32 %28, i32* %4
%29 = load i32, i32* %4
%30 = load i32, i32* %5
%31 = icmp sgt i32 %29, %30
br i1 %31, label %32, label %34
32: ; preds = %26
%33 = load i32, i32* %4
store i32 %33, i32* %5
br label %34
34: ; preds = %32, %26
br label %36
35: ; preds = %22
store i32 0, i32* %4
br label %36
36: ; preds = %35, %34
%37 = load i32*, i32** %2
%38 = call i32 @getc(i32* %37)
store i32 %38, i32* %3
br label %18
39: ; preds = %18
%40 = load i32*, i32** %2
%41 = call i32 @fclose(i32* %40)
br label %42
42: ; preds = %39, %13
%43 = load i32, i32* %5
%44 = zext i32 %43 to i64
%45 = call i8* @llvm.stacksave()
store i8* %45, i8** %6
%46 = mul nuw i64 1000, %44
%47 = alloca i8, i64 %46
store i64 %44, i64* %7
%48 = load i32, i32* %5
%49 = bitcast i8* %47 to i8**
%50 = call i32 @getWords(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %48, i8** %49)
store i32 %50, i32* %8
%51 = load i32, i32* %8
%52 = icmp sgt i32 %51, 0
br i1 %52, label %53, label %70
53: ; preds = %42
%54 = call i32 @puts(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %9
br label %55
55: ; preds = %66, %53
%56 = load i32, i32* %9
%57 = load i32, i32* %8
%58 = icmp slt i32 %56, %57
br i1 %58, label %59, label %69
59: ; preds = %55
%60 = load i32, i32* %9
%61 = load i32, i32* %9
%62 = sext i32 %61 to i64
%63 = mul nsw i64 %62, %44
%64 = getelementptr inbounds i8, i8* %47, i64 %63
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %60, i8* %64)
br label %66
66: ; preds = %59
%67 = load i32, i32* %9
%68 = add nsw i32 %67, 1
store i32 %68, i32* %9
br label %55
69: ; preds = %55
br label %70
70: ; preds = %69, %42
store i32 0, i32* %1
%71 = load i8*, i8** %6
%72 = load i32, i32* %1
ret i32 %72
}

LLVM IR (-O2):
@.str = [7 x i8] c"main.c\00"
@.str.1 = [2 x i8] c"r\00"
@EOF = global i32 0
@.str.3 = [18 x i8] c"gevonden woorden:\00"
@.str.4 = [8 x i8] c"%3d %s\0A\00"
@str = [31 x i8] c"Cannot open main.c for reading\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%2 = icmp eq i32* %1, null
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
br label %26
5: ; preds = %0
%6 = tail call i32 @getc(i32* %1)
%7 = load i32, i32* @EOF
%8 = icmp eq i32 %6, %7
br i1 %8, label %23, label %9
9: ; preds = %5, %9
%10 = phi i32 [ %20, %9 ], [ %6, %5 ]
%11 = phi i32 [ %19, %9 ], [ 0, %5 ]
%12 = phi i32 [ %18, %9 ], [ 0, %5 ]
%13 = tail call i64 @isalnum(i32 %10)
%14 = icmp eq i64 %13, 0
%15 = add nsw i32 %11, 1
%16 = icmp slt i32 %11, %12
%17 = select i1 %14, i1 true, i1 %16
%18 = select i1 %17, i32 %12, i32 %15
%19 = select i1 %14, i32 0, i32 %15
%20 = tail call i32 @getc(i32* %1)
%21 = load i32, i32* @EOF
%22 = icmp eq i32 %20, %21
br i1 %22, label %23, label %9
23: ; preds = %9, %5
%24 = phi i32 [ 0, %5 ], [ %18, %9 ]
%25 = tail call i32 @fclose(i32* %1)
br label %26
26: ; preds = %23, %3
%27 = phi i32 [ 0, %3 ], [ %24, %23 ]
%28 = zext i32 %27 to i64
%29 = mul nuw nsw i64 %28, 125
%30 = alloca i8*, i64 %29
%31 = bitcast i8** %30 to i8*
%32 = call i32 @getWords(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %27, i8** %30)
%33 = icmp sgt i32 %32, 0
br i1 %33, label %34, label %45
34: ; preds = %26
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%36 = zext i32 %32 to i64
br label %37
37: ; preds = %34, %37
%38 = phi i64 [ 0, %34 ], [ %43, %37 ]
%39 = mul nuw nsw i64 %38, %28
%40 = getelementptr inbounds i8, i8* %31, i64 %39
%41 = trunc i64 %38 to i32
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %41, i8* %40)
%43 = add nuw nsw i64 %38, 1
%44 = icmp eq i64 %43, %36
br i1 %44, label %45, label %37
45: ; preds = %37, %26
ret i32 0
}