#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*/ feof(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int /*<<< orphan*/ strcat(char *, char const *);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int __libnet_internal__seek_section(FILE *fp, const char *section) {
  char buffer[1024];
  char target[1024];
  strcpy(target, "[");
  strcat(target, section);
  strcat(target, "]\n");
  rewind(fp);
  do {
    fgets(buffer, 1024, fp);
    if (strlen(buffer) == 1023)
      while ((strlen(buffer) == 1023) && fgets(buffer, 1024, fp))
        ;
    else {
      if (!strcmp(buffer, target))
        return 0;
    }
  } while (!feof(fp));
  return 1;
}


x86 assembly (clang, -O0):
<__libnet_internal__seek_section>:
push   %rbp
mov    %rsp,%rbp
sub    $0x830,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x820(%rbp),%rdi
lea    0xe6f(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x820(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1090 <strcat@plt>
lea    -0x820(%rbp),%rdi
lea    0xe4e(%rip),%rsi
call   1090 <strcat@plt>
mov    -0x10(%rbp),%rdi
call   1050 <rewind@plt>
lea    -0x420(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x400,%esi
call   1060 <fgets@plt>
lea    -0x420(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x3ff,%eax
jne    1254 <__libnet_internal__seek_section+0xe4>
jmp    11f3 <__libnet_internal__seek_section+0x83>
lea    -0x420(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x3ff,%ecx
mov    %al,-0x821(%rbp)
jne    1237 <__libnet_internal__seek_section+0xc7>
lea    -0x420(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x400,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x821(%rbp)
mov    -0x821(%rbp),%al
test   $0x1,%al
jne    124a <__libnet_internal__seek_section+0xda>
jmp    124f <__libnet_internal__seek_section+0xdf>
jmp    11f3 <__libnet_internal__seek_section+0x83>
jmp    1281 <__libnet_internal__seek_section+0x111>
lea    -0x420(%rbp),%rdi
lea    -0x820(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    127c <__libnet_internal__seek_section+0x10c>
movl   $0x0,-0x4(%rbp)
jmp    12a6 <__libnet_internal__seek_section+0x136>
jmp    1281 <__libnet_internal__seek_section+0x111>
jmp    1286 <__libnet_internal__seek_section+0x116>
mov    -0x10(%rbp),%rdi
call   1080 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11c2 <__libnet_internal__seek_section+0x52>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x830,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__libnet_internal__seek_section>:
push   %r15
push   %r14
push   %rbx
sub    $0x800,%rsp
mov    %rsi,%rbx
mov    %rdi,%r15
lea    0xe77(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
call   1030 <strcpy@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1090 <strcat@plt>
lea    0xe5c(%rip),%rsi
mov    %r14,%rdi
call   1090 <strcat@plt>
mov    %r15,%rdi
call   1050 <rewind@plt>
lea    0x400(%rsp),%rbx
jmp    11db <__libnet_internal__seek_section+0x6b>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <strcmp@plt>
test   %eax,%eax
je     122d <__libnet_internal__seek_section+0xbd>
mov    %r15,%rdi
call   1080 <feof@plt>
test   %eax,%eax
jne    1226 <__libnet_internal__seek_section+0xb6>
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %r15,%rdx
call   1060 <fgets@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    $0x3ff,%eax
jne    11c0 <__libnet_internal__seek_section+0x50>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    $0x3ff,%eax
jne    11cf <__libnet_internal__seek_section+0x5f>
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %r15,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
jne    1200 <__libnet_internal__seek_section+0x90>
jmp    11cf <__libnet_internal__seek_section+0x5f>
mov    $0x1,%eax
jmp    122f <__libnet_internal__seek_section+0xbf>
xor    %eax,%eax
add    $0x800,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"[\00"
@.str.1 = [3 x i8] c"]\0A\00"
define i32 @__libnet_internal__seek_section(i32* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca [1024 x i8]
%7 = alloca [1024 x i8]
store i32* %0, i32** %4
store i8* %1, i8** %5
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%9 = call i32 @strcpy(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%11 = load i8*, i8** %5
%12 = call i32 @strcat(i8* %10, i8* %11)
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%14 = call i32 @strcat(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%15 = load i32*, i32** %4
%16 = call i32 @rewind(i32* %15)
br label %17
17: ; preds = %46, %2
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%19 = load i32*, i32** %4
%20 = call i64 @fgets(i8* %18, i32 1024, i32* %19)
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%22 = call i32 @strlen(i8* %21)
%23 = icmp eq i32 %22, 1023
br i1 %23, label %24, label %38
24: ; preds = %17
br label %25
25: ; preds = %36, %24
%26 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%27 = call i32 @strlen(i8* %26)
%28 = icmp eq i32 %27, 1023
br i1 %28, label %29, label %34
29: ; preds = %25
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%31 = load i32*, i32** %4
%32 = call i64 @fgets(i8* %30, i32 1024, i32* %31)
%33 = icmp ne i64 %32, 0
br label %34
34: ; preds = %29, %25
%35 = phi i1 [ false, %25 ], [ %33, %29 ]
br i1 %35, label %36, label %37
36: ; preds = %34
br label %25
37: ; preds = %34
br label %45
38: ; preds = %17
%39 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%40 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%41 = call i32 @strcmp(i8* %39, i8* %40)
%42 = icmp ne i32 %41, 0
br i1 %42, label %44, label %43
43: ; preds = %38
store i32 0, i32* %3
br label %52
44: ; preds = %38
br label %45
45: ; preds = %44, %37
br label %46
46: ; preds = %45
%47 = load i32*, i32** %4
%48 = call i32 @feof(i32* %47)
%49 = icmp ne i32 %48, 0
%50 = xor i1 %49, true
br i1 %50, label %17, label %51
51: ; preds = %46
store i32 1, i32* %3
br label %52
52: ; preds = %51, %43
%53 = load i32, i32* %3
ret i32 %53
}

LLVM IR (-O2):
@.str = [2 x i8] c"[\00"
@.str.1 = [3 x i8] c"]\0A\00"
define i32 @__libnet_internal__seek_section(i32* nocapture %0, i8* %1) {
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%7 = call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @strcat(i8* %6, i8* %1)
%9 = call i32 @strcat(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @rewind(i32* %0)
br label %11
11: ; preds = %24, %2
%12 = call i64 @fgets(i8* %5, i32 1024, i32* %0)
%13 = call i32 @strlen(i8* %5)
%14 = icmp eq i32 %13, 1023
br i1 %14, label %15, label %21
15: ; preds = %11, %18
%16 = call i32 @strlen(i8* %5)
%17 = icmp eq i32 %16, 1023
br i1 %17, label %18, label %24
18: ; preds = %15
%19 = call i64 @fgets(i8* %5, i32 1024, i32* %0)
%20 = icmp eq i64 %19, 0
br i1 %20, label %24, label %15
21: ; preds = %11
%22 = call i32 @strcmp(i8* %5, i8* %6)
%23 = icmp eq i32 %22, 0
br i1 %23, label %27, label %24
24: ; preds = %15, %18, %21
%25 = call i32 @feof(i32* %0)
%26 = icmp eq i32 %25, 0
br i1 %26, label %11, label %27
27: ; preds = %24, %21
%28 = phi i32 [ 0, %21 ], [ 1, %24 ]
ret i32 %28
}