#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 *strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char *);
void imc_fits_extract_string(char *fl, char *s) {
  char *cp1, *cp2, *cp3, *cp;
  cp1 = strchr(fl, '\'');
  if (cp1 != NULL) {
    cp2 = strchr(cp1 + 1, '\'');
    while (cp2 != NULL) {
      cp3 = strchr(cp2 + 1, '\'');
      if (cp3 == NULL) {
        *cp2 = '\0';
        cp2 = NULL;
      } else {
        cp2++;
        if (cp3 == cp2) {
          for (; *cp3 != '\0'; cp3++)
            *(cp3) = *(cp3 + 1);
        }
      }
    }
    cp = cp1 + 1;
  } else
    cp = fl;
  (void)strcpy(s, cp);
  return;
}


x86 assembly (clang, -O0):
<imc_fits_extract_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x27,%esi
call   1040 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1210 <imc_fits_extract_string+0xf0>
mov    -0x18(%rbp),%rdi
add    $0x1,%rdi
mov    $0x27,%esi
call   1040 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11ff <imc_fits_extract_string+0xdf>
mov    -0x20(%rbp),%rdi
add    $0x1,%rdi
mov    $0x27,%esi
call   1040 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11a3 <imc_fits_extract_string+0x83>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
movq   $0x0,-0x20(%rbp)
jmp    11fa <imc_fits_extract_string+0xda>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
jne    11f5 <imc_fits_extract_string+0xd5>
jmp    11c2 <imc_fits_extract_string+0xa2>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11f0 <imc_fits_extract_string+0xd0>
mov    -0x28(%rbp),%rax
mov    0x1(%rax),%cl
mov    -0x28(%rbp),%rax
mov    %cl,(%rax)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    11c2 <imc_fits_extract_string+0xa2>
jmp    11f5 <imc_fits_extract_string+0xd5>
jmp    11fa <imc_fits_extract_string+0xda>
jmp    1163 <imc_fits_extract_string+0x43>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1218 <imc_fits_extract_string+0xf8>
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1030 <strcpy@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<imc_fits_extract_string>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x27,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     11c8 <imc_fits_extract_string+0xa8>
mov    %rax,%r15
add    $0x1,%r15
mov    %r15,%rdi
mov    $0x27,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     11c5 <imc_fits_extract_string+0xa5>
mov    %rax,%r12
lea    0x1(%rax),%r13
mov    %r13,%rdi
mov    $0x27,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     11c0 <imc_fits_extract_string+0xa0>
add    $0x2,%r12
mov    %r12,%rbx
jmp    119b <imc_fits_extract_string+0x7b>
nopl   (%rax)
lea    0x1(%r12),%r13
mov    %r13,%rdi
mov    $0x27,%esi
call   1040 <strchr@plt>
add    $0x1,%rbx
test   %rax,%rax
je     11c0 <imc_fits_extract_string+0xa0>
mov    %r13,%r12
cmp    %r13,%rax
jne    1180 <imc_fits_extract_string+0x60>
cmpb   $0x0,(%r12)
je     1180 <imc_fits_extract_string+0x60>
mov    %rbx,%rax
nopl   (%rax)
movzbl (%rax),%ecx
mov    %cl,-0x1(%rax)
add    $0x1,%rax
test   %cl,%cl
jne    11b0 <imc_fits_extract_string+0x90>
jmp    1180 <imc_fits_extract_string+0x60>
movb   $0x0,(%r12)
mov    %r15,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <strcpy@plt>

LLVM IR (-O0):
define void @imc_fits_extract_string(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%9 = load i8*, i8** %3
%10 = call i8* @strchr(i8* %9, i8 signext 39)
store i8* %10, i8** %5
%11 = load i8*, i8** %5
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %54
13: ; preds = %2
%14 = load i8*, i8** %5
%15 = getelementptr inbounds i8, i8* %14, i64 1
%16 = call i8* @strchr(i8* %15, i8 signext 39)
store i8* %16, i8** %6
br label %17
17: ; preds = %50, %13
%18 = load i8*, i8** %6
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %51
20: ; preds = %17
%21 = load i8*, i8** %6
%22 = getelementptr inbounds i8, i8* %21, i64 1
%23 = call i8* @strchr(i8* %22, i8 signext 39)
store i8* %23, i8** %7
%24 = load i8*, i8** %7
%25 = icmp eq i8* %24, null
br i1 %25, label %26, label %28
26: ; preds = %20
%27 = load i8*, i8** %6
store i8 0, i8* %27
store i8* null, i8** %6
br label %50
28: ; preds = %20
%29 = load i8*, i8** %6
%30 = getelementptr inbounds i8, i8* %29, i32 1
store i8* %30, i8** %6
%31 = load i8*, i8** %7
%32 = load i8*, i8** %6
%33 = icmp eq i8* %31, %32
br i1 %33, label %34, label %49
34: ; preds = %28
br label %35
35: ; preds = %45, %34
%36 = load i8*, i8** %7
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %48
40: ; preds = %35
%41 = load i8*, i8** %7
%42 = getelementptr inbounds i8, i8* %41, i64 1
%43 = load i8, i8* %42
%44 = load i8*, i8** %7
store i8 %43, i8* %44
br label %45
45: ; preds = %40
%46 = load i8*, i8** %7
%47 = getelementptr inbounds i8, i8* %46, i32 1
store i8* %47, i8** %7
br label %35
48: ; preds = %35
br label %49
49: ; preds = %48, %28
br label %50
50: ; preds = %49, %26
br label %17
51: ; preds = %17
%52 = load i8*, i8** %5
%53 = getelementptr inbounds i8, i8* %52, i64 1
store i8* %53, i8** %8
br label %56
54: ; preds = %2
%55 = load i8*, i8** %3
store i8* %55, i8** %8
br label %56
56: ; preds = %54, %51
%57 = load i8*, i8** %4
%58 = load i8*, i8** %8
%59 = call i32 @strcpy(i8* %57, i8* %58)
ret void
}

LLVM IR (-O2):
define void @imc_fits_extract_string(i8* %0, i8* %1) {
%3 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 39)
%4 = icmp eq i8* %3, null
br i1 %4, label %31, label %5
5: ; preds = %2
%6 = getelementptr inbounds i8, i8* %3, i64 1
%7 = tail call i8* @strchr(i8* %6, i8 signext 39)
%8 = icmp eq i8* %7, null
br i1 %8, label %31, label %9
9: ; preds = %5
%10 = getelementptr inbounds i8, i8* %7, i64 1
%11 = tail call i8* @strchr(i8* %10, i8 signext 39)
%12 = icmp eq i8* %11, null
br i1 %12, label %29, label %13
13: ; preds = %9, %25
%14 = phi i8* [ %27, %25 ], [ %11, %9 ]
%15 = phi i8* [ %26, %25 ], [ %10, %9 ]
%16 = icmp eq i8* %14, %15
br i1 %16, label %17, label %25
17: ; preds = %13
%18 = load i8, i8* %15
%19 = icmp eq i8 %18, 0
br i1 %19, label %25, label %20
20: ; preds = %17, %20
%21 = phi i8* [ %22, %20 ], [ %15, %17 ]
%22 = getelementptr inbounds i8, i8* %21, i64 1
%23 = load i8, i8* %22
store i8 %23, i8* %21
%24 = icmp eq i8 %23, 0
br i1 %24, label %25, label %20
25: ; preds = %20, %17, %13
%26 = getelementptr inbounds i8, i8* %15, i64 1
%27 = tail call i8* @strchr(i8* %26, i8 signext 39)
%28 = icmp eq i8* %27, null
br i1 %28, label %29, label %13
29: ; preds = %25, %9
%30 = phi i8* [ %7, %9 ], [ %15, %25 ]
store i8 0, i8* %30
br label %31
31: ; preds = %29, %5, %2
%32 = phi i8* [ %0, %2 ], [ %6, %5 ], [ %6, %29 ]
%33 = tail call i32 @strcpy(i8* %1, i8* %32)
ret void
}