#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 editDisRecur(char *, char *, int, int);
int editDistance(char *, char *, int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int main() {
  int i, n = 0, m = 0;
  char str1[100], str2[100];
  printf("enter 2 strings\n");
  scanf("%s", str1);
  scanf("%s", str2);
  for (i = 0; str1[i] != '\0'; ++i)
    n++;
  for (i = 0; str2[i] != '\0'; ++i)
    m++;
  printf("%d\n", editDisRecur(str1, str2, n, m));
  printf("%d\n", editDistance(str1, str2, n, m));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x80(%rbp),%rsi
lea    0xe98(%rip),%rdi
call   1050 <scanf@plt>
lea    -0xf0(%rbp),%rsi
lea    0xe85(%rip),%rdi
call   1050 <scanf@plt>
movl   $0x0,-0x8(%rbp)
movslq -0x8(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     11c1 <main+0x81>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1198 <main+0x58>
movl   $0x0,-0x8(%rbp)
movslq -0x8(%rbp),%rax
movsbl -0xf0(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     11f4 <main+0xb4>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11c8 <main+0x88>
lea    -0x80(%rbp),%rdi
lea    -0xf0(%rbp),%rsi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
call   1040 <editDisRecur@plt>
mov    %eax,%esi
lea    0xe01(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x80(%rbp),%rdi
lea    -0xf0(%rbp),%rsi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
call   1060 <editDistance@plt>
mov    %eax,%esi
lea    0xddb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xe0,%rsp
lea    0xea0(%rip),%rdi
call   1030 <puts@plt>
lea    0xe8d(%rip),%rbx
lea    0x70(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
xor    %r14d,%r14d
cmpb   $0x0,0x70(%rsp)
mov    $0x0,%ebx
je     11ab <main+0x5b>
xor    %ebx,%ebx
nopl   0x0(%rax)
cmpb   $0x0,0x71(%rsp,%rbx,1)
lea    0x1(%rbx),%rbx
jne    11a0 <main+0x50>
cmpb   $0x0,(%rsp)
je     11cc <main+0x7c>
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmpb   $0x0,0x1(%rsp,%r14,1)
lea    0x1(%r14),%r14
jne    11c0 <main+0x70>
lea    0x70(%rsp),%r15
mov    %rsp,%r12
mov    %r15,%rdi
mov    %r12,%rsi
mov    %ebx,%edx
mov    %r14d,%ecx
call   1050 <editDisRecur@plt>
lea    0xe18(%rip),%r13
mov    %r13,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %ebx,%edx
mov    %r14d,%ecx
call   1070 <editDistance@plt>
mov    %r13,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [17 x i8] c"enter 2 strings\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [100 x i8]
%6 = alloca [100 x i8]
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %4
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %10)
store i32 0, i32* %2
br label %12
12: ; preds = %22, %0
%13 = load i32, i32* %2
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %25
19: ; preds = %12
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
store i32 %21, i32* %3
br label %22
22: ; preds = %19
%23 = load i32, i32* %2
%24 = add nsw i32 %23, 1
store i32 %24, i32* %2
br label %12
25: ; preds = %12
store i32 0, i32* %2
br label %26
26: ; preds = %36, %25
%27 = load i32, i32* %2
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 %28
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %39
33: ; preds = %26
%34 = load i32, i32* %4
%35 = add nsw i32 %34, 1
store i32 %35, i32* %4
br label %36
36: ; preds = %33
%37 = load i32, i32* %2
%38 = add nsw i32 %37, 1
store i32 %38, i32* %2
br label %26
39: ; preds = %26
%40 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%41 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%42 = load i32, i32* %3
%43 = load i32, i32* %4
%44 = call i32 @editDisRecur(i8* %40, i8* %41, i32 %42, i32 %43)
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %44)
%46 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%47 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%48 = load i32, i32* %3
%49 = load i32, i32* %4
%50 = call i32 @editDistance(i8* %46, i8* %47, i32 %48, i32 %49)
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %50)
%52 = load i32, i32* %1
ret i32 %52
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@str = [16 x i8] c"enter 2 strings\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%8 = load i8, i8* %3
%9 = icmp eq i8 %8, 0
br i1 %9, label %12, label %16
10: ; preds = %16
%11 = trunc i64 %18 to i32
br label %12
12: ; preds = %10, %0
%13 = phi i32 [ 0, %0 ], [ %11, %10 ]
%14 = load i8, i8* %4
%15 = icmp eq i8 %14, 0
br i1 %15, label %30, label %22
16: ; preds = %0, %16
%17 = phi i64 [ %18, %16 ], [ 0, %0 ]
%18 = add nuw nsw i64 %17, 1
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 0
br i1 %21, label %10, label %16
22: ; preds = %12, %22
%23 = phi i64 [ %24, %22 ], [ 0, %12 ]
%24 = add nuw nsw i64 %23, 1
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 0
br i1 %27, label %28, label %22
28: ; preds = %22
%29 = trunc i64 %24 to i32
br label %30
30: ; preds = %28, %12
%31 = phi i32 [ 0, %12 ], [ %29, %28 ]
%32 = call i32 @editDisRecur(i8* %3, i8* %4, i32 %13, i32 %31)
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %32)
%34 = call i32 @editDistance(i8* %3, i8* %4, i32 %13, i32 %31)
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %34)
ret i32 0
}