#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 */
struct Reg_Log {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ getlog(char *, struct Reg_Log *);
scalar_t__ isheader(char *);
scalar_t__ islog(char *);
int strlen(char *);
int /*<<< orphan*/ trim(char *);
int Get_Next_Log(FILE *configfile, struct Reg_Log *log_struct) {
  char inputbuffer[8192];
  while (fgets(inputbuffer, 8192, configfile)) {
    trim(inputbuffer);
    if (isheader(inputbuffer))
      return (0);
    if (strlen(inputbuffer) < 3)
      continue;
    if (islog(inputbuffer)) {
      getlog(inputbuffer, log_struct);
      return (1);
    }
  }
  return (0);
}


x86 assembly (clang, -O0):
<Get_Next_Log>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2020,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x2020(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x2000,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     1211 <Get_Next_Log+0xb1>
lea    -0x2020(%rbp),%rdi
call   1040 <trim@plt>
lea    -0x2020(%rbp),%rdi
call   1050 <isheader@plt>
cmp    $0x0,%rax
je     11c0 <Get_Next_Log+0x60>
movl   $0x0,-0x4(%rbp)
jmp    1218 <Get_Next_Log+0xb8>
lea    -0x2020(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x3,%eax
jge    11da <Get_Next_Log+0x7a>
jmp    1173 <Get_Next_Log+0x13>
lea    -0x2020(%rbp),%rdi
call   1080 <islog@plt>
cmp    $0x0,%rax
je     120c <Get_Next_Log+0xac>
lea    -0x2020(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <getlog@plt>
movl   $0x1,-0x4(%rbp)
jmp    1218 <Get_Next_Log+0xb8>
jmp    1173 <Get_Next_Log+0x13>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x2020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Get_Next_Log>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x2008,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsp,%rdi
mov    $0x2000,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
xor    %r15d,%r15d
test   %rax,%rax
je     11e5 <Get_Next_Log+0x85>
mov    %rsp,%rbp
jmp    11a5 <Get_Next_Log+0x45>
mov    %rbp,%rdi
mov    $0x2000,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     11e5 <Get_Next_Log+0x85>
mov    %rbp,%rdi
call   1040 <trim@plt>
mov    %rbp,%rdi
call   1050 <isheader@plt>
test   %rax,%rax
jne    11e5 <Get_Next_Log+0x85>
mov    %rbp,%rdi
call   1030 <strlen@plt>
cmp    $0x2,%eax
jle    1190 <Get_Next_Log+0x30>
mov    %rbp,%rdi
call   1080 <islog@plt>
test   %rax,%rax
je     1190 <Get_Next_Log+0x30>
mov    %rsp,%rdi
mov    %r14,%rsi
call   1070 <getlog@plt>
mov    $0x1,%r15d
mov    %r15d,%eax
add    $0x2008,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.Reg_Log = type { i32 }
define i32 @Get_Next_Log(i32* %0, %struct.Reg_Log* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca %struct.Reg_Log*
%6 = alloca [8192 x i8]
store i32* %0, i32** %4
store %struct.Reg_Log* %1, %struct.Reg_Log** %5
br label %7
7: ; preds = %32, %23, %2
%8 = getelementptr inbounds [8192 x i8], [8192 x i8]* %6, i64 0, i64 0
%9 = load i32*, i32** %4
%10 = call i64 @fgets(i8* %8, i32 8192, i32* %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %33
12: ; preds = %7
%13 = getelementptr inbounds [8192 x i8], [8192 x i8]* %6, i64 0, i64 0
%14 = call i32 @trim(i8* %13)
%15 = getelementptr inbounds [8192 x i8], [8192 x i8]* %6, i64 0, i64 0
%16 = call i64 @isheader(i8* %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %12
store i32 0, i32* %3
br label %34
19: ; preds = %12
%20 = getelementptr inbounds [8192 x i8], [8192 x i8]* %6, i64 0, i64 0
%21 = call i32 @strlen(i8* %20)
%22 = icmp slt i32 %21, 3
br i1 %22, label %23, label %24
23: ; preds = %19
br label %7
24: ; preds = %19
%25 = getelementptr inbounds [8192 x i8], [8192 x i8]* %6, i64 0, i64 0
%26 = call i64 @islog(i8* %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %32
28: ; preds = %24
%29 = getelementptr inbounds [8192 x i8], [8192 x i8]* %6, i64 0, i64 0
%30 = load %struct.Reg_Log*, %struct.Reg_Log** %5
%31 = call i32 @getlog(i8* %29, %struct.Reg_Log* %30)
store i32 1, i32* %3
br label %34
32: ; preds = %24
br label %7
33: ; preds = %7
store i32 0, i32* %3
br label %34
34: ; preds = %33, %28, %18
%35 = load i32, i32* %3
ret i32 %35
}

LLVM IR (-O2):
%struct.Reg_Log = type { i32 }
define i32 @Get_Next_Log(i32* nocapture %0, %struct.Reg_Log* %1) {
%3 = alloca [8192 x i8]
%4 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 0
%5 = call i64 @fgets(i8* %4, i32 8192, i32* %0)
%6 = icmp eq i64 %5, 0
br i1 %6, label %22, label %7
7: ; preds = %2, %14
%8 = call i32 @trim(i8* %4)
%9 = call i64 @isheader(i8* %4)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %22
11: ; preds = %7
%12 = call i32 @strlen(i8* %4)
%13 = icmp slt i32 %12, 3
br i1 %13, label %14, label %17
14: ; preds = %11, %17
%15 = call i64 @fgets(i8* %4, i32 8192, i32* %0)
%16 = icmp eq i64 %15, 0
br i1 %16, label %22, label %7
17: ; preds = %11
%18 = call i64 @islog(i8* %4)
%19 = icmp eq i64 %18, 0
br i1 %19, label %14, label %20
20: ; preds = %17
%21 = call i32 @getlog(i8* %4, %struct.Reg_Log* %1)
br label %22
22: ; preds = %7, %14, %2, %20
%23 = phi i32 [ 1, %20 ], [ 0, %2 ], [ 0, %14 ], [ 0, %7 ]
ret i32 %23
}