char *longestCommonPrefix(char **strs, int strsSize) {
  if (strsSize == 0)
    return "";
  int i;
  for (i = 0; e(strs, strsSize, i); i++)
    ;
  if (i == 0)
    return "";
  char *p = (char *)malloc((i) * sizeof(char));
  memmove(p, strs[0], i);
  p[i] = '\0';
  return p;
}


x86 assembly (clang, -O0):
<longestCommonPrefix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1159 <longestCommonPrefix+0x29>
lea    0xeb0(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11e0 <longestCommonPrefix+0xb0>
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    $0x0,%al
call   1040 <e@plt>
cmp    $0x0,%eax
je     118d <longestCommonPrefix+0x5d>
jmp    117f <longestCommonPrefix+0x4f>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1160 <longestCommonPrefix+0x30>
cmpl   $0x0,-0x18(%rbp)
jne    11a7 <longestCommonPrefix+0x77>
lea    0xe62(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11e0 <longestCommonPrefix+0xb0>
movslq -0x18(%rbp),%rdi
shl    $0x0,%rdi
call   1030 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
movslq -0x18(%rbp),%rdx
call   1050 <memmove@plt>
mov    -0x20(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<longestCommonPrefix>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xec2(%rip),%r14
test   %esi,%esi
je     1188 <longestCommonPrefix+0x58>
mov    %esi,%ebp
mov    %rdi,%r15
mov    $0xffffffffffffffff,%rbx
xchg   %ax,%ax
add    $0x1,%rbx
mov    %r15,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <e@plt>
test   %eax,%eax
jne    1150 <longestCommonPrefix+0x20>
test   %ebx,%ebx
je     1188 <longestCommonPrefix+0x58>
mov    %rbx,%rdi
call   1040 <malloc@plt>
mov    %rax,%r14
mov    (%r15),%rsi
mov    %rax,%rdi
mov    %rbx,%rdx
call   1030 <memcpy@plt>
movb   $0x0,(%r14,%rbx,1)
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
define i8* @longestCommonPrefix(i8** %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
store i8** %0, i8*** %4
store i32 %1, i32* %5
%8 = load i32, i32* %5
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %2
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %3
br label %42
11: ; preds = %2
store i32 0, i32* %6
br label %12
12: ; preds = %19, %11
%13 = load i8**, i8*** %4
%14 = load i32, i32* %5
%15 = load i32, i32* %6
%16 = call i32 (i8**, i32, i32, ...) bitcast (i32 (...)* @e to i32 (i8**, i32, i32, ...)*)(i8** %13, i32 %14, i32 %15)
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %12
br label %19
19: ; preds = %18
%20 = load i32, i32* %6
%21 = add nsw i32 %20, 1
store i32 %21, i32* %6
br label %12
22: ; preds = %12
%23 = load i32, i32* %6
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %22
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %3
br label %42
26: ; preds = %22
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = mul i64 %28, 1
%30 = call i8* @malloc(i64 %29)
store i8* %30, i8** %7
%31 = load i8*, i8** %7
%32 = load i8**, i8*** %4
%33 = getelementptr inbounds i8*, i8** %32, i64 0
%34 = load i8*, i8** %33
%35 = load i32, i32* %6
%36 = sext i32 %35 to i64
%37 = load i8*, i8** %7
%38 = load i32, i32* %6
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %37, i64 %39
store i8 0, i8* %40
%41 = load i8*, i8** %7
store i8* %41, i8** %3
br label %42
42: ; preds = %26, %25, %10
%43 = load i8*, i8** %3
ret i8* %43
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
define i8* @longestCommonPrefix(i8** %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %16, label %4
4: ; preds = %2, %4
%5 = phi i32 [ %8, %4 ], [ 0, %2 ]
%6 = tail call i32 (i8**, i32, i32, ...) bitcast (i32 (...)* @e to i32 (i8**, i32, i32, ...)*)(i8** %0, i32 %1, i32 %5)
%7 = icmp eq i32 %6, 0
%8 = add nuw nsw i32 %5, 1
br i1 %7, label %9, label %4
9: ; preds = %4
%10 = icmp eq i32 %5, 0
br i1 %10, label %16, label %11
11: ; preds = %9
%12 = zext i32 %5 to i64
%13 = tail call i8* @malloc(i64 %12)
%14 = load i8*, i8** %0
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %13, i8* align 1 %14, i64 %12, i1 false)
%15 = getelementptr inbounds i8, i8* %13, i64 %12
store i8 0, i8* %15
br label %16
16: ; preds = %11, %9, %2
%17 = phi i8* [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %2 ], [ %13, %11 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %9 ]
ret i8* %17
}