#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 strlen(char const *);
scalar_t__ strncmp(char const *, char const *, int);
int fstrcmp(const char *expected, const char *actual) {
  const char *delim;
  if (!expected)
    return 0;
  delim = actual + strlen(expected);
  if (*delim != 0x01)
    return 1;
  return strncmp(expected, actual, strlen(expected)) != 0;
}


x86 assembly (clang, -O0):
<fstrcmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1147 <fstrcmp+0x27>
movl   $0x0,-0x4(%rbp)
jmp    11bb <fstrcmp+0x9b>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x1,%eax
je     1184 <fstrcmp+0x64>
movl   $0x1,-0x4(%rbp)
jmp    11bb <fstrcmp+0x9b>
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fstrcmp>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     1165 <fstrcmp+0x45>
mov    %rsi,%r14
mov    %rdi,%rbx
call   1040 <strlen@plt>
movslq %eax,%rcx
mov    $0x1,%eax
cmpb   $0x1,(%r14,%rcx,1)
jne    1167 <fstrcmp+0x47>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
setne  %al
jmp    1167 <fstrcmp+0x47>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i32 @fstrcmp(i8* %0, i8* %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %15, label %4
4: ; preds = %2
%5 = tail call i32 @strlen(i8* %0)
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds i8, i8* %1, i64 %6
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 1
br i1 %9, label %10, label %15
10: ; preds = %4
%11 = tail call i32 @strlen(i8* %0)
%12 = tail call i64 @strncmp(i8* %0, i8* %1, i32 %11)
%13 = icmp ne i64 %12, 0
%14 = zext i1 %13 to i32
br label %15
15: ; preds = %4, %2, %10
%16 = phi i32 [ %14, %10 ], [ 0, %2 ], [ 1, %4 ]
ret i32 %16
}