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

/* Variables and functions */
int /*<<< orphan*/ fgetpos(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int fscanf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ fsetpos(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
int sscanf(char *, char *, char *);
scalar_t__ strcmp(char *, char *);
FILE *find_TS(FILE *fpin, char seek_step[20]) {
  int i;
  char inStr[255], cur_step[20], dummy[80];
  fpos_t the_pos;
  fgetpos(fpin, &the_pos);
  do {
    fsetpos(fpin, &the_pos);
    for (i = 1; i <= 5; i++)
      if (fgets(inStr, 255, fpin) == NULL)
        goto err;
    if (fscanf(fpin, "PPF subfile %s", cur_step) != 1)
      goto err;
    if (strcmp(seek_step, cur_step) != 0) {
      do {
        fgetpos(fpin, &the_pos);
        if (fgets(inStr, 255, fpin) == NULL)
          goto err;
      } while (sscanf(inStr, "TITLE(1) %s", dummy) != 1);
    }
  } while (strcmp(seek_step, cur_step) != 0);
  fsetpos(fpin, &the_pos);
  return fpin;
err:
  printf("error finding tstep [%s]\n", seek_step);
  return NULL;
}


x86 assembly (clang, -O0):
<find_TS>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1a0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x194(%rbp),%rsi
call   1040 <fgetpos@plt>
mov    -0x10(%rbp),%rdi
lea    -0x194(%rbp),%rsi
call   1090 <fsetpos@plt>
movl   $0x1,-0x1c(%rbp)
cmpl   $0x5,-0x1c(%rbp)
jg     11eb <find_TS+0x7b>
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0xff,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
jne    11d8 <find_TS+0x68>
jmp    12cc <find_TS+0x15c>
jmp    11dd <find_TS+0x6d>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11aa <find_TS+0x3a>
mov    -0x10(%rbp),%rdi
lea    -0x140(%rbp),%rdx
lea    0xe03(%rip),%rsi
call   1050 <fscanf@plt>
cmp    $0x1,%eax
je     1210 <find_TS+0xa0>
jmp    12cc <find_TS+0x15c>
mov    -0x18(%rbp),%rdi
lea    -0x140(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     1290 <find_TS+0x120>
jmp    122f <find_TS+0xbf>
mov    -0x10(%rbp),%rdi
lea    -0x194(%rbp),%rsi
call   1040 <fgetpos@plt>
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0xff,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
jne    1263 <find_TS+0xf3>
jmp    12cc <find_TS+0x15c>
jmp    1268 <find_TS+0xf8>
lea    -0x120(%rbp),%rdi
lea    -0x190(%rbp),%rdx
lea    0xd92(%rip),%rsi
call   1080 <sscanf@plt>
cmp    $0x1,%eax
jne    122f <find_TS+0xbf>
jmp    1290 <find_TS+0x120>
jmp    1295 <find_TS+0x125>
mov    -0x18(%rbp),%rdi
lea    -0x140(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1193 <find_TS+0x23>
mov    -0x10(%rbp),%rdi
lea    -0x194(%rbp),%rsi
call   1090 <fsetpos@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    12e4 <find_TS+0x174>
mov    -0x18(%rbp),%rsi
lea    0xd44(%rip),%rdi
call   1030 <printf@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_TS>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x188,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xc(%rsp),%r15
mov    %r15,%rsi
call   1040 <fgetpos@plt>
lea    0x80(%rsp),%r12
lea    0xe6c(%rip),%r13
lea    0x30(%rsp),%rbp
jmp    11c6 <find_TS+0x56>
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
lea    0x10(%rsp),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     12de <find_TS+0x16e>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1090 <fsetpos@plt>
mov    %r12,%rdi
mov    $0xff,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     12b8 <find_TS+0x148>
mov    %r12,%rdi
mov    $0xff,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     12b8 <find_TS+0x148>
mov    %r12,%rdi
mov    $0xff,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     12b8 <find_TS+0x148>
mov    %r12,%rdi
mov    $0xff,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     12b8 <find_TS+0x148>
mov    %r12,%rdi
mov    $0xff,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     12b8 <find_TS+0x148>
mov    %rbx,%rdi
lea    0xdac(%rip),%rsi
lea    0x10(%rsp),%rdx
call   1050 <fscanf@plt>
cmp    $0x1,%eax
jne    12b8 <find_TS+0x148>
mov    %r14,%rdi
lea    0x10(%rsp),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     11b0 <find_TS+0x40>
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <fgetpos@plt>
mov    %r12,%rdi
mov    $0xff,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     12b8 <find_TS+0x148>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
call   1080 <sscanf@plt>
cmp    $0x1,%eax
jne    1280 <find_TS+0x110>
jmp    11b0 <find_TS+0x40>
lea    0xd5c(%rip),%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x188,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1090 <fsetpos@plt>
jmp    12c9 <find_TS+0x159>

LLVM IR (-O0):
@.str = [15 x i8] c"PPF subfile %s\00"
@.str.1 = [12 x i8] c"TITLE(1) %s\00"
@.str.2 = [26 x i8] c"error finding tstep [%s]\0A\00"
define i32* @find_TS(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca [255 x i8]
%8 = alloca [20 x i8]
%9 = alloca [80 x i8]
%10 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
%11 = load i32*, i32** %4
%12 = call i32 @fgetpos(i32* %11, i32* %10)
br label %13
13: ; preds = %57, %2
%14 = load i32*, i32** %4
%15 = call i32 @fsetpos(i32* %14, i32* %10)
store i32 1, i32* %6
br label %16
16: ; preds = %26, %13
%17 = load i32, i32* %6
%18 = icmp sle i32 %17, 5
br i1 %18, label %19, label %29
19: ; preds = %16
%20 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%21 = load i32*, i32** %4
%22 = call i32* @fgets(i8* %20, i32 255, i32* %21)
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %25
24: ; preds = %19
br label %66
25: ; preds = %19
br label %26
26: ; preds = %25
%27 = load i32, i32* %6
%28 = add nsw i32 %27, 1
store i32 %28, i32* %6
br label %16
29: ; preds = %16
%30 = load i32*, i32** %4
%31 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 0
%32 = call i32 @fscanf(i32* %30, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %31)
%33 = icmp ne i32 %32, 1
br i1 %33, label %34, label %35
34: ; preds = %29
br label %66
35: ; preds = %29
%36 = load i8*, i8** %5
%37 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 0
%38 = call i64 @strcmp(i8* %36, i8* %37)
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %56
40: ; preds = %35
br label %41
41: ; preds = %50, %40
%42 = load i32*, i32** %4
%43 = call i32 @fgetpos(i32* %42, i32* %10)
%44 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%45 = load i32*, i32** %4
%46 = call i32* @fgets(i8* %44, i32 255, i32* %45)
%47 = icmp eq i32* %46, null
br i1 %47, label %48, label %49
48: ; preds = %41
br label %66
49: ; preds = %41
br label %50
50: ; preds = %49
%51 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%52 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%53 = call i32 @sscanf(i8* %51, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %52)
%54 = icmp ne i32 %53, 1
br i1 %54, label %41, label %55
55: ; preds = %50
br label %56
56: ; preds = %55, %35
br label %57
57: ; preds = %56
%58 = load i8*, i8** %5
%59 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 0
%60 = call i64 @strcmp(i8* %58, i8* %59)
%61 = icmp ne i64 %60, 0
br i1 %61, label %13, label %62
62: ; preds = %57
%63 = load i32*, i32** %4
%64 = call i32 @fsetpos(i32* %63, i32* %10)
%65 = load i32*, i32** %4
store i32* %65, i32** %3
br label %69
66: ; preds = %48, %34, %24
%67 = load i8*, i8** %5
%68 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %67)
store i32* null, i32** %3
br label %69
69: ; preds = %66, %62
%70 = load i32*, i32** %3
ret i32* %70
}

LLVM IR (-O2):
@.str = [15 x i8] c"PPF subfile %s\00"
@.str.1 = [12 x i8] c"TITLE(1) %s\00"
@.str.2 = [26 x i8] c"error finding tstep [%s]\0A\00"
define i32* @find_TS(i32* %0, i8* %1) {
%3 = alloca [255 x i8]
%4 = alloca [20 x i8]
%5 = alloca [80 x i8]
%6 = alloca i32
%7 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%10 = bitcast i32* %6 to i8*
%11 = call i32 @fgetpos(i32* %0, i32* %6)
br label %12
12: ; preds = %41, %2
%13 = call i32 @fsetpos(i32* %0, i32* %6)
%14 = call i32* @fgets(i8* %7, i32 255, i32* %0)
%15 = icmp eq i32* %14, null
br i1 %15, label %46, label %16
16: ; preds = %12
%17 = call i32* @fgets(i8* %7, i32 255, i32* %0)
%18 = icmp eq i32* %17, null
br i1 %18, label %46, label %19
19: ; preds = %16
%20 = call i32* @fgets(i8* %7, i32 255, i32* %0)
%21 = icmp eq i32* %20, null
br i1 %21, label %46, label %22
22: ; preds = %19
%23 = call i32* @fgets(i8* %7, i32 255, i32* %0)
%24 = icmp eq i32* %23, null
br i1 %24, label %46, label %25
25: ; preds = %22
%26 = call i32* @fgets(i8* %7, i32 255, i32* %0)
%27 = icmp eq i32* %26, null
br i1 %27, label %46, label %28
28: ; preds = %25
%29 = call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %8)
%30 = icmp eq i32 %29, 1
br i1 %30, label %31, label %46
31: ; preds = %28
%32 = call i64 @strcmp(i8* %1, i8* %8)
%33 = icmp eq i64 %32, 0
br i1 %33, label %41, label %34
34: ; preds = %31, %38
%35 = call i32 @fgetpos(i32* %0, i32* %6)
%36 = call i32* @fgets(i8* %7, i32 255, i32* %0)
%37 = icmp eq i32* %36, null
br i1 %37, label %46, label %38
38: ; preds = %34
%39 = call i32 @sscanf(i8* %7, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%40 = icmp eq i32 %39, 1
br i1 %40, label %41, label %34
41: ; preds = %38, %31
%42 = call i64 @strcmp(i8* %1, i8* %8)
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %12
44: ; preds = %41
%45 = call i32 @fsetpos(i32* %0, i32* %6)
br label %48
46: ; preds = %28, %12, %16, %19, %22, %25, %34
%47 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %1)
br label %48
48: ; preds = %46, %44
%49 = phi i32* [ null, %46 ], [ %0, %44 ]
ret i32* %49
}