#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 */
scalar_t__ my_stristr(char *, char *);
int /*<<< orphan*/ pst_debug(int, char *, char *, ...);
int /*<<< orphan*/ pst_debug_func(char *);
int /*<<< orphan*/ pst_debug_func_ret();
scalar_t__ strlen(char *);
scalar_t__ strncasecmp(char *, char *, scalar_t__);
void header_has_field(char *header, char *field, int *flag) {
  {
    pst_debug_func("header_has_field");
    pst_debug(1189,
              "/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",
              "Entering function\n");
  };
  if (my_stristr(header, field) ||
      (strncasecmp(header, field + 1, strlen(field) - 1) == 0)) {
    pst_debug(1191,
              "/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",
              "header block has %s header\n", field + 1);
    *flag = 1;
  }
  {
    pst_debug(1194,
              "/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",
              "Leaving function\n");
    pst_debug_func_ret();
  };
}


x86 assembly (clang, -O0):
<header_has_field>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    0xe85(%rip),%rdi
call   1070 <pst_debug_func@plt>
mov    $0x4a5,%edi
lea    0xe85(%rip),%rsi
lea    0xf0a(%rip),%rdx
mov    $0x0,%al
call   1040 <pst_debug@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <my_stristr@plt>
cmp    $0x0,%rax
jne    11ec <header_has_field+0x8c>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    %rax,%rdx
sub    $0x1,%rdx
call   1050 <strncasecmp@plt>
cmp    $0x0,%rax
jne    1218 <header_has_field+0xb8>
mov    -0x10(%rbp),%rcx
add    $0x1,%rcx
mov    $0x4a7,%edi
lea    0xe11(%rip),%rsi
lea    0xea9(%rip),%rdx
mov    $0x0,%al
call   1040 <pst_debug@plt>
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
mov    $0x4aa,%edi
lea    0xded(%rip),%rsi
lea    0xea1(%rip),%rdx
mov    $0x0,%al
call   1040 <pst_debug@plt>
mov    $0x0,%al
call   1080 <pst_debug_func_ret@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<header_has_field>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
lea    0xe88(%rip),%rdi
call   1070 <pst_debug_func@plt>
lea    0xe8d(%rip),%rsi
lea    0xf12(%rip),%rdx
mov    $0x4a5,%edi
xor    %eax,%eax
call   1040 <pst_debug@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <my_stristr@plt>
test   %rax,%rax
jne    11c7 <header_has_field+0x67>
lea    0x1(%rbx),%r12
mov    %rbx,%rdi
call   1030 <strlen@plt>
lea    -0x1(%rax),%rdx
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <strncasecmp@plt>
test   %rax,%rax
jne    11ef <header_has_field+0x8f>
add    $0x1,%rbx
lea    0xe3f(%rip),%rsi
lea    0xed7(%rip),%rdx
mov    $0x4a7,%edi
mov    %rbx,%rcx
xor    %eax,%eax
call   1040 <pst_debug@plt>
movl   $0x1,(%r14)
lea    0xe1b(%rip),%rsi
lea    0xecf(%rip),%rdx
mov    $0x4aa,%edi
xor    %eax,%eax
call   1040 <pst_debug@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1080 <pst_debug_func_ret@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"header_has_field\00"
@.str.1 = [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.2 = [19 x i8] c"Entering function\0A\00"
@.str.3 = [28 x i8] c"header block has %s header\0A\00"
@.str.4 = [18 x i8] c"Leaving function\0A\00"
define void @header_has_field(i8* %0, i8* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32* %2, i32** %6
%7 = call i32 @pst_debug_func(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i32, i8*, i8*, ...) @pst_debug(i32 1189, i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%9 = load i8*, i8** %4
%10 = load i8*, i8** %5
%11 = call i64 @my_stristr(i8* %9, i8* %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %22, label %13
13: ; preds = %3
%14 = load i8*, i8** %4
%15 = load i8*, i8** %5
%16 = getelementptr inbounds i8, i8* %15, i64 1
%17 = load i8*, i8** %5
%18 = call i64 @strlen(i8* %17)
%19 = sub nsw i64 %18, 1
%20 = call i64 @strncasecmp(i8* %14, i8* %16, i64 %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %13, %3
%23 = load i8*, i8** %5
%24 = getelementptr inbounds i8, i8* %23, i64 1
%25 = call i32 (i32, i8*, i8*, ...) @pst_debug(i32 1191, i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* %24)
%26 = load i32*, i32** %6
store i32 1, i32* %26
br label %27
27: ; preds = %22, %13
%28 = call i32 (i32, i8*, i8*, ...) @pst_debug(i32 1194, i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%29 = call i32 (...) @pst_debug_func_ret()
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"header_has_field\00"
@.str.1 = [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.2 = [19 x i8] c"Entering function\0A\00"
@.str.3 = [28 x i8] c"header block has %s header\0A\00"
@.str.4 = [18 x i8] c"Leaving function\0A\00"
define void @header_has_field(i8* %0, i8* %1, i32* nocapture writeonly %2) {
%4 = tail call i32 @pst_debug_func(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 (i32, i8*, i8*, ...) @pst_debug(i32 1189, i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%6 = tail call i64 @my_stristr(i8* %0, i8* %1)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %14
8: ; preds = %3
%9 = getelementptr inbounds i8, i8* %1, i64 1
%10 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%11 = add nsw i64 %10, -1
%12 = tail call i64 @strncasecmp(i8* %0, i8* %9, i64 %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %8, %3
%15 = getelementptr inbounds i8, i8* %1, i64 1
%16 = tail call i32 (i32, i8*, i8*, ...) @pst_debug(i32 1191, i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* %15)
store i32 1, i32* %2
br label %17
17: ; preds = %14, %8
%18 = tail call i32 (i32, i8*, i8*, ...) @pst_debug(i32 1194, i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%19 = tail call i32 (...) @pst_debug_func_ret()
ret void
}