#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*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
char *mystrtok(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int str_funcs(char *, char *);
int main(int argc, char *argv[]) {
  char line[1024];
  char *count, *func;
  int i, j = 1;
  if (argc == 2) {
    FILE *fh = fopen("-h.txt", "r");
    if (fh == NULL)
      printf("File error.\n");
    while (fgets(line, 1024, fh))
      printf("%s", line);
    fclose(fh);
    return 0;
  }
  FILE *fp = fopen("Test.txt", "r");
  if (fp == NULL)
    printf("File error.\n");
  while (fgets(line, 1024, fp)) {
    printf("%d) %s", j, line);
    j++;
    count = mystrtok(line, " \t");
    func = mystrtok(NULL, " \t");
    i = str_funcs(func, line);
    if (i == 1)
      printf("%s has SUCCEEDED.\n\n", count);
    else if (i == 0)
      printf("%s has FAILED.\n\n", count);
    else
      printf("\n");
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x428(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    121c <main+0xbc>
lea    0xe6c(%rip),%rdi
lea    0xe6c(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x430(%rbp)
cmpq   $0x0,-0x430(%rbp)
jne    11c3 <main+0x63>
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11c8 <main+0x68>
lea    -0x410(%rbp),%rdi
mov    -0x430(%rbp),%rdx
mov    $0x400,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     1204 <main+0xa4>
lea    -0x410(%rbp),%rsi
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11c8 <main+0x68>
mov    -0x430(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
jmp    1366 <main+0x206>
lea    0xdf3(%rip),%rdi
lea    0xddd(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x438(%rbp)
cmpq   $0x0,-0x438(%rbp)
jne    1252 <main+0xf2>
lea    0xdbe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1257 <main+0xf7>
lea    -0x410(%rbp),%rdi
mov    -0x438(%rbp),%rdx
mov    $0x400,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     1353 <main+0x1f3>
mov    -0x428(%rbp),%esi
lea    -0x410(%rbp),%rdx
lea    0xd92(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x428(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x428(%rbp)
lea    -0x410(%rbp),%rdi
lea    0xd75(%rip),%rsi
call   1070 <mystrtok@plt>
mov    %rax,-0x418(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xd5e(%rip),%rsi
call   1070 <mystrtok@plt>
mov    %rax,-0x420(%rbp)
mov    -0x420(%rbp),%rdi
lea    -0x410(%rbp),%rsi
call   1050 <str_funcs@plt>
mov    %eax,-0x424(%rbp)
cmpl   $0x1,-0x424(%rbp)
jne    1314 <main+0x1b4>
mov    -0x418(%rbp),%rsi
lea    0xd21(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    134e <main+0x1ee>
cmpl   $0x0,-0x424(%rbp)
jne    133b <main+0x1db>
mov    -0x418(%rbp),%rsi
lea    0xd0e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1349 <main+0x1e9>
lea    0xcf9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    134e <main+0x1ee>
jmp    1257 <main+0xf7>
mov    -0x438(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
cmp    $0x2,%edi
jne    1207 <main+0x87>
lea    0xe63(%rip),%rdi
lea    0xe63(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%r15
test   %rax,%rax
jne    11bd <main+0x3d>
lea    0xe89(%rip),%rdi
call   1040 <puts@plt>
mov    %rsp,%rdi
mov    $0x400,%esi
mov    %r15,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     12e3 <main+0x163>
lea    0xe39(%rip),%rbx
mov    %rsp,%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbp,%rdi
mov    $0x400,%esi
mov    %r15,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
jne    11e0 <main+0x60>
jmp    12e3 <main+0x163>
lea    0xdfb(%rip),%rdi
lea    0xdf2(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%r15
test   %rax,%rax
jne    122e <main+0xae>
lea    0xe18(%rip),%rdi
call   1040 <puts@plt>
mov    %rsp,%rdi
mov    $0x400,%esi
mov    %r15,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     12e3 <main+0x163>
mov    $0x1,%ebp
lea    0xdbf(%rip),%r14
mov    %rsp,%rbx
lea    0xdbc(%rip),%r12
jmp    1282 <main+0x102>
nop
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %r15,%rdx
call   1080 <fgets@plt>
add    $0x1,%ebp
test   %rax,%rax
je     12e3 <main+0x163>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1090 <mystrtok@plt>
mov    %rax,%r13
xor    %edi,%edi
mov    %r12,%rsi
call   1090 <mystrtok@plt>
mov    %rax,%rdi
mov    %rbx,%rsi
call   1070 <str_funcs@plt>
test   %eax,%eax
je     12d0 <main+0x150>
cmp    $0x1,%eax
jne    1260 <main+0xe0>
lea    0xd58(%rip),%rdi
jmp    12d7 <main+0x157>
cs nopw 0x0(%rax,%rax,1)
lea    0xd59(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    126a <main+0xea>
mov    %r15,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"-h.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [13 x i8] c"File error.\0A\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [9 x i8] c"Test.txt\00"
@.str.5 = [7 x i8] c"%d) %s\00"
@.str.6 = [3 x i8] c" \09\00"
@.str.7 = [20 x i8] c"%s has SUCCEEDED.\0A\0A\00"
@.str.8 = [17 x i8] c"%s has FAILED.\0A\0A\00"
@.str.9 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1024 x i8]
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32*
%12 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %10
%13 = load i32, i32* %4
%14 = icmp eq i32 %13, 2
br i1 %14, label %15, label %33
15: ; preds = %2
%16 = 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* %16, i32** %11
%17 = load i32*, i32** %11
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %21
21: ; preds = %19, %15
br label %22
22: ; preds = %27, %21
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%24 = load i32*, i32** %11
%25 = call i64 @fgets(i8* %23, i32 1024, i32* %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %22
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %28)
br label %22
30: ; preds = %22
%31 = load i32*, i32** %11
%32 = call i32 @fclose(i32* %31)
store i32 0, i32* %3
br label %75
33: ; preds = %2
%34 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %34, i32** %12
%35 = load i32*, i32** %12
%36 = icmp eq i32* %35, null
br i1 %36, label %37, label %39
37: ; preds = %33
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %39
39: ; preds = %37, %33
br label %40
40: ; preds = %71, %39
%41 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%42 = load i32*, i32** %12
%43 = call i64 @fgets(i8* %41, i32 1024, i32* %42)
%44 = icmp ne i64 %43, 0
br i1 %44, label %45, label %72
45: ; preds = %40
%46 = load i32, i32* %10
%47 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 %46, i8* %47)
%49 = load i32, i32* %10
%50 = add nsw i32 %49, 1
store i32 %50, i32* %10
%51 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%52 = call i8* @mystrtok(i8* %51, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
store i8* %52, i8** %7
%53 = call i8* @mystrtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
store i8* %53, i8** %8
%54 = load i8*, i8** %8
%55 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%56 = call i32 @str_funcs(i8* %54, i8* %55)
store i32 %56, i32* %9
%57 = load i32, i32* %9
%58 = icmp eq i32 %57, 1
br i1 %58, label %59, label %62
59: ; preds = %45
%60 = load i8*, i8** %7
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), i8* %60)
br label %71
62: ; preds = %45
%63 = load i32, i32* %9
%64 = icmp eq i32 %63, 0
br i1 %64, label %65, label %68
65: ; preds = %62
%66 = load i8*, i8** %7
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), i8* %66)
br label %70
68: ; preds = %62
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
br label %70
70: ; preds = %68, %65
br label %71
71: ; preds = %70, %59
br label %40
72: ; preds = %40
%73 = load i32*, i32** %12
%74 = call i32 @fclose(i32* %73)
store i32 0, i32* %3
br label %75
75: ; preds = %72, %30
%76 = load i32, i32* %3
ret i32 %76
}

LLVM IR (-O2):
@.str = [7 x i8] c"-h.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [9 x i8] c"Test.txt\00"
@.str.5 = [7 x i8] c"%d) %s\00"
@.str.6 = [3 x i8] c" \09\00"
@.str.7 = [20 x i8] c"%s has SUCCEEDED.\0A\0A\00"
@.str.8 = [17 x i8] c"%s has FAILED.\0A\0A\00"
@str.10 = [12 x i8] c"File error.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 2
br i1 %5, label %6, label %18
6: ; preds = %2
%7 = 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))
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.10, i64 0, i64 0))
br label %11
11: ; preds = %9, %6
%12 = call i64 @fgets(i8* %4, i32 1024, i32* %7)
%13 = icmp eq i64 %12, 0
br i1 %13, label %42, label %14
14: ; preds = %11, %14
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%16 = call i64 @fgets(i8* %4, i32 1024, i32* %7)
%17 = icmp eq i64 %16, 0
br i1 %17, label %42, label %14
18: ; preds = %2
%19 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.10, i64 0, i64 0))
br label %23
23: ; preds = %21, %18
%24 = call i64 @fgets(i8* %4, i32 1024, i32* %19)
%25 = icmp eq i64 %24, 0
br i1 %25, label %42, label %26
26: ; preds = %23, %39
%27 = phi i32 [ %29, %39 ], [ 1, %23 ]
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 %27, i8* %4)
%29 = add nuw nsw i32 %27, 1
%30 = call i8* @mystrtok(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%31 = call i8* @mystrtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%32 = call i32 @str_funcs(i8* %31, i8* %4)
switch i32 %32, label %37 [
i32 1, label %33
i32 0, label %35
]
33: ; preds = %26
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), i8* %30)
br label %39
35: ; preds = %26
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), i8* %30)
br label %39
37: ; preds = %26
%38 = call i32 @putchar(i32 10)
br label %39
39: ; preds = %35, %37, %33
%40 = call i64 @fgets(i8* %4, i32 1024, i32* %19)
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %26
42: ; preds = %39, %14, %23, %11
%43 = phi i32* [ %7, %11 ], [ %19, %23 ], [ %7, %14 ], [ %19, %39 ]
%44 = call i32 @fclose(i32* %43)
ret i32 0
}