#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 */

/* Variables and functions */
int /*<<< orphan*/ pst_debug(int, char *, char *, char *);
int strlen(char *);
scalar_t__ strncasecmp(char *, char *, int);
int valid_headers(char *header) {
  if (header) {
    if ((strncasecmp(header, "X-Barracuda-URL: ", 17) == 0) ||
        (strncasecmp(header, "X-ASG-Debug-ID: ", 16) == 0) ||
        (strncasecmp(header, "Return-Path: ", 13) == 0) ||
        (strncasecmp(header, "Received: ", 10) == 0) ||
        (strncasecmp(header, "Subject: ", 9) == 0) ||
        (strncasecmp(header, "Date: ", 6) == 0) ||
        (strncasecmp(header, "From: ", 6) == 0) ||
        (strncasecmp(header, "X-x: ", 5) == 0) ||
        (strncasecmp(header, "Microsoft Mail Internet Headers", 31) == 0)) {
      return 1;
    } else {
      if (strlen(header) > 2) {
        pst_debug(1178,
                  "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                  "outputs/2022-01-22/02-19-57/repos/Distrotech/libpst/refs/"
                  "heads/master/src/readpst.c",
                  "Ignore bogus headers = %s\n", header);
      }
      return 0;
    }
  } else
    return 0;
}


x86 assembly (clang, -O0):
<valid_headers>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     12a4 <valid_headers+0x174>
mov    -0x10(%rbp),%rdi
lea    0xeae(%rip),%rsi
mov    $0x11,%edx
call   1050 <strncasecmp@plt>
cmp    $0x0,%rax
je     125e <valid_headers+0x12e>
mov    -0x10(%rbp),%rdi
lea    0xea1(%rip),%rsi
mov    $0x10,%edx
call   1050 <strncasecmp@plt>
cmp    $0x0,%rax
je     125e <valid_headers+0x12e>
mov    -0x10(%rbp),%rdi
lea    0xe93(%rip),%rsi
mov    $0xd,%edx
call   1050 <strncasecmp@plt>
cmp    $0x0,%rax
je     125e <valid_headers+0x12e>
mov    -0x10(%rbp),%rdi
lea    0xe82(%rip),%rsi
mov    $0xa,%edx
call   1050 <strncasecmp@plt>
cmp    $0x0,%rax
je     125e <valid_headers+0x12e>
mov    -0x10(%rbp),%rdi
lea    0xe6e(%rip),%rsi
mov    $0x9,%edx
call   1050 <strncasecmp@plt>
cmp    $0x0,%rax
je     125e <valid_headers+0x12e>
mov    -0x10(%rbp),%rdi
lea    0xe59(%rip),%rsi
mov    $0x6,%edx
call   1050 <strncasecmp@plt>
cmp    $0x0,%rax
je     125e <valid_headers+0x12e>
mov    -0x10(%rbp),%rdi
lea    0xe41(%rip),%rsi
mov    $0x6,%edx
call   1050 <strncasecmp@plt>
cmp    $0x0,%rax
je     125e <valid_headers+0x12e>
mov    -0x10(%rbp),%rdi
lea    0xe29(%rip),%rsi
mov    $0x5,%edx
call   1050 <strncasecmp@plt>
cmp    $0x0,%rax
je     125e <valid_headers+0x12e>
mov    -0x10(%rbp),%rdi
lea    0xe10(%rip),%rsi
mov    $0x1f,%edx
call   1050 <strncasecmp@plt>
cmp    $0x0,%rax
jne    126a <valid_headers+0x13a>
movl   $0x1,-0x4(%rbp)
jmp    12ab <valid_headers+0x17b>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x2,%eax
jle    1298 <valid_headers+0x168>
mov    -0x10(%rbp),%rcx
mov    $0x49a,%edi
lea    0xdee(%rip),%rsi
lea    0xe73(%rip),%rdx
call   1040 <pst_debug@plt>
movl   $0x0,-0x4(%rbp)
jmp    12ab <valid_headers+0x17b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<valid_headers>:
push   %rbp
push   %rbx
push   %rax
test   %rdi,%rdi
je     125e <valid_headers+0x12e>
mov    %rdi,%rbx
lea    0xeba(%rip),%rsi
mov    $0x11,%edx
call   1050 <strncasecmp@plt>
mov    $0x1,%ebp
test   %rax,%rax
je     1260 <valid_headers+0x130>
lea    0xead(%rip),%rsi
mov    %rbx,%rdi
mov    $0x10,%edx
call   1050 <strncasecmp@plt>
test   %rax,%rax
je     1260 <valid_headers+0x130>
lea    0xea1(%rip),%rsi
mov    %rbx,%rdi
mov    $0xd,%edx
call   1050 <strncasecmp@plt>
test   %rax,%rax
je     1260 <valid_headers+0x130>
lea    0xe92(%rip),%rsi
mov    %rbx,%rdi
mov    $0xa,%edx
call   1050 <strncasecmp@plt>
test   %rax,%rax
je     1260 <valid_headers+0x130>
lea    0xe80(%rip),%rsi
mov    %rbx,%rdi
mov    $0x9,%edx
call   1050 <strncasecmp@plt>
test   %rax,%rax
je     1260 <valid_headers+0x130>
lea    0xe6d(%rip),%rsi
mov    %rbx,%rdi
mov    $0x6,%edx
call   1050 <strncasecmp@plt>
test   %rax,%rax
je     1260 <valid_headers+0x130>
lea    0xe5b(%rip),%rsi
mov    %rbx,%rdi
mov    $0x6,%edx
call   1050 <strncasecmp@plt>
test   %rax,%rax
je     1260 <valid_headers+0x130>
lea    0xe49(%rip),%rsi
mov    %rbx,%rdi
mov    $0x5,%edx
call   1050 <strncasecmp@plt>
test   %rax,%rax
je     1260 <valid_headers+0x130>
lea    0xe36(%rip),%rsi
mov    %rbx,%rdi
mov    $0x1f,%edx
call   1050 <strncasecmp@plt>
test   %rax,%rax
je     1260 <valid_headers+0x130>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    $0x3,%eax
jl     125e <valid_headers+0x12e>
lea    0xe30(%rip),%rsi
lea    0xeb5(%rip),%rdx
mov    $0x49a,%edi
mov    %rbx,%rcx
call   1040 <pst_debug@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"X-Barracuda-URL: \00"
@.str.1 = [17 x i8] c"X-ASG-Debug-ID: \00"
@.str.2 = [14 x i8] c"Return-Path: \00"
@.str.3 = [11 x i8] c"Received: \00"
@.str.4 = [10 x i8] c"Subject: \00"
@.str.5 = [7 x i8] c"Date: \00"
@.str.6 = [7 x i8] c"From: \00"
@.str.7 = [6 x i8] c"X-x: \00"
@.str.8 = [32 x i8] c"Microsoft Mail Internet Headers\00"
@.str.9 = [140 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Distrotech/libpst/refs/heads/master/src/readpst.c\00"
@.str.10 = [27 x i8] c"Ignore bogus headers = %s\0A\00"
define i32 @valid_headers(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = icmp ne i8* %4, null
br i1 %5, label %6, label %51
6: ; preds = %1
%7 = load i8*, i8** %3
%8 = call i64 @strncasecmp(i8* %7, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 17)
%9 = icmp eq i64 %8, 0
br i1 %9, label %42, label %10
10: ; preds = %6
%11 = load i8*, i8** %3
%12 = call i64 @strncasecmp(i8* %11, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 16)
%13 = icmp eq i64 %12, 0
br i1 %13, label %42, label %14
14: ; preds = %10
%15 = load i8*, i8** %3
%16 = call i64 @strncasecmp(i8* %15, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 13)
%17 = icmp eq i64 %16, 0
br i1 %17, label %42, label %18
18: ; preds = %14
%19 = load i8*, i8** %3
%20 = call i64 @strncasecmp(i8* %19, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 10)
%21 = icmp eq i64 %20, 0
br i1 %21, label %42, label %22
22: ; preds = %18
%23 = load i8*, i8** %3
%24 = call i64 @strncasecmp(i8* %23, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 9)
%25 = icmp eq i64 %24, 0
br i1 %25, label %42, label %26
26: ; preds = %22
%27 = load i8*, i8** %3
%28 = call i64 @strncasecmp(i8* %27, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 6)
%29 = icmp eq i64 %28, 0
br i1 %29, label %42, label %30
30: ; preds = %26
%31 = load i8*, i8** %3
%32 = call i64 @strncasecmp(i8* %31, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 6)
%33 = icmp eq i64 %32, 0
br i1 %33, label %42, label %34
34: ; preds = %30
%35 = load i8*, i8** %3
%36 = call i64 @strncasecmp(i8* %35, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i32 5)
%37 = icmp eq i64 %36, 0
br i1 %37, label %42, label %38
38: ; preds = %34
%39 = load i8*, i8** %3
%40 = call i64 @strncasecmp(i8* %39, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0), i32 31)
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %43
42: ; preds = %38, %34, %30, %26, %22, %18, %14, %10, %6
store i32 1, i32* %2
br label %52
43: ; preds = %38
%44 = load i8*, i8** %3
%45 = call i32 @strlen(i8* %44)
%46 = icmp sgt i32 %45, 2
br i1 %46, label %47, label %50
47: ; preds = %43
%48 = load i8*, i8** %3
%49 = call i32 @pst_debug(i32 1178, i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0), i8* %48)
br label %50
50: ; preds = %47, %43
store i32 0, i32* %2
br label %52
51: ; preds = %1
store i32 0, i32* %2
br label %52
52: ; preds = %51, %50, %42
%53 = load i32, i32* %2
ret i32 %53
}

LLVM IR (-O2):
@.str = [18 x i8] c"X-Barracuda-URL: \00"
@.str.1 = [17 x i8] c"X-ASG-Debug-ID: \00"
@.str.2 = [14 x i8] c"Return-Path: \00"
@.str.3 = [11 x i8] c"Received: \00"
@.str.4 = [10 x i8] c"Subject: \00"
@.str.5 = [7 x i8] c"Date: \00"
@.str.6 = [7 x i8] c"From: \00"
@.str.7 = [6 x i8] c"X-x: \00"
@.str.8 = [32 x i8] c"Microsoft Mail Internet Headers\00"
@.str.9 = [140 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Distrotech/libpst/refs/heads/master/src/readpst.c\00"
@.str.10 = [27 x i8] c"Ignore bogus headers = %s\0A\00"
define i32 @valid_headers(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %35, label %3
3: ; preds = %1
%4 = tail call i64 @strncasecmp(i8* %0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 17)
%5 = icmp eq i64 %4, 0
br i1 %5, label %35, label %6
6: ; preds = %3
%7 = tail call i64 @strncasecmp(i8* %0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 16)
%8 = icmp eq i64 %7, 0
br i1 %8, label %35, label %9
9: ; preds = %6
%10 = tail call i64 @strncasecmp(i8* %0, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 13)
%11 = icmp eq i64 %10, 0
br i1 %11, label %35, label %12
12: ; preds = %9
%13 = tail call i64 @strncasecmp(i8* %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 10)
%14 = icmp eq i64 %13, 0
br i1 %14, label %35, label %15
15: ; preds = %12
%16 = tail call i64 @strncasecmp(i8* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 9)
%17 = icmp eq i64 %16, 0
br i1 %17, label %35, label %18
18: ; preds = %15
%19 = tail call i64 @strncasecmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 6)
%20 = icmp eq i64 %19, 0
br i1 %20, label %35, label %21
21: ; preds = %18
%22 = tail call i64 @strncasecmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 6)
%23 = icmp eq i64 %22, 0
br i1 %23, label %35, label %24
24: ; preds = %21
%25 = tail call i64 @strncasecmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i32 5)
%26 = icmp eq i64 %25, 0
br i1 %26, label %35, label %27
27: ; preds = %24
%28 = tail call i64 @strncasecmp(i8* %0, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0), i32 31)
%29 = icmp eq i64 %28, 0
br i1 %29, label %35, label %30
30: ; preds = %27
%31 = tail call i32 @strlen(i8* %0)
%32 = icmp sgt i32 %31, 2
br i1 %32, label %33, label %35
33: ; preds = %30
%34 = tail call i32 @pst_debug(i32 1178, i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0), i8* %0)
br label %35
35: ; preds = %1, %30, %33, %3, %6, %9, %12, %15, %18, %21, %24, %27
%36 = phi i32 [ 1, %27 ], [ 1, %24 ], [ 1, %21 ], [ 1, %18 ], [ 1, %15 ], [ 1, %12 ], [ 1, %9 ], [ 1, %6 ], [ 1, %3 ], [ 0, %33 ], [ 0, %30 ], [ 0, %1 ]
ret i32 %36
}