#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 *fgets(char *, size_t, int /*<<< orphan*/ *);
size_t strlen(char *);
int /*<<< orphan*/ strncmp(char *, char *, size_t);
int skip_till_prefix(FILE *f, char *line, size_t line_len, char *prefix) {
  int found = 0;
  size_t prefix_len = strlen(prefix);
  do {
    if (!strncmp(prefix, line, prefix_len)) {
      found = 1;
      break;
    }
  } while (line == fgets(line, line_len, f));
  if (!found) {
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<skip_till_prefix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x38(%rbp),%rdx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1182 <skip_till_prefix+0x52>
movl   $0x1,-0x2c(%rbp)
jmp    11b0 <skip_till_prefix+0x80>
jmp    1187 <skip_till_prefix+0x57>
mov    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1050 <fgets@plt>
mov    %rax,%rcx
mov    -0x40(%rbp),%rax
cmp    %rcx,%rax
je     115c <skip_till_prefix+0x2c>
cmpl   $0x0,-0x2c(%rbp)
jne    11c6 <skip_till_prefix+0x96>
movl   $0xffffffff,-0x4(%rbp)
jmp    11cd <skip_till_prefix+0x9d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<skip_till_prefix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r15
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r12
mov    %rcx,%rdi
call   1040 <strlen@plt>
mov    %rax,%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
call   1030 <strncmp@plt>
mov    %eax,%ebp
test   %eax,%eax
je     1187 <skip_till_prefix+0x57>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
call   1050 <fgets@plt>
cmp    %rbx,%rax
je     1160 <skip_till_prefix+0x30>
neg    %ebp
sbb    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @skip_till_prefix(i32* %0, i8* %1, i64 %2, i8* %3) {
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i64
store i32* %0, i32** %6
store i8* %1, i8** %7
store i64 %2, i64* %8
store i8* %3, i8** %9
store i32 0, i32* %10
%12 = load i8*, i8** %9
%13 = call i64 @strlen(i8* %12)
store i64 %13, i64* %11
br label %14
14: ; preds = %22, %4
%15 = load i8*, i8** %9
%16 = load i8*, i8** %7
%17 = load i64, i64* %11
%18 = call i32 @strncmp(i8* %15, i8* %16, i64 %17)
%19 = icmp ne i32 %18, 0
br i1 %19, label %21, label %20
20: ; preds = %14
store i32 1, i32* %10
br label %29
21: ; preds = %14
br label %22
22: ; preds = %21
%23 = load i8*, i8** %7
%24 = load i8*, i8** %7
%25 = load i64, i64* %8
%26 = load i32*, i32** %6
%27 = call i8* @fgets(i8* %24, i64 %25, i32* %26)
%28 = icmp eq i8* %23, %27
br i1 %28, label %14, label %29
29: ; preds = %22, %20
%30 = load i32, i32* %10
%31 = icmp ne i32 %30, 0
br i1 %31, label %33, label %32
32: ; preds = %29
store i32 -1, i32* %5
br label %34
33: ; preds = %29
store i32 0, i32* %5
br label %34
34: ; preds = %33, %32
%35 = load i32, i32* %5
ret i32 %35
}

LLVM IR (-O2):
define i32 @skip_till_prefix(i32* nocapture %0, i8* %1, i64 %2, i8* nocapture %3) {
%5 = tail call i64 @strlen(i8* dereferenceable(1) %3)
br label %6
6: ; preds = %9, %4
%7 = tail call i32 @strncmp(i8* %3, i8* %1, i64 %5)
%8 = icmp eq i32 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %6
%10 = tail call i8* @fgets(i8* %1, i64 %2, i32* %0)
%11 = icmp eq i8* %10, %1
br i1 %11, label %6, label %12
12: ; preds = %6, %9
%13 = xor i1 %8, true
%14 = sext i1 %13 to i32
ret i32 %14
}