#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*/ memcmp(char *, char *, unsigned int);
int /*<<< orphan*/ sprintf(char *, char *, char *);
unsigned int strlen(char *);
int FindLineSection(char ln[], char section[]) {
  unsigned int pnt, len;
  char cmp[256];
  sprintf(cmp, "[%s]", section);
  len = (int)strlen(cmp);
  pnt = 0;
  while (len + pnt < strlen(ln)) {
    if (!memcmp(ln + pnt, cmp, len))
      return (pnt + len);
    pnt++;
  }
  return (-1);
}


x86 assembly (clang, -O0):
<FindLineSection>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x120(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xeab(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x120(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x124(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x124(%rbp),%eax
cmp    %ecx,%eax
jae    11d3 <FindLineSection+0xa3>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%eax
add    %rax,%rdi
lea    -0x120(%rbp),%rsi
mov    -0x20(%rbp),%edx
call   1040 <memcmp@plt>
cmp    $0x0,%eax
jne    11c5 <FindLineSection+0x95>
mov    -0x1c(%rbp),%eax
add    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11da <FindLineSection+0xaa>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1170 <FindLineSection+0x40>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FindLineSection>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x100,%rsp
mov    %rsi,%rdx
mov    %rdi,%r14
lea    0xeb4(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1050 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%r15d
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    %eax,%r15d
jae    11b7 <FindLineSection+0x87>
mov    %rsp,%rsi
mov    %r14,%rdi
mov    %r15d,%edx
call   1040 <memcmp@plt>
test   %eax,%eax
je     11be <FindLineSection+0x8e>
lea    0x1(%r14),%rbx
mov    %rsp,%r12
mov    %r15d,%ebp
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebp
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    %eax,%ebp
jae    11b7 <FindLineSection+0x87>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r15d,%edx
call   1040 <memcmp@plt>
add    $0x1,%rbx
test   %eax,%eax
jne    1190 <FindLineSection+0x60>
jmp    11c1 <FindLineSection+0x91>
mov    $0xffffffff,%ebp
jmp    11c1 <FindLineSection+0x91>
mov    %r15d,%ebp
mov    %ebp,%eax
add    $0x100,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"[%s]\00"
define i32 @FindLineSection(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca [256 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%10 = load i8*, i8** %5
%11 = call i32 @sprintf(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%13 = call i32 @strlen(i8* %12)
store i32 %13, i32* %7
store i32 0, i32* %6
br label %14
14: ; preds = %34, %2
%15 = load i32, i32* %7
%16 = load i32, i32* %6
%17 = add i32 %15, %16
%18 = load i8*, i8** %4
%19 = call i32 @strlen(i8* %18)
%20 = icmp ult i32 %17, %19
br i1 %20, label %21, label %37
21: ; preds = %14
%22 = load i8*, i8** %4
%23 = load i32, i32* %6
%24 = zext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%27 = load i32, i32* %7
%28 = call i32 @memcmp(i8* %25, i8* %26, i32 %27)
%29 = icmp ne i32 %28, 0
br i1 %29, label %34, label %30
30: ; preds = %21
%31 = load i32, i32* %6
%32 = load i32, i32* %7
%33 = add i32 %31, %32
store i32 %33, i32* %3
br label %38
34: ; preds = %21
%35 = load i32, i32* %6
%36 = add i32 %35, 1
store i32 %36, i32* %6
br label %14
37: ; preds = %14
store i32 -1, i32* %3
br label %38
38: ; preds = %37, %30
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
@.str = [5 x i8] c"[%s]\00"
define i32 @FindLineSection(i8* %0, i8* %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %1)
%6 = call i32 @strlen(i8* %4)
%7 = call i32 @strlen(i8* %0)
%8 = icmp ult i32 %6, %7
br i1 %8, label %9, label %23
9: ; preds = %2
%10 = call i32 @memcmp(i8* %0, i8* %4, i32 %6)
%11 = icmp eq i32 %10, 0
br i1 %11, label %23, label %12
12: ; preds = %9, %18
%13 = phi i64 [ %22, %18 ], [ 1, %9 ]
%14 = trunc i64 %13 to i32
%15 = add i32 %6, %14
%16 = call i32 @strlen(i8* %0)
%17 = icmp ult i32 %15, %16
br i1 %17, label %18, label %23
18: ; preds = %12
%19 = getelementptr inbounds i8, i8* %0, i64 %13
%20 = call i32 @memcmp(i8* %19, i8* %4, i32 %6)
%21 = icmp eq i32 %20, 0
%22 = add nuw nsw i64 %13, 1
br i1 %21, label %23, label %12
23: ; preds = %12, %18, %9, %2
%24 = phi i32 [ -1, %2 ], [ %6, %9 ], [ %15, %18 ], [ -1, %12 ]
ret i32 %24
}