#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 */
char EOF;
char fgetc(int /*<<< orphan*/ *);
scalar_t__ strlen(char const *);
int /*<<< orphan*/ strncmp(char *, char const *, int);
int FindMarker(FILE *infile, const char *marker) {
  char line[50];
  int i, len;
  len = (int)strlen(marker);
  if (len > 50 - 1)
    len = 50 - 1;
  for (i = 0; i < len; i++)
    if ((line[i] = fgetc(infile)) == EOF)
      return 0;
  line[len] = '\0';
  while (1) {
    if (!strncmp(line, marker, len))
      return 1;
    for (i = 0; i < len - 1; i++)
      line[i] = line[i + 1];
    if ((line[len - 1] = fgetc(infile)) == EOF)
      return 0;
    line[len] = '\0';
  }
  return 0;
}


x86 assembly (clang, -O0):
<FindMarker>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x58(%rbp)
cmpl   $0x31,-0x58(%rbp)
jle    115d <FindMarker+0x2d>
movl   $0x31,-0x58(%rbp)
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x58(%rbp),%eax
jge    11b5 <FindMarker+0x85>
mov    -0x10(%rbp),%rdi
call   1050 <fgetc@plt>
movslq -0x54(%rbp),%rcx
mov    %al,-0x50(%rbp,%rcx,1)
movsbl %al,%eax
mov    0x2e5d(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    11a2 <FindMarker+0x72>
movl   $0x0,-0x4(%rbp)
jmp    1262 <FindMarker+0x132>
jmp    11a7 <FindMarker+0x77>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1164 <FindMarker+0x34>
movslq -0x58(%rbp),%rax
movb   $0x0,-0x50(%rbp,%rax,1)
lea    -0x50(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x58(%rbp),%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    11e3 <FindMarker+0xb3>
movl   $0x1,-0x4(%rbp)
jmp    1262 <FindMarker+0x132>
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
mov    -0x58(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    121d <FindMarker+0xed>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
cltq
mov    -0x50(%rbp,%rax,1),%cl
movslq -0x54(%rbp),%rax
mov    %cl,-0x50(%rbp,%rax,1)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    11ea <FindMarker+0xba>
mov    -0x10(%rbp),%rdi
call   1050 <fgetc@plt>
mov    -0x58(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %al,-0x50(%rbp,%rcx,1)
movsbl %al,%eax
mov    0x2dab(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    1254 <FindMarker+0x124>
movl   $0x0,-0x4(%rbp)
jmp    1262 <FindMarker+0x132>
movslq -0x58(%rbp),%rax
movb   $0x0,-0x50(%rbp,%rax,1)
jmp    11be <FindMarker+0x8e>
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FindMarker>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
mov    %rsi,%rdi
call   1040 <strlen@plt>
cmp    $0x31,%eax
mov    $0x31,%ebx
cmovl  %eax,%ebx
test   %eax,%eax
jle    119c <FindMarker+0x5c>
cmp    $0x2,%ebx
mov    $0x1,%ebp
cmovge %ebx,%ebp
mov    0x2e6b(%rip),%r13
xor    %r12d,%r12d
mov    %r15,%rdi
call   1050 <fgetc@plt>
mov    %al,0x10(%rsp,%r12,1)
cmp    0x0(%r13),%al
je     1208 <FindMarker+0xc8>
add    $0x1,%r12
cmp    %r12,%rbp
jne    1180 <FindMarker+0x40>
movslq %ebx,%r13
lea    -0x1(%rbx),%eax
mov    %rax,0x8(%rsp)
movslq %eax,%r12
lea    0x10(%rsp),%rbp
jmp    11d8 <FindMarker+0x98>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1050 <fgetc@plt>
mov    %al,0x10(%rsp,%r12,1)
mov    0x2e14(%rip),%rcx
cmp    (%rcx),%al
je     1208 <FindMarker+0xc8>
movb   $0x0,0x10(%rsp,%r13,1)
mov    %rbp,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     120c <FindMarker+0xcc>
cmp    $0x2,%ebx
jl     11c0 <FindMarker+0x80>
mov    %rbp,%rdi
lea    0x11(%rsp),%rsi
mov    0x8(%rsp),%rdx
call   1060 <memmove@plt>
jmp    11c0 <FindMarker+0x80>
xor    %eax,%eax
jmp    1211 <FindMarker+0xd1>
mov    $0x1,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i8 0
define i32 @FindMarker(i32* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca [50 x i8]
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
%9 = load i8*, i8** %5
%10 = call i64 @strlen(i8* %9)
%11 = trunc i64 %10 to i32
store i32 %11, i32* %8
%12 = load i32, i32* %8
%13 = icmp sgt i32 %12, 49
br i1 %13, label %14, label %15
14: ; preds = %2
store i32 49, i32* %8
br label %15
15: ; preds = %14, %2
store i32 0, i32* %7
br label %16
16: ; preds = %32, %15
%17 = load i32, i32* %7
%18 = load i32, i32* %8
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %35
20: ; preds = %16
%21 = load i32*, i32** %4
%22 = call signext i8 @fgetc(i32* %21)
%23 = load i32, i32* %7
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 %24
store i8 %22, i8* %25
%26 = sext i8 %22 to i32
%27 = load i8, i8* @EOF
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %26, %28
br i1 %29, label %30, label %31
30: ; preds = %20
store i32 0, i32* %3
br label %80
31: ; preds = %20
br label %32
32: ; preds = %31
%33 = load i32, i32* %7
%34 = add nsw i32 %33, 1
store i32 %34, i32* %7
br label %16
35: ; preds = %16
%36 = load i32, i32* %8
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 %37
store i8 0, i8* %38
br label %39
39: ; preds = %35, %76
%40 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%41 = load i8*, i8** %5
%42 = load i32, i32* %8
%43 = call i32 @strncmp(i8* %40, i8* %41, i32 %42)
%44 = icmp ne i32 %43, 0
br i1 %44, label %46, label %45
45: ; preds = %39
store i32 1, i32* %3
br label %80
46: ; preds = %39
store i32 0, i32* %7
br label %47
47: ; preds = %61, %46
%48 = load i32, i32* %7
%49 = load i32, i32* %8
%50 = sub nsw i32 %49, 1
%51 = icmp slt i32 %48, %50
br i1 %51, label %52, label %64
52: ; preds = %47
%53 = load i32, i32* %7
%54 = add nsw i32 %53, 1
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 %55
%57 = load i8, i8* %56
%58 = load i32, i32* %7
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 %59
store i8 %57, i8* %60
br label %61
61: ; preds = %52
%62 = load i32, i32* %7
%63 = add nsw i32 %62, 1
store i32 %63, i32* %7
br label %47
64: ; preds = %47
%65 = load i32*, i32** %4
%66 = call signext i8 @fgetc(i32* %65)
%67 = load i32, i32* %8
%68 = sub nsw i32 %67, 1
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 %69
store i8 %66, i8* %70
%71 = sext i8 %66 to i32
%72 = load i8, i8* @EOF
%73 = sext i8 %72 to i32
%74 = icmp eq i32 %71, %73
br i1 %74, label %75, label %76
75: ; preds = %64
store i32 0, i32* %3
br label %80
76: ; preds = %64
%77 = load i32, i32* %8
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 %78
store i8 0, i8* %79
br label %39
80: ; preds = %75, %45, %30
%81 = load i32, i32* %3
ret i32 %81
}

LLVM IR (-O2):
@EOF = global i8 0
define i32 @FindMarker(i32* nocapture %0, i8* %1) {
%3 = alloca [50 x i8]
%4 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%6 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%7 = trunc i64 %6 to i32
%8 = icmp slt i32 %7, 49
%9 = select i1 %8, i32 %7, i32 49
%10 = icmp sgt i32 %7, 0
br i1 %10, label %11, label %23
11: ; preds = %2
%12 = call i32 @llvm.smax.i32(i32 %9, i32 1)
%13 = zext i32 %12 to i64
br label %16
14: ; preds = %16
%15 = icmp eq i64 %22, %13
br i1 %15, label %23, label %16
16: ; preds = %11, %14
%17 = phi i64 [ 0, %11 ], [ %22, %14 ]
%18 = tail call signext i8 @fgetc(i32* %0)
%19 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 %17
store i8 %18, i8* %19
%20 = load i8, i8* @EOF
%21 = icmp eq i8 %18, %20
%22 = add nuw nsw i64 %17, 1
br i1 %21, label %41, label %14
23: ; preds = %14, %2
%24 = sext i32 %9 to i64
%25 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 %24
%26 = add i32 %9, -1
%27 = icmp sgt i32 %9, 1
%28 = sext i32 %26 to i64
%29 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 %28
%30 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 1
%31 = zext i32 %26 to i64
br label %32
32: ; preds = %37, %23
store i8 0, i8* %25
%33 = call i32 @strncmp(i8* %5, i8* %1, i32 %9)
%34 = icmp eq i32 %33, 0
br i1 %34, label %41, label %35
35: ; preds = %32
br i1 %27, label %36, label %37
36: ; preds = %35
br label %37
37: ; preds = %36, %35
%38 = call signext i8 @fgetc(i32* %0)
store i8 %38, i8* %29
%39 = load i8, i8* @EOF
%40 = icmp eq i8 %38, %39
br i1 %40, label %41, label %32
41: ; preds = %16, %37, %32
%42 = phi i32 [ 0, %37 ], [ 1, %32 ], [ 0, %16 ]
ret i32 %42
}