#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
char *strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *strstr(char *, char *);
char strCmpPrefixAndCopy(char *line, char *str, char *outName) {
  char *pos, *pPreLine;
  pPreLine = line;
  pos = strstr(line, str);
  if (pos == NULL)
    return 0;
  line = pos + strlen(str);
  strcpy(outName, line);
  pos = strchr(outName, ']');
  if (pos == NULL) {
    fprintf(stderr, "Error encountered in line: [%s]", pPreLine);
    exit(-1);
  }
  *pos = 0;
  return 1;
}


x86 assembly (clang, -O0):
<strCmpPrefixAndCopy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1080 <strstr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11a1 <strCmpPrefixAndCopy+0x41>
movb   $0x0,-0x1(%rbp)
jmp    121a <strCmpPrefixAndCopy+0xba>
mov    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x20(%rbp),%rdi
mov    $0x5d,%esi
call   1050 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    120f <strCmpPrefixAndCopy+0xaf>
mov    0x2ded(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%rdx
lea    0xe00(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
movb   $0x1,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strCmpPrefixAndCopy>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%r14
call   1080 <strstr@plt>
test   %rax,%rax
je     11af <strCmpPrefixAndCopy+0x4f>
mov    %rax,%rbx
mov    %r12,%rdi
call   1040 <strlen@plt>
cltq
add    %rax,%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %r15,%rdi
mov    $0x5d,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     11bd <strCmpPrefixAndCopy+0x5d>
movb   $0x0,(%rax)
mov    $0x1,%al
jmp    11b1 <strCmpPrefixAndCopy+0x51>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    0x2e1c(%rip),%rax
mov    (%rax),%edi
lea    0xe33(%rip),%rsi
mov    %r14,%rdx
call   1060 <fprintf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [32 x i8] c"Error encountered in line: [%s]\00"
define signext i8 @strCmpPrefixAndCopy(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%10 = load i8*, i8** %5
store i8* %10, i8** %9
%11 = load i8*, i8** %5
%12 = load i8*, i8** %6
%13 = call i8* @strstr(i8* %11, i8* %12)
store i8* %13, i8** %8
%14 = load i8*, i8** %8
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %17
16: ; preds = %3
store i8 0, i8* %4
br label %37
17: ; preds = %3
%18 = load i8*, i8** %8
%19 = load i8*, i8** %6
%20 = call i32 @strlen(i8* %19)
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %18, i64 %21
store i8* %22, i8** %5
%23 = load i8*, i8** %7
%24 = load i8*, i8** %5
%25 = call i32 @strcpy(i8* %23, i8* %24)
%26 = load i8*, i8** %7
%27 = call i8* @strchr(i8* %26, i8 signext 93)
store i8* %27, i8** %8
%28 = load i8*, i8** %8
%29 = icmp eq i8* %28, null
br i1 %29, label %30, label %35
30: ; preds = %17
%31 = load i32, i32* @stderr
%32 = load i8*, i8** %9
%33 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %32)
%34 = call i32 @exit(i32 -1)
unreachable
35: ; preds = %17
%36 = load i8*, i8** %8
store i8 0, i8* %36
store i8 1, i8* %4
br label %37
37: ; preds = %35, %16
%38 = load i8, i8* %4
ret i8 %38
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [32 x i8] c"Error encountered in line: [%s]\00"
define signext i8 @strCmpPrefixAndCopy(i8* %0, i8* %1, i8* %2) {
%4 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) %1)
%5 = icmp eq i8* %4, null
br i1 %5, label %18, label %6
6: ; preds = %3
%7 = tail call i32 @strlen(i8* %1)
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %4, i64 %8
%10 = tail call i32 @strcpy(i8* %2, i8* %9)
%11 = tail call i8* @strchr(i8* dereferenceable(1) %2, i8 signext 93)
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %17
13: ; preds = %6
%14 = load i32, i32* @stderr
%15 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %0)
%16 = tail call i32 @exit(i32 -1)
unreachable
17: ; preds = %6
store i8 0, i8* %11
br label %18
18: ; preds = %3, %17
%19 = phi i8 [ 1, %17 ], [ 0, %3 ]
ret i8 %19
}