#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 */
char *safestrdup(char *, char *, int);
int safestrlen(char const *);
char *safestrpbrk(char *, char const *);
char *strstr(char *, char const *);
char *Find_str_in_flat(char *str, const char *key, const char *sep) {
  char *s, *end;
  int n, c = 0;
  if (str == 0 || key == 0 || sep == 0)
    return (0);
  n = safestrlen(key);
  for (s = str; (s = strstr(s, key));) {
    s += n;
    if (*s == '=') {
      ++s;
      if ((end = safestrpbrk(s, sep))) {
        c = *end;
        *end = c;
      }
      s = safestrdup(s,
                     "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                     "outputs/2022-01-22/02-19-57/repos/AndreyPopovNew/"
                     "asuswrt-merlin-rt-n/refs/heads/374.43_2-update/release/"
                     "src/router/LPRng/src/common/linelist.c",
                     730);
      if (end)
        *end = c;
      return (s);
    }
  }
  return (0);
}


x86 assembly (clang, -O0):
<Find_str_in_flat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x0,-0x38(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     117c <Find_str_in_flat+0x3c>
cmpq   $0x0,-0x18(%rbp)
je     117c <Find_str_in_flat+0x3c>
cmpq   $0x0,-0x20(%rbp)
jne    1189 <Find_str_in_flat+0x49>
movq   $0x0,-0x8(%rbp)
jmp    125e <Find_str_in_flat+0x11e>
mov    -0x18(%rbp),%rdi
call   1040 <safestrlen@plt>
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <strstr@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     1256 <Find_str_in_flat+0x116>
mov    -0x34(%rbp),%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3d,%eax
jne    1251 <Find_str_in_flat+0x111>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <safestrpbrk@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     1215 <Find_str_in_flat+0xd5>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
mov    %al,%cl
mov    -0x30(%rbp),%rax
mov    %cl,(%rax)
mov    -0x28(%rbp),%rdi
lea    0xde0(%rip),%rsi
mov    $0x2da,%edx
call   1030 <safestrdup@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     1244 <Find_str_in_flat+0x104>
mov    -0x38(%rbp),%eax
mov    %al,%cl
mov    -0x30(%rbp),%rax
mov    %cl,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    125e <Find_str_in_flat+0x11e>
jmp    119d <Find_str_in_flat+0x5d>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Find_str_in_flat>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %rdi,%rdi
je     11c0 <Find_str_in_flat+0x80>
mov    %rsi,%r15
test   %rsi,%rsi
je     11c0 <Find_str_in_flat+0x80>
mov    %rdx,%r14
test   %rdx,%rdx
je     11c0 <Find_str_in_flat+0x80>
mov    %rdi,%rbx
mov    %r15,%rdi
call   1040 <safestrlen@plt>
movslq %eax,%r12
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <strstr@plt>
test   %rax,%rax
je     11c0 <Find_str_in_flat+0x80>
mov    %rax,%rbx
add    %r12,%rbx
cmpb   $0x3d,(%rax,%r12,1)
jne    1170 <Find_str_in_flat+0x30>
add    $0x1,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <safestrpbrk@plt>
test   %rax,%rax
je     11cb <Find_str_in_flat+0x8b>
mov    %rax,%r14
mov    (%rax),%bpl
lea    0xe52(%rip),%rsi
mov    %rbx,%rdi
mov    $0x2da,%edx
call   1030 <safestrdup@plt>
mov    %bpl,(%r14)
jmp    11c2 <Find_str_in_flat+0x82>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe2e(%rip),%rsi
mov    %rbx,%rdi
mov    $0x2da,%edx
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <safestrdup@plt>

LLVM IR (-O0):
@.str = [199 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/AndreyPopovNew/asuswrt-merlin-rt-n/refs/heads/374.43_2-update/release/src/router/LPRng/src/common/linelist.c\00"
define i8* @Find_str_in_flat(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 0, i32* %11
%12 = load i8*, i8** %5
%13 = icmp eq i8* %12, null
br i1 %13, label %20, label %14
14: ; preds = %3
%15 = load i8*, i8** %6
%16 = icmp eq i8* %15, null
br i1 %16, label %20, label %17
17: ; preds = %14
%18 = load i8*, i8** %7
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %21
20: ; preds = %17, %14, %3
store i8* null, i8** %4
br label %66
21: ; preds = %17
%22 = load i8*, i8** %6
%23 = call i32 @safestrlen(i8* %22)
store i32 %23, i32* %10
%24 = load i8*, i8** %5
store i8* %24, i8** %8
br label %25
25: ; preds = %64, %21
%26 = load i8*, i8** %8
%27 = load i8*, i8** %6
%28 = call i8* @strstr(i8* %26, i8* %27)
store i8* %28, i8** %8
%29 = icmp ne i8* %28, null
br i1 %29, label %30, label %65
30: ; preds = %25
%31 = load i32, i32* %10
%32 = load i8*, i8** %8
%33 = sext i32 %31 to i64
%34 = getelementptr inbounds i8, i8* %32, i64 %33
store i8* %34, i8** %8
%35 = load i8*, i8** %8
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %37, 61
br i1 %38, label %39, label %64
39: ; preds = %30
%40 = load i8*, i8** %8
%41 = getelementptr inbounds i8, i8* %40, i32 1
store i8* %41, i8** %8
%42 = load i8*, i8** %8
%43 = load i8*, i8** %7
%44 = call i8* @safestrpbrk(i8* %42, i8* %43)
store i8* %44, i8** %9
%45 = icmp ne i8* %44, null
br i1 %45, label %46, label %53
46: ; preds = %39
%47 = load i8*, i8** %9
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
store i32 %49, i32* %11
%50 = load i32, i32* %11
%51 = trunc i32 %50 to i8
%52 = load i8*, i8** %9
store i8 %51, i8* %52
br label %53
53: ; preds = %46, %39
%54 = load i8*, i8** %8
%55 = call i8* @safestrdup(i8* %54, i8* getelementptr inbounds ([199 x i8], [199 x i8]* @.str, i64 0, i64 0), i32 730)
store i8* %55, i8** %8
%56 = load i8*, i8** %9
%57 = icmp ne i8* %56, null
br i1 %57, label %58, label %62
58: ; preds = %53
%59 = load i32, i32* %11
%60 = trunc i32 %59 to i8
%61 = load i8*, i8** %9
store i8 %60, i8* %61
br label %62
62: ; preds = %58, %53
%63 = load i8*, i8** %8
store i8* %63, i8** %4
br label %66
64: ; preds = %30
br label %25
65: ; preds = %25
store i8* null, i8** %4
br label %66
66: ; preds = %65, %62, %20
%67 = load i8*, i8** %4
ret i8* %67
}

LLVM IR (-O2):
@.str = [199 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/AndreyPopovNew/asuswrt-merlin-rt-n/refs/heads/374.43_2-update/release/src/router/LPRng/src/common/linelist.c\00"
define i8* @Find_str_in_flat(i8* %0, i8* %1, i8* %2) {
%4 = icmp eq i8* %0, null
%5 = icmp eq i8* %1, null
%6 = or i1 %4, %5
%7 = icmp eq i8* %2, null
%8 = or i1 %6, %7
br i1 %8, label %29, label %9
9: ; preds = %3
%10 = tail call i32 @safestrlen(i8* %1)
%11 = sext i32 %10 to i64
br label %12
12: ; preds = %16, %9
%13 = phi i8* [ %0, %9 ], [ %17, %16 ]
%14 = tail call i8* @strstr(i8* dereferenceable(1) %13, i8* dereferenceable(1) %1)
%15 = icmp eq i8* %14, null
br i1 %15, label %29, label %16
16: ; preds = %12
%17 = getelementptr inbounds i8, i8* %14, i64 %11
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 61
br i1 %19, label %20, label %12
20: ; preds = %16
%21 = getelementptr inbounds i8, i8* %17, i64 1
%22 = tail call i8* @safestrpbrk(i8* %21, i8* %2)
%23 = icmp eq i8* %22, null
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = tail call i8* @safestrdup(i8* %21, i8* getelementptr inbounds ([199 x i8], [199 x i8]* @.str, i64 0, i64 0), i32 730)
br label %29
26: ; preds = %20
%27 = load i8, i8* %22
%28 = tail call i8* @safestrdup(i8* %21, i8* getelementptr inbounds ([199 x i8], [199 x i8]* @.str, i64 0, i64 0), i32 730)
store i8 %27, i8* %22
br label %29
29: ; preds = %12, %24, %26, %3
%30 = phi i8* [ null, %3 ], [ %28, %26 ], [ %25, %24 ], [ null, %12 ]
ret i8* %30
}