#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*/ common_prefix(char *, char *, char *);
void prefix_of_all(char *files[], int nfiles, char *prefix) {
  int i;
  common_prefix(files[0], files[1], prefix);
  for (i = 2; i < nfiles; i++) {
    common_prefix(files[i], prefix, prefix);
  }
}


x86 assembly (clang, -O0):
<prefix_of_all>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <common_prefix@plt>
movl   $0x2,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1175 <prefix_of_all+0x65>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <common_prefix@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1142 <prefix_of_all+0x32>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prefix_of_all>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %esi,%ebp
mov    %rdi,%r14
mov    (%rdi),%rdi
mov    0x8(%r14),%rsi
call   1030 <common_prefix@plt>
cmp    $0x3,%ebp
jl     1158 <prefix_of_all+0x48>
mov    %ebp,%r15d
mov    $0x2,%ebp
nopl   0x0(%rax,%rax,1)
mov    (%r14,%rbp,8),%rdi
mov    %rbx,%rsi
mov    %rbx,%rdx
call   1030 <common_prefix@plt>
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1140 <prefix_of_all+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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