#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 getMin(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char *);
int getLongestPrefix(char *nodepath, char *path) {
  int max, i;
  max = getMin(strlen(path), strlen(nodepath));
  i = 0;
  while (i < max && path[i] == nodepath[i])
    i++;
  return (i);
}


x86 assembly (clang, -O0):
<getLongestPrefix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x1c(%rbp),%edi
mov    %eax,%esi
call   1040 <getMin@plt>
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%ecx
xor    %eax,%eax
cmp    -0x14(%rbp),%ecx
mov    %al,-0x1d(%rbp)
jge    118a <getLongestPrefix+0x6a>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x8(%rbp),%rcx
movslq -0x18(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
sete   %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    119a <getLongestPrefix+0x7a>
jmp    11a8 <getLongestPrefix+0x88>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1159 <getLongestPrefix+0x39>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getLongestPrefix>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1040 <getMin@plt>
test   %eax,%eax
jle    1167 <getLongestPrefix+0x47>
mov    %eax,%ecx
xor    %eax,%eax
nopl   (%rax)
movzbl (%r14,%rax,1),%edx
cmp    (%rbx,%rax,1),%dl
jne    1169 <getLongestPrefix+0x49>
add    $0x1,%rax
cmp    %rax,%rcx
jne    1150 <getLongestPrefix+0x30>
mov    %ecx,%eax
jmp    1169 <getLongestPrefix+0x49>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @getLongestPrefix(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** %4
%8 = call i32 @strlen(i8* %7)
%9 = load i8*, i8** %3
%10 = call i32 @strlen(i8* %9)
%11 = call i32 @getMin(i32 %8, i32 %10)
store i32 %11, i32* %5
store i32 0, i32* %6
br label %12
12: ; preds = %32, %2
%13 = load i32, i32* %6
%14 = load i32, i32* %5
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %30
16: ; preds = %12
%17 = load i8*, i8** %4
%18 = load i32, i32* %6
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = load i8*, i8** %3
%24 = load i32, i32* %6
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %22, %28
br label %30
30: ; preds = %16, %12
%31 = phi i1 [ false, %12 ], [ %29, %16 ]
br i1 %31, label %32, label %35
32: ; preds = %30
%33 = load i32, i32* %6
%34 = add nsw i32 %33, 1
store i32 %34, i32* %6
br label %12
35: ; preds = %30
%36 = load i32, i32* %6
ret i32 %36
}

LLVM IR (-O2):
define i32 @getLongestPrefix(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %1)
%4 = tail call i32 @strlen(i8* %0)
%5 = tail call i32 @getMin(i32 %3, i32 %4)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %21
7: ; preds = %2
%8 = zext i32 %5 to i64
br label %9
9: ; preds = %7, %16
%10 = phi i64 [ 0, %7 ], [ %17, %16 ]
%11 = getelementptr inbounds i8, i8* %1, i64 %10
%12 = load i8, i8* %11
%13 = getelementptr inbounds i8, i8* %0, i64 %10
%14 = load i8, i8* %13
%15 = icmp eq i8 %12, %14
br i1 %15, label %16, label %19
16: ; preds = %9
%17 = add nuw nsw i64 %10, 1
%18 = icmp eq i64 %17, %8
br i1 %18, label %21, label %9
19: ; preds = %9
%20 = trunc i64 %10 to i32
br label %21
21: ; preds = %16, %19, %2
%22 = phi i32 [ 0, %2 ], [ %20, %19 ], [ %5, %16 ]
ret i32 %22
}