#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 slash_followed(char const *);
int strlen(char const *);
int strncmp(char const *, char const *, int);
int str_is_identical(const char *str1, const char *str2) {
  int len1 = strlen(str1);
  int len2 = strlen(str2);
  if (slash_followed(str1) == 1) {
    len1--;
  }
  if (slash_followed(str2) == 1) {
    len2--;
  }
  return strncmp(str1, str2, (((len1) >= (len2)) ? (len1) : (len2)));
}


x86 assembly (clang, -O0):
<str_is_identical>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <slash_followed@plt>
cmp    $0x1,%eax
jne    1173 <str_is_identical+0x43>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <slash_followed@plt>
cmp    $0x1,%eax
jne    118e <str_is_identical+0x5e>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jl     11b5 <str_is_identical+0x85>
mov    -0x14(%rbp),%eax
mov    %eax,-0x2c(%rbp)
jmp    11bb <str_is_identical+0x8b>
mov    -0x18(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdi
mov    -0x2c(%rbp),%edx
call   1030 <strncmp@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_is_identical>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
call   1040 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebx
mov    %r15,%rdi
call   1050 <slash_followed@plt>
xor    %ecx,%ecx
cmp    $0x1,%eax
sete   %cl
sub    %ecx,%ebp
mov    %r14,%rdi
call   1050 <slash_followed@plt>
xor    %ecx,%ecx
cmp    $0x1,%eax
sete   %cl
sub    %ecx,%ebx
cmp    %ebx,%ebp
cmovge %ebp,%ebx
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <strncmp@plt>

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

LLVM IR (-O2):
define i32 @str_is_identical(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = tail call i32 @strlen(i8* %1)
%5 = tail call i32 @slash_followed(i8* %0)
%6 = icmp eq i32 %5, 1
%7 = sext i1 %6 to i32
%8 = add nsw i32 %3, %7
%9 = tail call i32 @slash_followed(i8* %1)
%10 = icmp eq i32 %9, 1
%11 = sext i1 %10 to i32
%12 = add nsw i32 %4, %11
%13 = icmp slt i32 %8, %12
%14 = select i1 %13, i32 %12, i32 %8
%15 = tail call i32 @strncmp(i8* %0, i8* %1, i32 %14)
ret i32 %15
}