#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__ match_bool(char);
char *Extract_bool(char *exp, char p[]) {
  int i = 0;
  p[i] = *exp;
  exp++;
  i++;
  if (match_bool(*exp) == 0) {
    p[i] = *exp;
    exp++;
    i++;
  }
  p[i] = '\0';
  return exp;
}


x86 assembly (clang, -O0):
<Extract_bool>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%dl
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <match_bool@plt>
cmp    $0x0,%rax
jne    1189 <Extract_bool+0x79>
mov    -0x8(%rbp),%rax
mov    (%rax),%dl
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Extract_bool>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    (%rdi),%al
mov    %al,(%rsi)
movsbl 0x1(%rdi),%edi
call   1030 <match_bool@plt>
test   %rax,%rax
je     1137 <Extract_bool+0x27>
add    $0x1,%rbx
mov    $0x1,%eax
jmp    1147 <Extract_bool+0x37>
mov    0x1(%rbx),%al
mov    %al,0x1(%r14)
add    $0x2,%rbx
mov    $0x2,%eax
movb   $0x0,(%r14,%rax,1)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @Extract_bool(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %5
%6 = load i8*, i8** %3
%7 = load i8, i8* %6
%8 = load i8*, i8** %4
%9 = load i32, i32* %5
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %8, i64 %10
store i8 %7, i8* %11
%12 = load i8*, i8** %3
%13 = getelementptr inbounds i8, i8* %12, i32 1
store i8* %13, i8** %3
%14 = load i32, i32* %5
%15 = add nsw i32 %14, 1
store i32 %15, i32* %5
%16 = load i8*, i8** %3
%17 = load i8, i8* %16
%18 = call i64 @match_bool(i8 signext %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %31
20: ; preds = %2
%21 = load i8*, i8** %3
%22 = load i8, i8* %21
%23 = load i8*, i8** %4
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
store i8 %22, i8* %26
%27 = load i8*, i8** %3
%28 = getelementptr inbounds i8, i8* %27, i32 1
store i8* %28, i8** %3
%29 = load i32, i32* %5
%30 = add nsw i32 %29, 1
store i32 %30, i32* %5
br label %31
31: ; preds = %20, %2
%32 = load i8*, i8** %4
%33 = load i32, i32* %5
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
store i8 0, i8* %35
%36 = load i8*, i8** %3
ret i8* %36
}

LLVM IR (-O2):
define i8* @Extract_bool(i8* %0, i8* nocapture writeonly %1) {
%3 = load i8, i8* %0
store i8 %3, i8* %1
%4 = getelementptr inbounds i8, i8* %0, i64 1
%5 = load i8, i8* %4
%6 = tail call i64 @match_bool(i8 signext %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = load i8, i8* %4
%10 = getelementptr inbounds i8, i8* %1, i64 1
store i8 %9, i8* %10
%11 = getelementptr inbounds i8, i8* %0, i64 2
br label %12
12: ; preds = %8, %2
%13 = phi i8* [ %11, %8 ], [ %4, %2 ]
%14 = phi i64 [ 2, %8 ], [ 1, %2 ]
%15 = getelementptr inbounds i8, i8* %1, i64 %14
store i8 0, i8* %15
ret i8* %13
}