#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
char *strtok(char *, char *);
int main(int argc, char *argv[]) {
  FILE *fp = NULL;
  char line[100], *token = NULL;
  int n = 0;
  if (argc != 2) {
    printf("\nProvide the html source file\n");
    return -1;
  }
  fp = fopen(argv[1], "r");
  if (NULL == fp) {
    return -1;
  }
  while (NULL != fgets(line, 100, fp)) {
    token = strtok(line, "<>");
    while (NULL != token) {
      n++;
      token = strtok(NULL, "<>");
    }
  }
  printf("\nNo of tokens : %d\n", n);
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x88(%rbp)
movl   $0x0,-0x8c(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11aa <main+0x5a>
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1279 <main+0x129>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe66(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
cmp    -0x18(%rbp),%rax
jne    11da <main+0x8a>
movl   $0xffffffff,-0x4(%rbp)
jmp    1279 <main+0x129>
jmp    11df <main+0x8f>
lea    -0x80(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x64,%esi
call   1050 <fgets@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     1255 <main+0x105>
lea    -0x80(%rbp),%rdi
lea    0xe17(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x88(%rbp)
xor    %eax,%eax
cmp    -0x88(%rbp),%rax
je     1250 <main+0x100>
mov    -0x8c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8c(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xde2(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x88(%rbp)
jmp    1216 <main+0xc6>
jmp    11df <main+0x8f>
mov    -0x8c(%rbp),%esi
lea    0xdc2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x70,%rsp
cmp    $0x2,%edi
jne    11f4 <main+0x94>
mov    0x8(%rsi),%rdi
lea    0xe80(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1200 <main+0xa0>
mov    %rax,%r15
mov    %rsp,%rdi
mov    $0x64,%esi
mov    %rax,%rdx
call   1060 <fgets@plt>
xor    %r14d,%r14d
mov    $0x0,%ebp
test   %rax,%rax
je     1208 <main+0xa8>
xor    %ebp,%ebp
lea    0xe4f(%rip),%rbx
mov    %rsp,%r12
jmp    11d5 <main+0x75>
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    $0x64,%esi
mov    %r15,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     1208 <main+0xa8>
mov    %r12,%rdi
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rsi
call   1080 <strtok@plt>
test   %rax,%rax
je     11c0 <main+0x60>
add    $0x1,%ebp
xor    %edi,%edi
jmp    11e0 <main+0x80>
lea    0xe1e(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%r14d
jmp    1220 <main+0xc0>
lea    0xdf6(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    %r14d,%eax
add    $0x70,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"\0AProvide the html source file\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"<>\00"
@.str.3 = [20 x i8] c"\0ANo of tokens : %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [100 x i8]
%8 = alloca i8*
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32* null, i32** %6
store i8* null, i8** %8
store i32 0, i32* %9
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 2
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %44
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32* @fopen(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %18, i32** %6
%19 = load i32*, i32** %6
%20 = icmp eq i32* null, %19
br i1 %20, label %21, label %22
21: ; preds = %14
store i32 -1, i32* %3
br label %44
22: ; preds = %14
br label %23
23: ; preds = %38, %22
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%25 = load i32*, i32** %6
%26 = call i32* @fgets(i8* %24, i32 100, i32* %25)
%27 = icmp ne i32* null, %26
br i1 %27, label %28, label %39
28: ; preds = %23
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%30 = call i8* @strtok(i8* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i8* %30, i8** %8
br label %31
31: ; preds = %34, %28
%32 = load i8*, i8** %8
%33 = icmp ne i8* null, %32
br i1 %33, label %34, label %38
34: ; preds = %31
%35 = load i32, i32* %9
%36 = add nsw i32 %35, 1
store i32 %36, i32* %9
%37 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i8* %37, i8** %8
br label %31
38: ; preds = %31
br label %23
39: ; preds = %23
%40 = load i32, i32* %9
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 %40)
%42 = load i32*, i32** %6
%43 = call i32 @fclose(i32* %42)
store i32 0, i32* %3
br label %44
44: ; preds = %39, %21, %12
%45 = load i32, i32* %3
ret i32 %45
}

LLVM IR (-O2):
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"<>\00"
@.str.3 = [20 x i8] c"\0ANo of tokens : %d\0A\00"
@str = [30 x i8] c"\0AProvide the html source file\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 2
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
br label %33
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %33, label %13
13: ; preds = %8
%14 = call i32* @fgets(i8* %4, i32 100, i32* %11)
%15 = icmp eq i32* %14, null
br i1 %15, label %29, label %20
16: ; preds = %24, %20
%17 = phi i32 [ %21, %20 ], [ %26, %24 ]
%18 = call i32* @fgets(i8* %4, i32 100, i32* %11)
%19 = icmp eq i32* %18, null
br i1 %19, label %29, label %20
20: ; preds = %13, %16
%21 = phi i32 [ %17, %16 ], [ 0, %13 ]
%22 = call i8* @strtok(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%23 = icmp eq i8* %22, null
br i1 %23, label %16, label %24
24: ; preds = %20, %24
%25 = phi i32 [ %26, %24 ], [ %21, %20 ]
%26 = add nsw i32 %25, 1
%27 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%28 = icmp eq i8* %27, null
br i1 %28, label %16, label %24
29: ; preds = %16, %13
%30 = phi i32 [ 0, %13 ], [ %17, %16 ]
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 %30)
%32 = call i32 @fclose(i32* %11)
br label %33
33: ; preds = %8, %29, %6
%34 = phi i32 [ -1, %6 ], [ 0, %29 ], [ -1, %8 ]
ret i32 %34
}