#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__ m_next(int, int *, char **);
int cmp(char *s, int m) {
  int p;
  char *d;
  for (p = -1; m_next(m, &p, &d);) {
    if (*s == 0)
      return 0;
    if (*s != *d)
      break;
    s++;
  }
  return 1;
}


x86 assembly (clang, -O0):
<cmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0xffffffff,-0x18(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x18(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1030 <m_next@plt>
cmp    $0x0,%rax
je     1188 <cmp+0x78>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    115c <cmp+0x4c>
movl   $0x0,-0x4(%rbp)
jmp    118f <cmp+0x7f>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    -0x20(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1177 <cmp+0x67>
jmp    1188 <cmp+0x78>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1126 <cmp+0x16>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmp>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebp
mov    %rdi,%rbx
movl   $0xffffffff,0x4(%rsp)
ff
lea    0x4(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    %ebp,%edi
call   1030 <m_next@plt>
mov    $0x1,%r14d
test   %rax,%rax
je     117b <cmp+0x6b>
lea    0x4(%rsp),%r15
lea    0x8(%rsp),%r12
nop
movzbl (%rbx),%eax
test   %al,%al
je     1178 <cmp+0x68>
mov    0x8(%rsp),%rcx
cmp    (%rcx),%al
jne    117b <cmp+0x6b>
add    $0x1,%rbx
mov    %ebp,%edi
mov    %r15,%rsi
mov    %r12,%rdx
call   1030 <m_next@plt>
test   %rax,%rax
jne    1150 <cmp+0x40>
jmp    117b <cmp+0x6b>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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