#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*/ m_remove(int, int /*<<< orphan*/, int);
scalar_t__ match(int, int *, char *, int *);
int s_new();
int s_prefix(int m, char *pref) {
  if (!m)
    m = s_new();
  int res = 0;
  int pos = 0;
  while (match(m, &res, pref, &pos) == 0)
    if (!pref[pos]) {
      m_remove(m, 0, res);
      break;
    }
  return m;
}


x86 assembly (clang, -O0):
<s_prefix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1153 <s_prefix+0x23>
mov    $0x0,%al
call   1030 <s_new@plt>
mov    %eax,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rdx
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rcx
call   1050 <match@plt>
cmp    $0x0,%rax
jne    11a8 <s_prefix+0x78>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
jne    11a3 <s_prefix+0x73>
mov    -0x4(%rbp),%edi
mov    -0x14(%rbp),%edx
xor    %esi,%esi
call   1040 <m_remove@plt>
jmp    11a8 <s_prefix+0x78>
jmp    1161 <s_prefix+0x31>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<s_prefix>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
test   %edi,%edi
jne    1149 <s_prefix+0x19>
xor    %eax,%eax
call   1030 <s_new@plt>
mov    %eax,%ebp
movl   $0x0,0x4(%rsp)
movl   $0x0,(%rsp)
lea    0x4(%rsp),%r14
mov    %rsp,%r15
mov    %ebp,%edi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %r15,%rcx
call   1050 <match@plt>
test   %rax,%rax
jne    118c <s_prefix+0x5c>
movslq (%rsp),%rax
cmpb   $0x0,(%rbx,%rax,1)
jne    1160 <s_prefix+0x30>
mov    0x4(%rsp),%edx
mov    %ebp,%edi
xor    %esi,%esi
call   1040 <m_remove@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @s_prefix(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
%7 = load i32, i32* %3
%8 = icmp ne i32 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %2
%10 = call i32 (...) @s_new()
store i32 %10, i32* %3
br label %11
11: ; preds = %9, %2
store i32 0, i32* %5
store i32 0, i32* %6
br label %12
12: ; preds = %28, %11
%13 = load i32, i32* %3
%14 = load i8*, i8** %4
%15 = call i64 @match(i32 %13, i32* %5, i8* %14, i32* %6)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %29
17: ; preds = %12
%18 = load i8*, i8** %4
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = load i8, i8* %21
%23 = icmp ne i8 %22, 0
br i1 %23, label %28, label %24
24: ; preds = %17
%25 = load i32, i32* %3
%26 = load i32, i32* %5
%27 = call i32 @m_remove(i32 %25, i32 0, i32 %26)
br label %29
28: ; preds = %17
br label %12
29: ; preds = %24, %12
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
define i32 @s_prefix(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = icmp eq i32 %0, 0
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 (...) @s_new()
br label %8
8: ; preds = %6, %2
%9 = phi i32 [ %0, %2 ], [ %7, %6 ]
%10 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%11 = bitcast i32* %4 to i8*
store i32 0, i32* %4
br label %12
12: ; preds = %15, %8
%13 = call i64 @match(i32 %9, i32* %3, i8* %1, i32* %4)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %24
15: ; preds = %12
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %1, i64 %17
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
br i1 %20, label %21, label %12
21: ; preds = %15
%22 = load i32, i32* %3
%23 = call i32 @m_remove(i32 %9, i32 0, i32 %22)
br label %24
24: ; preds = %12, %21
ret i32 %9
}