#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 /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *const, char *);
char *getPtrInLineForProject(char *);
scalar_t__ isLineAComment(char *);
int getProjectsNumber(const char *const filename) {
  FILE *fin = fopen(filename, "r");
  if (fin == NULL) {
    exit(2);
  }
  char line[100];
  int retval = 0;
  while (fgets(line, 100, fin) != NULL) {
    if (isLineAComment(line)) {
      continue;
    }
    const char *projectName = getPtrInLineForProject(line);
    if (projectName == NULL) {
      continue;
    }
    retval++;
  }
  return retval;
}


x86 assembly (clang, -O0):
<getProjectsNumber>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe96(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1188 <getProjectsNumber+0x38>
mov    $0x2,%edi
call   1070 <exit@plt>
movl   $0x0,-0x84(%rbp)
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x64,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     11fd <getProjectsNumber+0xad>
lea    -0x80(%rbp),%rdi
call   1040 <isLineAComment@plt>
cmp    $0x0,%rax
je     11c6 <getProjectsNumber+0x76>
jmp    1192 <getProjectsNumber+0x42>
lea    -0x80(%rbp),%rdi
call   1030 <getPtrInLineForProject@plt>
mov    %rax,-0x90(%rbp)
cmpq   $0x0,-0x90(%rbp)
jne    11e9 <getProjectsNumber+0x99>
jmp    1192 <getProjectsNumber+0x42>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    1192 <getProjectsNumber+0x42>
mov    -0x84(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getProjectsNumber>:
push   %rbp
push   %r14
push   %rbx
sub    $0x70,%rsp
lea    0xea1(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11c0 <getProjectsNumber+0x70>
mov    %rax,%rbx
xor    %r14d,%r14d
mov    %rsp,%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbp,%rdi
mov    $0x64,%esi
mov    %rbx,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     11b4 <getProjectsNumber+0x64>
mov    %rbp,%rdi
call   1040 <isLineAComment@plt>
test   %rax,%rax
jne    1180 <getProjectsNumber+0x30>
mov    %rbp,%rdi
call   1030 <getPtrInLineForProject@plt>
cmp    $0x1,%rax
sbb    $0xffffffff,%r14d
jmp    1180 <getProjectsNumber+0x30>
mov    %r14d,%eax
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    $0x2,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
define i32 @getProjectsNumber(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca [100 x i8]
%5 = alloca i32
%6 = alloca i8*
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %8, i32** %3
%9 = load i32*, i32** %3
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %13
11: ; preds = %1
%12 = call i32 @exit(i32 2)
unreachable
13: ; preds = %1
store i32 0, i32* %5
br label %14
14: ; preds = %30, %29, %23, %13
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%16 = load i32*, i32** %3
%17 = call i32* @fgets(i8* %15, i32 100, i32* %16)
%18 = icmp ne i32* %17, null
br i1 %18, label %19, label %33
19: ; preds = %14
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%21 = call i64 @isLineAComment(i8* %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %19
br label %14
24: ; preds = %19
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%26 = call i8* @getPtrInLineForProject(i8* %25)
store i8* %26, i8** %6
%27 = load i8*, i8** %6
%28 = icmp eq i8* %27, null
br i1 %28, label %29, label %30
29: ; preds = %24
br label %14
30: ; preds = %24
%31 = load i32, i32* %5
%32 = add nsw i32 %31, 1
store i32 %32, i32* %5
br label %14
33: ; preds = %14
%34 = load i32, i32* %5
ret i32 %34
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
define i32 @getProjectsNumber(i8* nocapture %0) {
%2 = alloca [100 x i8]
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = tail call i32 @exit(i32 2)
unreachable
7: ; preds = %1
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
br label %9
9: ; preds = %17, %7
%10 = phi i32 [ %21, %17 ], [ 0, %7 ]
br label %11
11: ; preds = %9, %14
%12 = call i32* @fgets(i8* %8, i32 100, i32* %3)
%13 = icmp eq i32* %12, null
br i1 %13, label %22, label %14
14: ; preds = %11
%15 = call i64 @isLineAComment(i8* %8)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %11
17: ; preds = %14
%18 = call i8* @getPtrInLineForProject(i8* %8)
%19 = icmp ne i8* %18, null
%20 = zext i1 %19 to i32
%21 = add nuw nsw i32 %10, %20
br label %9
22: ; preds = %11
ret i32 %10
}