#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 */
scalar_t__ malloc(int);
char *prefix(char *s1, char *s2) {
  char *ans = (char *)malloc(sizeof(char) * 51);
  int len = 0;
  while (*(s1 + len) == *(s2 + len))
    ans[len] = *(s1 + len++);
  ans[len] = '\0';
  return ans;
}


x86 assembly (clang, -O0):
<prefix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x33,%edi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x10(%rbp),%rcx
movslq -0x1c(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
jne    117a <prefix+0x6a>
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x1c(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    1135 <prefix+0x25>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prefix>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x33,%edi
call   1030 <malloc@plt>
mov    (%rbx),%cl
cmp    (%r14),%cl
jne    114b <prefix+0x3b>
xor    %edx,%edx
nopl   (%rax)
mov    %rdx,%rsi
mov    %cl,0x1(%rax,%rdx,1)
movzbl 0x1(%rbx,%rdx,1),%ecx
add    $0x1,%rdx
cmp    0x1(%r14,%rsi,1),%cl
je     1130 <prefix+0x20>
mov    %edx,%ecx
jmp    114d <prefix+0x3d>
xor    %ecx,%ecx
movb   $0x0,(%rax,%rcx,1)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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