#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 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;
  int curr_line;
  len = (int)strlen(marker);
  if (len > 50 - 1)
    len = 50 - 1;
  for (i = 0; i < len; i++) {
    curr_line = fgetc(infile);
    line[i] = curr_line;
    if (curr_line == 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];
    curr_line = fgetc(infile);
    line[len - 1] = curr_line;
    if (curr_line == 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    11ba <FindMarker+0x8a>
mov    -0x10(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
mov    %al,%cl
movslq -0x54(%rbp),%rax
mov    %cl,-0x50(%rbp,%rax,1)
mov    -0x5c(%rbp),%eax
mov    0x2e55(%rip),%rcx
cmp    (%rcx),%eax
jne    11a7 <FindMarker+0x77>
movl   $0x0,-0x4(%rbp)
jmp    126b <FindMarker+0x13b>
jmp    11ac <FindMarker+0x7c>
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    11e8 <FindMarker+0xb8>
movl   $0x1,-0x4(%rbp)
jmp    126b <FindMarker+0x13b>
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
mov    -0x58(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1222 <FindMarker+0xf2>
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    11ef <FindMarker+0xbf>
mov    -0x10(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
mov    %al,%cl
mov    -0x58(%rbp),%eax
sub    $0x1,%eax
cltq
mov    %cl,-0x50(%rbp,%rax,1)
mov    -0x5c(%rbp),%eax
mov    0x2d9f(%rip),%rcx
cmp    (%rcx),%eax
jne    125d <FindMarker+0x12d>
movl   $0x0,-0x4(%rbp)
jmp    126b <FindMarker+0x13b>
movslq -0x58(%rbp),%rax
movb   $0x0,-0x50(%rbp,%rax,1)
jmp    11c3 <FindMarker+0x93>
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),%eax
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),%eax
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 i32 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
%9 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
%10 = load i8*, i8** %5
%11 = call i64 @strlen(i8* %10)
%12 = trunc i64 %11 to i32
store i32 %12, i32* %8
%13 = load i32, i32* %8
%14 = icmp sgt i32 %13, 49
br i1 %14, label %15, label %16
15: ; preds = %2
store i32 49, i32* %8
br label %16
16: ; preds = %15, %2
store i32 0, i32* %7
br label %17
17: ; preds = %34, %16
%18 = load i32, i32* %7
%19 = load i32, i32* %8
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %37
21: ; preds = %17
%22 = load i32*, i32** %4
%23 = call i32 @fgetc(i32* %22)
store i32 %23, i32* %9
%24 = load i32, i32* %9
%25 = trunc i32 %24 to i8
%26 = load i32, i32* %7
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 %27
store i8 %25, i8* %28
%29 = load i32, i32* %9
%30 = load i32, i32* @EOF
%31 = icmp eq i32 %29, %30
br i1 %31, label %32, label %33
32: ; preds = %21
store i32 0, i32* %3
br label %83
33: ; preds = %21
br label %34
34: ; preds = %33
%35 = load i32, i32* %7
%36 = add nsw i32 %35, 1
store i32 %36, i32* %7
br label %17
37: ; preds = %17
%38 = load i32, i32* %8
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 %39
store i8 0, i8* %40
br label %41
41: ; preds = %37, %79
%42 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%43 = load i8*, i8** %5
%44 = load i32, i32* %8
%45 = call i32 @strncmp(i8* %42, i8* %43, i32 %44)
%46 = icmp ne i32 %45, 0
br i1 %46, label %48, label %47
47: ; preds = %41
store i32 1, i32* %3
br label %83
48: ; preds = %41
store i32 0, i32* %7
br label %49
49: ; preds = %63, %48
%50 = load i32, i32* %7
%51 = load i32, i32* %8
%52 = sub nsw i32 %51, 1
%53 = icmp slt i32 %50, %52
br i1 %53, label %54, label %66
54: ; preds = %49
%55 = load i32, i32* %7
%56 = add nsw i32 %55, 1
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 %57
%59 = load i8, i8* %58
%60 = load i32, i32* %7
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 %61
store i8 %59, i8* %62
br label %63
63: ; preds = %54
%64 = load i32, i32* %7
%65 = add nsw i32 %64, 1
store i32 %65, i32* %7
br label %49
66: ; preds = %49
%67 = load i32*, i32** %4
%68 = call i32 @fgetc(i32* %67)
store i32 %68, i32* %9
%69 = load i32, i32* %9
%70 = trunc i32 %69 to i8
%71 = load i32, i32* %8
%72 = sub nsw i32 %71, 1
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 %73
store i8 %70, i8* %74
%75 = load i32, i32* %9
%76 = load i32, i32* @EOF
%77 = icmp eq i32 %75, %76
br i1 %77, label %78, label %79
78: ; preds = %66
store i32 0, i32* %3
br label %83
79: ; preds = %66
%80 = load i32, i32* %8
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 %81
store i8 0, i8* %82
br label %41
83: ; preds = %78, %47, %32
%84 = load i32, i32* %3
ret i32 %84
}

LLVM IR (-O2):
@EOF = global i32 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 %24
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 %23, %13
br i1 %15, label %24, label %16
16: ; preds = %11, %14
%17 = phi i64 [ 0, %11 ], [ %23, %14 ]
%18 = tail call i32 @fgetc(i32* %0)
%19 = trunc i32 %18 to i8
%20 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 %17
store i8 %19, i8* %20
%21 = load i32, i32* @EOF
%22 = icmp eq i32 %18, %21
%23 = add nuw nsw i64 %17, 1
br i1 %22, label %43, label %14
24: ; preds = %14, %2
%25 = sext i32 %9 to i64
%26 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 %25
%27 = add i32 %9, -1
%28 = icmp sgt i32 %9, 1
%29 = sext i32 %27 to i64
%30 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 %29
%31 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 1
%32 = zext i32 %27 to i64
br label %33
33: ; preds = %38, %24
store i8 0, i8* %26
%34 = call i32 @strncmp(i8* %5, i8* %1, i32 %9)
%35 = icmp eq i32 %34, 0
br i1 %35, label %43, label %36
36: ; preds = %33
br i1 %28, label %37, label %38
37: ; preds = %36
br label %38
38: ; preds = %37, %36
%39 = call i32 @fgetc(i32* %0)
%40 = trunc i32 %39 to i8
store i8 %40, i8* %30
%41 = load i32, i32* @EOF
%42 = icmp eq i32 %39, %41
br i1 %42, label %43, label %33
43: ; preds = %16, %38, %33
%44 = phi i32 [ 0, %38 ], [ 1, %33 ], [ 0, %16 ]
ret i32 %44
}