#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 /*<<< orphan*/ *fgets(char *, int const, int /*<<< orphan*/ *);
scalar_t__ strstr(char *, char const *);
int RnaFoldPs_CheckHeader(FILE *fd) {
  const int max_line_length = 1024;
  char line[max_line_length];
  const char header_ident[] = "%%Creator: PS_dot.c";
  while (fgets(line, max_line_length, fd) != NULL) {
    if (strstr(line, header_ident))
      return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<RnaFoldPs_CheckHeader>:
push   %rbp
mov    %rsp,%rbp
sub    $0x450,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x400,-0x14(%rbp)
mov    %rsp,%rax
mov    %rax,-0x20(%rbp)
mov    0xebc(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xeb9(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xeb7(%rip),%eax
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%rdx
lea    -0x450(%rbp),%rdi
mov    $0x400,%esi
call   1030 <fgets@plt>
cmp    $0x0,%rax
je     11ad <RnaFoldPs_CheckHeader+0x8d>
lea    -0x40(%rbp),%rsi
lea    -0x450(%rbp),%rdi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     11a8 <RnaFoldPs_CheckHeader+0x88>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x44(%rbp)
jmp    11bb <RnaFoldPs_CheckHeader+0x9b>
jmp    115c <RnaFoldPs_CheckHeader+0x3c>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x44(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
add    $0x450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RnaFoldPs_CheckHeader>:
push   %r15
push   %r14
push   %rbx
sub    $0x420,%rsp
mov    %rdi,%r14
movaps 0xeca(%rip),%xmm0
movaps %xmm0,(%rsp)
movl   $0x632e74,0x10(%rsp)
lea    0x20(%rsp),%rbx
mov    %rsp,%r15
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %r14,%rdx
call   1030 <fgets@plt>
test   %rax,%rax
je     117c <RnaFoldPs_CheckHeader+0x5c>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strstr@plt>
test   %rax,%rax
je     1150 <RnaFoldPs_CheckHeader+0x30>
mov    $0x1,%eax
jmp    117e <RnaFoldPs_CheckHeader+0x5e>
xor    %eax,%eax
add    $0x420,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.RnaFoldPs_CheckHeader.header_ident = [20 x i8] c"%%Creator: PS_dot.c\00"
define i32 @RnaFoldPs_CheckHeader(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca [20 x i8]
%7 = alloca i32
store i32* %0, i32** %3
store i32 1024, i32* %4
%8 = call i8* @llvm.stacksave()
store i8* %8, i8** %5
%9 = alloca i8, i64 1024
%10 = bitcast [20 x i8]* %6 to i8*
br label %11
11: ; preds = %20, %1
%12 = load i32*, i32** %3
%13 = call i32* @fgets(i8* %9, i32 1024, i32* %12)
%14 = icmp ne i32* %13, null
br i1 %14, label %15, label %21
15: ; preds = %11
%16 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%17 = call i64 @strstr(i8* %9, i8* %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %15
store i32 1, i32* %2
store i32 1, i32* %7
br label %22
20: ; preds = %15
br label %11
21: ; preds = %11
store i32 0, i32* %2
store i32 1, i32* %7
br label %22
22: ; preds = %21, %19
%23 = load i8*, i8** %5
%24 = load i32, i32* %2
ret i32 %24
}

LLVM IR (-O2):
@__const.RnaFoldPs_CheckHeader.header_ident = [20 x i8] c"%%Creator: PS_dot.c\00"
define i32 @RnaFoldPs_CheckHeader(i32* nocapture %0) {
%2 = alloca [20 x i8]
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
br label %6
6: ; preds = %9, %1
%7 = call i32* @fgets(i8* %4, i32 1024, i32* %0)
%8 = icmp eq i32* %7, null
br i1 %8, label %12, label %9
9: ; preds = %6
%10 = call i64 @strstr(i8* %4, i8* %5)
%11 = icmp eq i64 %10, 0
br i1 %11, label %6, label %12
12: ; preds = %6, %9
%13 = phi i32 [ 1, %9 ], [ 0, %6 ]
ret i32 %13
}