#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 editdist(char *, char *, int, int);
int /*<<< orphan*/ printf(char *, int);
int strlen(char *);
void main() {
  char str1[] = "avinash";
  char str2[] = "ainash";
  int len1 = strlen(str1);
  int len2 = strlen(str2);
  int table[len1][len2];
  int res = editdist(str1, str2, len1 - 1, len2 - 1);
  printf("Min edit dist is %d", res);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0xec1(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    0xebf(%rip),%eax
mov    %eax,-0xf(%rbp)
mov    0xeb9(%rip),%ax
mov    %ax,-0xb(%rbp)
mov    0xeb1(%rip),%al
mov    %al,-0x9(%rbp)
lea    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
lea    -0xf(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
mov    %rsp,%rdx
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %rax,-0x30(%rbp)
lea    -0x8(%rbp),%rdi
lea    -0xf(%rbp),%rsi
mov    -0x14(%rbp),%edx
sub    $0x1,%edx
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
call   1050 <editdist@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%esi
lea    0xe5a(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
movabs $0x6873616e697661,%rax
mov    %rax,0x10(%rsp)
movl   $0x687361,0xb(%rsp)
movl   $0x616e6961,0x8(%rsp)
61
lea    0x10(%rsp),%r14
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
lea    0x8(%rsp),%r15
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %rsp,%rbx
add    $0xffffffff,%ebp
lea    -0x1(%rax),%ecx
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1050 <editdist@plt>
lea    0xe75(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    %rbx,%rsp
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.str1 = [8 x i8] c"avinash\00"
@__const.main.str2 = [7 x i8] c"ainash\00"
@.str = [20 x i8] c"Min edit dist is %d\00"
define void @main() {
%1 = alloca [8 x i8]
%2 = alloca [7 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
%9 = bitcast [8 x i8]* %1 to i8*
%10 = bitcast [7 x i8]* %2 to i8*
%11 = getelementptr inbounds [8 x i8], [8 x i8]* %1, i64 0, i64 0
%12 = call i32 @strlen(i8* %11)
store i32 %12, i32* %3
%13 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 0
%14 = call i32 @strlen(i8* %13)
store i32 %14, i32* %4
%15 = load i32, i32* %3
%16 = zext i32 %15 to i64
%17 = load i32, i32* %4
%18 = zext i32 %17 to i64
%19 = call i8* @llvm.stacksave()
store i8* %19, i8** %5
%20 = mul nuw i64 %16, %18
%21 = alloca i32, i64 %20
store i64 %16, i64* %6
store i64 %18, i64* %7
%22 = getelementptr inbounds [8 x i8], [8 x i8]* %1, i64 0, i64 0
%23 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 0
%24 = load i32, i32* %3
%25 = sub nsw i32 %24, 1
%26 = load i32, i32* %4
%27 = sub nsw i32 %26, 1
%28 = call i32 @editdist(i8* %22, i8* %23, i32 %25, i32 %27)
store i32 %28, i32* %8
%29 = load i32, i32* %8
%30 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %29)
%31 = load i8*, i8** %5
ret void
}

LLVM IR (-O2):
@__const.main.str2 = [7 x i8] c"ainash\00"
@.str = [20 x i8] c"Min edit dist is %d\00"
define void @main() {
%1 = alloca i64
%2 = alloca [7 x i8]
%3 = bitcast i64* %1 to i8*
store i64 29400259879335521, i64* %1
%4 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 0
%5 = call i32 @strlen(i8* %3)
%6 = call i32 @strlen(i8* %4)
%7 = call i8* @llvm.stacksave()
%8 = add nsw i32 %5, -1
%9 = add nsw i32 %6, -1
%10 = call i32 @editdist(i8* %3, i8* %4, i32 %8, i32 %9)
%11 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %10)
ret void
}