#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 EOF;
int getc(int /*<<< orphan*/ *);
int seekFILEpipe(FILE *fp, char *s) {
  register char *ptr = s;
  register int ch, ctr = 1;
  ch = getc(fp);
  do {
    if (ch == EOF)
      return EOF;
    else
      (*ptr == ch) ? (ptr++) : (ptr = (*s == ch) ? s + 1 : s);
    ch = getc(fp);
    ctr++;
  } while (*ptr);
  return ctr;
}


x86 assembly (clang, -O0):
<seekFILEpipe>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x1,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <getc@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    0x2ea3(%rip),%rcx
cmp    (%rcx),%eax
jne    115e <seekFILEpipe+0x4e>
mov    0x2e94(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11d8 <seekFILEpipe+0xc8>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    -0x24(%rbp),%eax
jne    117f <seekFILEpipe+0x6f>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    11b0 <seekFILEpipe+0xa0>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    -0x24(%rbp),%eax
jne    11a0 <seekFILEpipe+0x90>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    11a8 <seekFILEpipe+0x98>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <getc@plt>
mov    %eax,-0x24(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
jne    113b <seekFILEpipe+0x2b>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<seekFILEpipe>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r12
call   1030 <getc@plt>
mov    $0x1,%ebp
mov    0x2eb9(%rip),%r15
mov    %r14,%rbx
jmp    115e <seekFILEpipe+0x4e>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl (%r14),%ecx
xor    %ebx,%ebx
cmp    %ecx,%eax
sete   %bl
add    %r14,%rbx
mov    %r12,%rdi
call   1030 <getc@plt>
add    $0x1,%ebp
cmpb   $0x0,(%rbx)
je     1172 <seekFILEpipe+0x62>
cmp    (%r15),%eax
je     1170 <seekFILEpipe+0x60>
movsbl (%rbx),%ecx
cmp    %ecx,%eax
jne    1140 <seekFILEpipe+0x30>
add    $0x1,%rbx
jmp    114e <seekFILEpipe+0x3e>
mov    %eax,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
define i32 @seekFILEpipe(i32* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
%9 = load i8*, i8** %5
store i8* %9, i8** %6
store i32 1, i32* %8
%10 = load i32*, i32** %4
%11 = call i32 @getc(i32* %10)
store i32 %11, i32* %7
br label %12
12: ; preds = %47, %2
%13 = load i32, i32* %7
%14 = load i32, i32* @EOF
%15 = icmp eq i32 %13, %14
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = load i32, i32* @EOF
store i32 %17, i32* %3
br label %53
18: ; preds = %12
%19 = load i8*, i8** %6
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = load i32, i32* %7
%23 = icmp eq i32 %21, %22
br i1 %23, label %24, label %27
24: ; preds = %18
%25 = load i8*, i8** %6
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %6
br label %40
27: ; preds = %18
%28 = load i8*, i8** %5
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = load i32, i32* %7
%32 = icmp eq i32 %30, %31
br i1 %32, label %33, label %36
33: ; preds = %27
%34 = load i8*, i8** %5
%35 = getelementptr inbounds i8, i8* %34, i64 1
br label %38
36: ; preds = %27
%37 = load i8*, i8** %5
br label %38
38: ; preds = %36, %33
%39 = phi i8* [ %35, %33 ], [ %37, %36 ]
store i8* %39, i8** %6
br label %40
40: ; preds = %38, %24
%41 = phi i8* [ %25, %24 ], [ %39, %38 ]
br label %42
42: ; preds = %40
%43 = load i32*, i32** %4
%44 = call i32 @getc(i32* %43)
store i32 %44, i32* %7
%45 = load i32, i32* %8
%46 = add nsw i32 %45, 1
store i32 %46, i32* %8
br label %47
47: ; preds = %42
%48 = load i8*, i8** %6
%49 = load i8, i8* %48
%50 = icmp ne i8 %49, 0
br i1 %50, label %12, label %51
51: ; preds = %47
%52 = load i32, i32* %8
store i32 %52, i32* %3
br label %53
53: ; preds = %51, %16
%54 = load i32, i32* %3
ret i32 %54
}

LLVM IR (-O2):
@EOF = global i32 0
define i32 @seekFILEpipe(i32* nocapture %0, i8* nocapture %1) {
%3 = tail call i32 @getc(i32* %0)
br label %4
4: ; preds = %22, %2
%5 = phi i8* [ %1, %2 ], [ %23, %22 ]
%6 = phi i32 [ %3, %2 ], [ %24, %22 ]
%7 = phi i32 [ 1, %2 ], [ %25, %22 ]
%8 = load i32, i32* @EOF
%9 = icmp eq i32 %6, %8
br i1 %9, label %28, label %10
10: ; preds = %4
%11 = load i8, i8* %5
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %6, %12
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = getelementptr inbounds i8, i8* %5, i64 1
br label %22
16: ; preds = %10
%17 = load i8, i8* %1
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %6, %18
%20 = zext i1 %19 to i64
%21 = getelementptr i8, i8* %1, i64 %20
br label %22
22: ; preds = %14, %16
%23 = phi i8* [ %15, %14 ], [ %21, %16 ]
%24 = tail call i32 @getc(i32* %0)
%25 = add nuw nsw i32 %7, 1
%26 = load i8, i8* %23
%27 = icmp eq i8 %26, 0
br i1 %27, label %28, label %4
28: ; preds = %22, %4
%29 = phi i32 [ %6, %4 ], [ %25, %22 ]
ret i32 %29
}