#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*/ line;
typedef int /*<<< orphan*/ buf;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ EOF;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int /*<<< orphan*/ stderr;
scalar_t__ strchr(char *, char);
char *strerror(int /*<<< orphan*/);
scalar_t__ strstr(char *, char *);
int test_result_analysis(void) {
  FILE *fp = fopen("test.tmp", "r");
  char line[1024];
  int counter = 0;
  if (!fp)
    do {
      char buf[1024];
      snprintf(buf, sizeof(buf), "open %s for analysis", "test.tmp");
      fprintf(stderr, "%s: %s\n", buf, strerror(errno));
      exit(EXIT_FAILURE);
    } while (0);
  while (fgets(line, sizeof(line), fp)) {
    if (strstr(line, "#TSTP##CONT#"))
      counter++;
    else if (strchr(line, '#'))
      printf("MISMATCH: %s", line);
  }
  if (!feof(fp))
    do {
      char buf[1024];
      snprintf(buf, sizeof(buf), "read from the %s", "test.tmp");
      fprintf(stderr, "%s: %s\n", buf, strerror(errno));
    } while (0);
  if (fclose(fp) == EOF)
    do {
      char buf[1024];
      snprintf(buf, sizeof(buf), "close file %s", "test.tmp");
      fprintf(stderr, "%s: %s\n", buf, strerror(errno));
    } while (0);
  return counter;
}


x86 assembly (clang, -O0):
<test_result_analysis>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1050,%rsp
lea    0xe3e(%rip),%rdi
lea    0xe40(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x8(%rbp)
movl   $0x0,-0x414(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1260 <test_result_analysis+0xb0>
jmp    11ec <test_result_analysis+0x3c>
lea    -0x820(%rbp),%rdi
mov    $0x400,%esi
lea    0xe0c(%rip),%rdx
lea    0xdfa(%rip),%rcx
call   1060 <snprintf@plt>
mov    0x2dc6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x102c(%rbp)
lea    -0x820(%rbp),%rax
mov    %rax,-0x1028(%rbp)
mov    0x2da1(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    -0x102c(%rbp),%edi
mov    -0x1028(%rbp),%rdx
mov    %rax,%rcx
lea    0xdd3(%rip),%rsi
call   1080 <fprintf@plt>
mov    0x2d6f(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
jmp    1265 <test_result_analysis+0xb5>
lea    -0x410(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x400,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     12ed <test_result_analysis+0x13d>
lea    -0x410(%rbp),%rdi
lea    0xd96(%rip),%rsi
call   10d0 <strstr@plt>
cmp    $0x0,%rax
je     12b5 <test_result_analysis+0x105>
mov    -0x414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x414(%rbp)
jmp    12e8 <test_result_analysis+0x138>
lea    -0x410(%rbp),%rdi
mov    $0x23,%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
je     12e3 <test_result_analysis+0x133>
lea    -0x410(%rbp),%rsi
lea    0xd57(%rip),%rdi
call   1050 <printf@plt>
jmp    12e8 <test_result_analysis+0x138>
jmp    1265 <test_result_analysis+0xb5>
mov    -0x8(%rbp),%rdi
call   1090 <feof@plt>
cmp    $0x0,%eax
jne    136f <test_result_analysis+0x1bf>
jmp    1304 <test_result_analysis+0x154>
lea    -0xc20(%rbp),%rdi
mov    $0x400,%esi
lea    0xd2b(%rip),%rdx
lea    0xce2(%rip),%rcx
call   1060 <snprintf@plt>
mov    0x2cae(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x103c(%rbp)
lea    -0xc20(%rbp),%rax
mov    %rax,-0x1038(%rbp)
mov    0x2c89(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    -0x103c(%rbp),%edi
mov    -0x1038(%rbp),%rdx
mov    %rax,%rcx
lea    0xcbb(%rip),%rsi
call   1080 <fprintf@plt>
jmp    136f <test_result_analysis+0x1bf>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
mov    0x2c69(%rip),%rcx
cmp    (%rcx),%rax
jne    13f8 <test_result_analysis+0x248>
jmp    138d <test_result_analysis+0x1dd>
lea    -0x1020(%rbp),%rdi
mov    $0x400,%esi
lea    0xcb3(%rip),%rdx
lea    0xc59(%rip),%rcx
call   1060 <snprintf@plt>
mov    0x2c25(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x104c(%rbp)
lea    -0x1020(%rbp),%rax
mov    %rax,-0x1048(%rbp)
mov    0x2c00(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    -0x104c(%rbp),%edi
mov    -0x1048(%rbp),%rdx
mov    %rax,%rcx
lea    0xc32(%rip),%rsi
call   1080 <fprintf@plt>
jmp    13f8 <test_result_analysis+0x248>
mov    -0x414(%rbp),%eax
add    $0x1050,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_result_analysis>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x800,%rsp
lea    0xe3a(%rip),%rdi
lea    0xe3c(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1327 <test_result_analysis+0x177>
mov    %rax,%rbx
mov    %rsp,%rdi
mov    $0x400,%esi
mov    %rax,%rdx
call   1070 <fgets@plt>
xor    %r15d,%r15d
test   %rax,%rax
je     1258 <test_result_analysis+0xa8>
lea    0xe2b(%rip),%r14
mov    %rsp,%rbp
lea    0xe2e(%rip),%r12
jmp    1229 <test_result_analysis+0x79>
nopl   0x0(%rax)
add    $0x1,%r15d
mov    %rbp,%rdi
mov    $0x400,%esi
mov    %rbx,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     1258 <test_result_analysis+0xa8>
mov    %rbp,%rdi
mov    %r14,%rsi
call   10d0 <strstr@plt>
test   %rax,%rax
jne    1210 <test_result_analysis+0x60>
mov    %rbp,%rdi
mov    $0x23,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1214 <test_result_analysis+0x64>
mov    %r12,%rdi
mov    %rbp,%rsi
call   1050 <printf@plt>
jmp    1214 <test_result_analysis+0x64>
mov    %rbx,%rdi
call   1090 <feof@plt>
test   %eax,%eax
jne    12b2 <test_result_analysis+0x102>
lea    0xdd7(%rip),%rdx
lea    0xd8e(%rip),%rcx
lea    0x400(%rsp),%r14
mov    %r14,%rdi
mov    $0x400,%esi
call   1060 <snprintf@plt>
mov    0x2d4a(%rip),%rax
mov    (%rax),%ebp
mov    0x2d39(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
lea    0xd7b(%rip),%rsi
mov    %ebp,%edi
mov    %r14,%rdx
mov    %rax,%rcx
call   1080 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    0x2d27(%rip),%rcx
cmp    (%rcx),%rax
jne    1314 <test_result_analysis+0x164>
lea    0xd86(%rip),%rdx
lea    0xd2c(%rip),%rcx
lea    0x400(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x400,%esi
call   1060 <snprintf@plt>
mov    0x2ce8(%rip),%rax
mov    (%rax),%ebp
mov    0x2cd7(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
lea    0xd19(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
call   1080 <fprintf@plt>
mov    %r15d,%eax
add    $0x800,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xcdd(%rip),%rdx
lea    0xccb(%rip),%rcx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x400,%esi
call   1060 <snprintf@plt>
mov    0x2c8c(%rip),%rax
mov    (%rax),%ebp
mov    0x2c7b(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
lea    0xcbd(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
call   1080 <fprintf@plt>
mov    0x2c51(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"test.tmp\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [21 x i8] c"open %s for analysis\00"
@stderr = global i32 0
@.str.3 = [8 x i8] c"%s: %s\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@.str.4 = [13 x i8] c"#TSTP##CONT#\00"
@.str.5 = [13 x i8] c"MISMATCH: %s\00"
@.str.6 = [17 x i8] c"read from the %s\00"
@EOF = global i64 0
@.str.7 = [14 x i8] c"close file %s\00"
define i32 @test_result_analysis() {
%1 = alloca i32*
%2 = alloca [1024 x i8]
%3 = alloca i32
%4 = alloca [1024 x i8]
%5 = alloca [1024 x i8]
%6 = alloca [1024 x i8]
%7 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %1
store i32 0, i32* %3
%8 = load i32*, i32** %1
%9 = icmp ne i32* %8, null
br i1 %9, label %22, label %10
10: ; preds = %0
br label %11
11: ; preds = %10
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%13 = call i32 @snprintf(i8* %12, i32 1024, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%14 = load i32, i32* @stderr
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%16 = load i32, i32* @errno
%17 = call i8* @strerror(i32 %16)
%18 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %15, i8* %17)
%19 = load i32, i32* @EXIT_FAILURE
%20 = call i32 @exit(i32 %19)
unreachable
21: ; No predecessors!
br label %22
22: ; preds = %21, %0
br label %23
23: ; preds = %43, %22
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%25 = load i32*, i32** %1
%26 = call i64 @fgets(i8* %24, i32 1024, i32* %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %44
28: ; preds = %23
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%30 = call i64 @strstr(i8* %29, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %28
%33 = load i32, i32* %3
%34 = add nsw i32 %33, 1
store i32 %34, i32* %3
br label %43
35: ; preds = %28
%36 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%37 = call i64 @strchr(i8* %36, i8 signext 35)
%38 = icmp ne i64 %37, 0
br i1 %38, label %39, label %42
39: ; preds = %35
%40 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%41 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* %40)
br label %42
42: ; preds = %39, %35
br label %43
43: ; preds = %42, %32
br label %23
44: ; preds = %23
%45 = load i32*, i32** %1
%46 = call i32 @feof(i32* %45)
%47 = icmp ne i32 %46, 0
br i1 %47, label %58, label %48
48: ; preds = %44
br label %49
49: ; preds = %48
%50 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%51 = call i32 @snprintf(i8* %50, i32 1024, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%52 = load i32, i32* @stderr
%53 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%54 = load i32, i32* @errno
%55 = call i8* @strerror(i32 %54)
%56 = call i32 @fprintf(i32 %52, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %53, i8* %55)
br label %57
57: ; preds = %49
br label %58
58: ; preds = %57, %44
%59 = load i32*, i32** %1
%60 = call i64 @fclose(i32* %59)
%61 = load i64, i64* @EOF
%62 = icmp eq i64 %60, %61
br i1 %62, label %63, label %73
63: ; preds = %58
br label %64
64: ; preds = %63
%65 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%66 = call i32 @snprintf(i8* %65, i32 1024, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%67 = load i32, i32* @stderr
%68 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%69 = load i32, i32* @errno
%70 = call i8* @strerror(i32 %69)
%71 = call i32 @fprintf(i32 %67, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %68, i8* %70)
br label %72
72: ; preds = %64
br label %73
73: ; preds = %72, %58
%74 = load i32, i32* %3
ret i32 %74
}

LLVM IR (-O2):
@.str = [9 x i8] c"test.tmp\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [21 x i8] c"open %s for analysis\00"
@stderr = global i32 0
@.str.3 = [8 x i8] c"%s: %s\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@.str.4 = [13 x i8] c"#TSTP##CONT#\00"
@.str.5 = [13 x i8] c"MISMATCH: %s\00"
@.str.6 = [17 x i8] c"read from the %s\00"
@EOF = global i64 0
@.str.7 = [14 x i8] c"close file %s\00"
define i32 @test_result_analysis() {
%1 = alloca [1024 x i8]
%2 = alloca [1024 x i8]
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%7 = icmp eq i32* %5, null
br i1 %7, label %11, label %8
8: ; preds = %0
%9 = call i64 @fgets(i8* %6, i32 1024, i32* %5)
%10 = icmp eq i64 %9, 0
br i1 %10, label %35, label %20
11: ; preds = %0
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%13 = call i32 @snprintf(i8* %12, i32 1024, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%14 = load i32, i32* @stderr
%15 = load i32, i32* @errno
%16 = call i8* @strerror(i32 %15)
%17 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %12, i8* %16)
%18 = load i32, i32* @EXIT_FAILURE
%19 = call i32 @exit(i32 %18)
unreachable
20: ; preds = %8, %31
%21 = phi i32 [ %32, %31 ], [ 0, %8 ]
%22 = call i64 @strstr(i8* %6, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %26, label %24
24: ; preds = %20
%25 = add nsw i32 %21, 1
br label %31
26: ; preds = %20
%27 = call i64 @strchr(i8* %6, i8 signext 35)
%28 = icmp eq i64 %27, 0
br i1 %28, label %31, label %29
29: ; preds = %26
%30 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* %6)
br label %31
31: ; preds = %26, %29, %24
%32 = phi i32 [ %25, %24 ], [ %21, %29 ], [ %21, %26 ]
%33 = call i64 @fgets(i8* %6, i32 1024, i32* %5)
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %20
35: ; preds = %31, %8
%36 = phi i32 [ 0, %8 ], [ %32, %31 ]
%37 = call i32 @feof(i32* %5)
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %46
39: ; preds = %35
%40 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%41 = call i32 @snprintf(i8* %40, i32 1024, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%42 = load i32, i32* @stderr
%43 = load i32, i32* @errno
%44 = call i8* @strerror(i32 %43)
%45 = call i32 @fprintf(i32 %42, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %40, i8* %44)
br label %46
46: ; preds = %39, %35
%47 = call i64 @fclose(i32* %5)
%48 = load i64, i64* @EOF
%49 = icmp eq i64 %47, %48
br i1 %49, label %50, label %57
50: ; preds = %46
%51 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%52 = call i32 @snprintf(i8* %51, i32 1024, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%53 = load i32, i32* @stderr
%54 = load i32, i32* @errno
%55 = call i8* @strerror(i32 %54)
%56 = call i32 @fprintf(i32 %53, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %51, i8* %55)
br label %57
57: ; preds = %50, %46
ret i32 %36
}