#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*/ *current_config(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int getheader(char *);
int /*<<< orphan*/ iscomment(char *);
scalar_t__ isheader(char *);
int /*<<< orphan*/ trim(char *);
FILE *Find_First(int config_header) {
  FILE *configfile;
  char inputbuffer[8192];
  int headertype = 0;
  configfile = current_config("r");
  if (!configfile)
    return (configfile);
  while (fgets(inputbuffer, 8192, configfile)) {
    trim(inputbuffer);
    if (!iscomment(inputbuffer)) {
      if (isheader(inputbuffer)) {
        headertype = getheader(inputbuffer);
        if (headertype == config_header) {
          return (configfile);
        }
      }
    }
  }
  fclose(configfile);
  configfile = (FILE *)NULL;
  return (configfile);
}


x86 assembly (clang, -O0):
<Find_First>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2030,%rsp
mov    %edi,-0xc(%rbp)
movl   $0x0,-0x2024(%rbp)
lea    0xe71(%rip),%rdi
call   1030 <current_config@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11b0 <Find_First+0x40>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1261 <Find_First+0xf1>
jmp    11b5 <Find_First+0x45>
lea    -0x2020(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x2000,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     1248 <Find_First+0xd8>
lea    -0x2020(%rbp),%rdi
call   1050 <trim@plt>
lea    -0x2020(%rbp),%rdi
call   1090 <iscomment@plt>
cmp    $0x0,%eax
jne    1243 <Find_First+0xd3>
lea    -0x2020(%rbp),%rdi
call   1060 <isheader@plt>
cmp    $0x0,%rax
je     123e <Find_First+0xce>
lea    -0x2020(%rbp),%rdi
call   1080 <getheader@plt>
mov    %eax,-0x2024(%rbp)
mov    -0x2024(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    1239 <Find_First+0xc9>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1261 <Find_First+0xf1>
jmp    123e <Find_First+0xce>
jmp    1243 <Find_First+0xd3>
jmp    11b5 <Find_First+0x45>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x2030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Find_First>:
push   %rbp
push   %r14
push   %rbx
sub    $0x2000,%rsp
mov    %edi,%r14d
lea    0xe7b(%rip),%rdi
call   1030 <current_config@plt>
test   %rax,%rax
je     11fd <Find_First+0x8d>
mov    %rax,%rbx
mov    %rsp,%rdi
mov    $0x2000,%esi
mov    %rax,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     11f5 <Find_First+0x85>
mov    %rsp,%rbp
jmp    11c5 <Find_First+0x55>
nopl   0x0(%rax)
mov    %rbp,%rdi
mov    $0x2000,%esi
mov    %rbx,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     11f5 <Find_First+0x85>
mov    %rbp,%rdi
call   1050 <trim@plt>
mov    %rbp,%rdi
call   1090 <iscomment@plt>
test   %eax,%eax
jne    11b0 <Find_First+0x40>
mov    %rbp,%rdi
call   1060 <isheader@plt>
test   %rax,%rax
je     11b0 <Find_First+0x40>
mov    %rbp,%rdi
call   1080 <getheader@plt>
cmp    %r14d,%eax
jne    11b0 <Find_First+0x40>
jmp    11ff <Find_First+0x8f>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x2000,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
define i32* @Find_First(i32 %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32*
%5 = alloca [8192 x i8]
%6 = alloca i32
store i32 %0, i32* %3
store i32 0, i32* %6
%7 = call i32* @current_config(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %7, i32** %4
%8 = load i32*, i32** %4
%9 = icmp ne i32* %8, null
br i1 %9, label %12, label %10
10: ; preds = %1
%11 = load i32*, i32** %4
store i32* %11, i32** %2
br label %43
12: ; preds = %1
br label %13
13: ; preds = %38, %12
%14 = getelementptr inbounds [8192 x i8], [8192 x i8]* %5, i64 0, i64 0
%15 = load i32*, i32** %4
%16 = call i64 @fgets(i8* %14, i32 8192, i32* %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %39
18: ; preds = %13
%19 = getelementptr inbounds [8192 x i8], [8192 x i8]* %5, i64 0, i64 0
%20 = call i32 @trim(i8* %19)
%21 = getelementptr inbounds [8192 x i8], [8192 x i8]* %5, i64 0, i64 0
%22 = call i32 @iscomment(i8* %21)
%23 = icmp ne i32 %22, 0
br i1 %23, label %38, label %24
24: ; preds = %18
%25 = getelementptr inbounds [8192 x i8], [8192 x i8]* %5, i64 0, i64 0
%26 = call i64 @isheader(i8* %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %37
28: ; preds = %24
%29 = getelementptr inbounds [8192 x i8], [8192 x i8]* %5, i64 0, i64 0
%30 = call i32 @getheader(i8* %29)
store i32 %30, i32* %6
%31 = load i32, i32* %6
%32 = load i32, i32* %3
%33 = icmp eq i32 %31, %32
br i1 %33, label %34, label %36
34: ; preds = %28
%35 = load i32*, i32** %4
store i32* %35, i32** %2
br label %43
36: ; preds = %28
br label %37
37: ; preds = %36, %24
br label %38
38: ; preds = %37, %18
br label %13
39: ; preds = %13
%40 = load i32*, i32** %4
%41 = call i32 @fclose(i32* %40)
store i32* null, i32** %4
%42 = load i32*, i32** %4
store i32* %42, i32** %2
br label %43
43: ; preds = %39, %34, %10
%44 = load i32*, i32** %2
ret i32* %44
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
define i32* @Find_First(i32 %0) {
%2 = alloca [8192 x i8]
%3 = getelementptr inbounds [8192 x i8], [8192 x i8]* %2, i64 0, i64 0
%4 = tail call i32* @current_config(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %24, label %6
6: ; preds = %1
%7 = call i64 @fgets(i8* %3, i32 8192, i32* %4)
%8 = icmp eq i64 %7, 0
br i1 %8, label %22, label %9
9: ; preds = %6, %19
%10 = call i32 @trim(i8* %3)
%11 = call i32 @iscomment(i8* %3)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %19
13: ; preds = %9
%14 = call i64 @isheader(i8* %3)
%15 = icmp eq i64 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %13
%17 = call i32 @getheader(i8* %3)
%18 = icmp eq i32 %17, %0
br i1 %18, label %24, label %19
19: ; preds = %13, %16, %9
%20 = call i64 @fgets(i8* %3, i32 8192, i32* %4)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %9
22: ; preds = %19, %6
%23 = call i32 @fclose(i32* %4)
br label %24
24: ; preds = %16, %1, %22
%25 = phi i32* [ null, %22 ], [ null, %1 ], [ %4, %16 ]
ret i32* %25
}