#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*/ get_line(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ put_line_strip(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ put_line_strip_check(char *, int /*<<< orphan*/ *);
scalar_t__ seetex_begin(char *);
scalar_t__ seetex_end(char *);
int seetex_process(FILE *srcid, FILE *texid) {
  char line[132];
  char *pline = (char *)NULL;
  int eof_found = 0;
  int in_seetex_block = 0;
  int line_count = 0;
  pline = &line[0];
  while (!eof_found) {
    if (0 >= 10)
      (void)printf("seetex_process:<%d>\n", line_count);
    eof_found = !get_line(srcid, line, 132);
    if (0 >= 10)
      (void)printf("seetex_process:<%s>\n", pline);
    if (eof_found) {
      if (0 >= 10)
        (void)printf("EOF found\n");
      break;
    }
    line_count++;
    if (0 >= 10)
      (void)printf("seetex_process: read line %d \n", line_count);
    if (seetex_end(pline))
      if (in_seetex_block > 0)
        in_seetex_block--;
      else {
        (void)printf("Found *:tex-{\\}end when not in a tex block\n");
        return 0;
      }
    if (seetex_begin(pline))
      in_seetex_block++;
    if (in_seetex_block)
      (void)put_line_strip(pline, texid);
    else
      (void)put_line_strip_check(pline, texid);
  }
  if (in_seetex_block == 0)
    return 1;
  else {
    (void)printf("EOF found but still in tex block\n");
    return 0;
  }
}


x86 assembly (clang, -O0):
<seetex_process>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0xa8(%rbp)
movl   $0x0,-0xac(%rbp)
movl   $0x0,-0xb0(%rbp)
movl   $0x0,-0xb4(%rbp)
lea    -0xa0(%rbp),%rax
mov    %rax,-0xa8(%rbp)
cmpl   $0x0,-0xac(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11c3 <seetex_process+0x63>
jmp    12be <seetex_process+0x15e>
mov    -0x10(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
mov    $0x84,%edx
call   1030 <get_line@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0xac(%rbp)
cmpl   $0x0,-0xac(%rbp)
je     11fd <seetex_process+0x9d>
jmp    12be <seetex_process+0x15e>
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
mov    -0xa8(%rbp),%rdi
call   1050 <seetex_end@plt>
cmp    $0x0,%rax
je     1262 <seetex_process+0x102>
cmpl   $0x0,-0xb0(%rbp)
jle    1243 <seetex_process+0xe3>
mov    -0xb0(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xb0(%rbp)
jmp    125d <seetex_process+0xfd>
lea    0xdb6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12ec <seetex_process+0x18c>
jmp    1262 <seetex_process+0x102>
mov    -0xa8(%rbp),%rdi
call   1060 <seetex_begin@plt>
cmp    $0x0,%rax
je     1287 <seetex_process+0x127>
mov    -0xb0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb0(%rbp)
cmpl   $0x0,-0xb0(%rbp)
je     12a9 <seetex_process+0x149>
mov    -0xa8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1080 <put_line_strip@plt>
jmp    12b9 <seetex_process+0x159>
mov    -0xa8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <put_line_strip_check@plt>
jmp    11aa <seetex_process+0x4a>
cmpl   $0x0,-0xb0(%rbp)
jne    12d7 <seetex_process+0x177>
movl   $0x1,-0x4(%rbp)
jmp    12ec <seetex_process+0x18c>
lea    0xd4e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<seetex_process>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsp,%rsi
mov    $0x84,%edx
call   1040 <get_line@plt>
mov    $0x1,%r12d
test   %eax,%eax
je     1226 <seetex_process+0xc6>
xor    %r13d,%r13d
mov    %rsp,%rbp
jmp    11bf <seetex_process+0x5f>
nopw   0x0(%rax,%rax,1)
call   1070 <put_line_strip_check@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    $0x84,%edx
call   1040 <get_line@plt>
mov    $0x0,%r13d
test   %eax,%eax
je     1226 <seetex_process+0xc6>
mov    %rbp,%rdi
call   1050 <seetex_end@plt>
test   %rax,%rax
je     11d5 <seetex_process+0x75>
test   %r13d,%r13d
jle    1217 <seetex_process+0xb7>
add    $0xffffffff,%r13d
mov    %r13d,%r15d
mov    %rbp,%rdi
call   1060 <seetex_begin@plt>
xor    %r13d,%r13d
test   %rax,%rax
setne  %r13b
mov    %rbp,%rdi
mov    %r14,%rsi
add    %r15d,%r13d
je     11a0 <seetex_process+0x40>
call   1080 <put_line_strip@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    $0x84,%edx
call   1040 <get_line@plt>
test   %eax,%eax
jne    11bf <seetex_process+0x5f>
lea    0xdeb(%rip),%rdi
jmp    121e <seetex_process+0xbe>
lea    0xe03(%rip),%rdi
call   1030 <puts@plt>
xor    %r12d,%r12d
mov    %r12d,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [44 x i8] c"Found *:tex-{\\}end when not in a tex block\0A\00"
@.str.1 = [34 x i8] c"EOF found but still in tex block\0A\00"
define i32 @seetex_process(i32* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca [132 x i8]
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
store i8* null, i8** %7
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
%11 = getelementptr inbounds [132 x i8], [132 x i8]* %6, i64 0, i64 0
store i8* %11, i8** %7
br label %12
12: ; preds = %59, %2
%13 = load i32, i32* %8
%14 = icmp ne i32 %13, 0
%15 = xor i1 %14, true
br i1 %15, label %16, label %60
16: ; preds = %12
%17 = load i32*, i32** %4
%18 = getelementptr inbounds [132 x i8], [132 x i8]* %6, i64 0, i64 0
%19 = call i32 @get_line(i32* %17, i8* %18, i32 132)
%20 = icmp ne i32 %19, 0
%21 = xor i1 %20, true
%22 = zext i1 %21 to i32
store i32 %22, i32* %8
%23 = load i32, i32* %8
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %16
br label %60
26: ; preds = %16
%27 = load i32, i32* %10
%28 = add nsw i32 %27, 1
store i32 %28, i32* %10
%29 = load i8*, i8** %7
%30 = call i64 @seetex_end(i8* %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %41
32: ; preds = %26
%33 = load i32, i32* %9
%34 = icmp sgt i32 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %32
%36 = load i32, i32* %9
%37 = add nsw i32 %36, -1
store i32 %37, i32* %9
br label %40
38: ; preds = %32
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %66
40: ; preds = %35
br label %41
41: ; preds = %40, %26
%42 = load i8*, i8** %7
%43 = call i64 @seetex_begin(i8* %42)
%44 = icmp ne i64 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %41
%46 = load i32, i32* %9
%47 = add nsw i32 %46, 1
store i32 %47, i32* %9
br label %48
48: ; preds = %45, %41
%49 = load i32, i32* %9
%50 = icmp ne i32 %49, 0
br i1 %50, label %51, label %55
51: ; preds = %48
%52 = load i8*, i8** %7
%53 = load i32*, i32** %5
%54 = call i32 @put_line_strip(i8* %52, i32* %53)
br label %59
55: ; preds = %48
%56 = load i8*, i8** %7
%57 = load i32*, i32** %5
%58 = call i32 @put_line_strip_check(i8* %56, i32* %57)
br label %59
59: ; preds = %55, %51
br label %12
60: ; preds = %25, %12
%61 = load i32, i32* %9
%62 = icmp eq i32 %61, 0
br i1 %62, label %63, label %64
63: ; preds = %60
store i32 1, i32* %3
br label %66
64: ; preds = %60
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %66
66: ; preds = %64, %63, %38
%67 = load i32, i32* %3
ret i32 %67
}

LLVM IR (-O2):
@str = [33 x i8] c"EOF found but still in tex block\00"
@str.2 = [43 x i8] c"Found *:tex-{\\}end when not in a tex block\00"
define i32 @seetex_process(i32* %0, i32* %1) {
%3 = alloca [132 x i8]
%4 = getelementptr inbounds [132 x i8], [132 x i8]* %3, i64 0, i64 0
%5 = call i32 @get_line(i32* %0, i8* %4, i32 132)
%6 = icmp eq i32 %5, 0
br i1 %6, label %35, label %7
7: ; preds = %2, %26
%8 = phi i32 [ %27, %26 ], [ 0, %2 ]
%9 = call i64 @seetex_end(i8* %4)
%10 = icmp eq i64 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %7
%12 = icmp sgt i32 %8, 0
br i1 %12, label %13, label %32
13: ; preds = %11
%14 = add nsw i32 %8, -1
br label %15
15: ; preds = %13, %7
%16 = phi i32 [ %14, %13 ], [ %8, %7 ]
%17 = call i64 @seetex_begin(i8* %4)
%18 = icmp ne i64 %17, 0
%19 = zext i1 %18 to i32
%20 = add nsw i32 %16, %19
%21 = icmp eq i32 %20, 0
br i1 %21, label %28, label %22
22: ; preds = %15
%23 = call i32 @put_line_strip(i8* %4, i32* %1)
%24 = call i32 @get_line(i32* %0, i8* %4, i32 132)
%25 = icmp eq i32 %24, 0
br i1 %25, label %32, label %26
26: ; preds = %22, %28
%27 = phi i32 [ %20, %22 ], [ 0, %28 ]
br label %7
28: ; preds = %15
%29 = call i32 @put_line_strip_check(i8* %4, i32* %1)
%30 = call i32 @get_line(i32* %0, i8* %4, i32 132)
%31 = icmp eq i32 %30, 0
br i1 %31, label %35, label %26
32: ; preds = %22, %11
%33 = phi i8* [ getelementptr inbounds ([43 x i8], [43 x i8]* @str.2, i64 0, i64 0), %11 ], [ getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0), %22 ]
%34 = call i32 @puts(i8* dereferenceable(1) %33)
br label %35
35: ; preds = %28, %32, %2
%36 = phi i32 [ 1, %2 ], [ 0, %32 ], [ 1, %28 ]
ret i32 %36
}