#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*/ assert(char const *);
char *calloc(int, size_t);
size_t strlen(char const *);
char *malloc4_lcs(const char *a, const char *b) {
  assert(a);
  assert(b);
  size_t la = strlen(a);
  size_t lb = strlen(b);
  size_t ll = (la < lb) ? la : lb;
  char *ret = calloc(1, ll + 1);
  assert(ret);
  return ret;
}


x86 assembly (clang, -O0):
<malloc4_lcs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <assert@plt>
mov    -0x10(%rbp),%rdi
call   1050 <assert@plt>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    1187 <malloc4_lcs+0x57>
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
jmp    118f <malloc4_lcs+0x5f>
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rsi
add    $0x1,%rsi
mov    $0x1,%edi
call   1040 <calloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1050 <assert@plt>
mov    -0x30(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<malloc4_lcs>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1050 <assert@plt>
mov    %r14,%rdi
call   1050 <assert@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    %rax,%rbx
cmovae %rax,%rbx
add    $0x1,%rbx
mov    $0x1,%edi
mov    %rbx,%rsi
call   1040 <calloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <assert@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i8* @malloc4_lcs(i8* %0, i8* %1) {
%3 = tail call i32 @assert(i8* %0)
%4 = tail call i32 @assert(i8* %1)
%5 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%6 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%7 = icmp ult i64 %5, %6
%8 = select i1 %7, i64 %5, i64 %6
%9 = add i64 %8, 1
%10 = tail call i8* @calloc(i32 1, i64 %9)
%11 = tail call i32 @assert(i8* %10)
ret i8* %10
}