#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__ memcmp(unsigned char *, unsigned char *, int);
int /*<<< orphan*/ memmove(unsigned char *, unsigned char *, int);
int strlen(unsigned char *);
void vGetCommonLanguage(unsigned char *pszLangs1, unsigned char *pszLangs2) {
  int i;
  ;
  if (strlen(pszLangs1) % 2) {
    pszLangs1[0] = 0;
    return;
  }
  while (strlen(pszLangs1)) {
    for (i = 0; i < (int)strlen(pszLangs2); i += 2) {
      if (memcmp(pszLangs1, pszLangs2 + i, 2) == 0)
        break;
    }
    if (i < (int)strlen(pszLangs2)) {
      pszLangs1 += 2;
      continue;
    }
    memmove(pszLangs1, pszLangs1 + 2, strlen(pszLangs1 + 2) + 1);
  }
}


x86 assembly (clang, -O0):
<vGetCommonLanguage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1166 <vGetCommonLanguage+0x36>
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
jmp    1240 <vGetCommonLanguage+0x110>
jmp    116b <vGetCommonLanguage+0x3b>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%eax
je     1240 <vGetCommonLanguage+0x110>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jge    11db <vGetCommonLanguage+0xab>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movslq -0x14(%rbp),%rax
add    %rax,%rsi
mov    $0x2,%edx
call   1040 <memcmp@plt>
cmp    $0x0,%rax
jne    11c8 <vGetCommonLanguage+0x98>
jmp    11db <vGetCommonLanguage+0xab>
jmp    11cd <vGetCommonLanguage+0x9d>
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x14(%rbp)
jmp    1184 <vGetCommonLanguage+0x54>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jge    1208 <vGetCommonLanguage+0xd8>
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
jmp    116b <vGetCommonLanguage+0x3b>
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
add    $0x2,%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
add    $0x1,%edx
call   1050 <memmove@plt>
jmp    116b <vGetCommonLanguage+0x3b>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vGetCommonLanguage>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
call   1030 <strlen@plt>
test   $0x1,%al
jne    11cc <vGetCommonLanguage+0x9c>
mov    %r14,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
je     11d0 <vGetCommonLanguage+0xa0>
mov    %r14,%r15
add    $0x2,%r14
xchg   %ax,%ax
mov    %rbx,%rdi
call   1030 <strlen@plt>
xor    %ebp,%ebp
test   %eax,%eax
jle    1196 <vGetCommonLanguage+0x66>
xchg   %ax,%ax
lea    (%rbx,%rbp,1),%rsi
mov    %r15,%rdi
mov    $0x2,%edx
call   1040 <memcmp@plt>
test   %rax,%rax
je     1196 <vGetCommonLanguage+0x66>
add    $0x2,%rbp
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    %ebp,%eax
jg     1170 <vGetCommonLanguage+0x40>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%r12d
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    %r12d,%ebp
jl     1153 <vGetCommonLanguage+0x23>
add    $0x1,%eax
mov    %r15,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1050 <memmove@plt>
mov    %r15,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jne    1160 <vGetCommonLanguage+0x30>
jmp    11d0 <vGetCommonLanguage+0xa0>
movb   $0x0,(%r14)
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @vGetCommonLanguage(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %3
%7 = call i32 @strlen(i8* %6)
%8 = srem i32 %7, 2
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i8*, i8** %3
%12 = getelementptr inbounds i8, i8* %11, i64 0
store i8 0, i8* %12
br label %54
13: ; preds = %2
br label %14
14: ; preds = %45, %42, %13
%15 = load i8*, i8** %3
%16 = call i32 @strlen(i8* %15)
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %54
18: ; preds = %14
store i32 0, i32* %5
br label %19
19: ; preds = %34, %18
%20 = load i32, i32* %5
%21 = load i8*, i8** %4
%22 = call i32 @strlen(i8* %21)
%23 = icmp slt i32 %20, %22
br i1 %23, label %24, label %37
24: ; preds = %19
%25 = load i8*, i8** %3
%26 = load i8*, i8** %4
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
%30 = call i64 @memcmp(i8* %25, i8* %29, i32 2)
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %24
br label %37
33: ; preds = %24
br label %34
34: ; preds = %33
%35 = load i32, i32* %5
%36 = add nsw i32 %35, 2
store i32 %36, i32* %5
br label %19
37: ; preds = %32, %19
%38 = load i32, i32* %5
%39 = load i8*, i8** %4
%40 = call i32 @strlen(i8* %39)
%41 = icmp slt i32 %38, %40
br i1 %41, label %42, label %45
42: ; preds = %37
%43 = load i8*, i8** %3
%44 = getelementptr inbounds i8, i8* %43, i64 2
store i8* %44, i8** %3
br label %14
45: ; preds = %37
%46 = load i8*, i8** %3
%47 = load i8*, i8** %3
%48 = getelementptr inbounds i8, i8* %47, i64 2
%49 = load i8*, i8** %3
%50 = getelementptr inbounds i8, i8* %49, i64 2
%51 = call i32 @strlen(i8* %50)
%52 = add nsw i32 %51, 1
%53 = call i32 @memmove(i8* %46, i8* %48, i32 %52)
br label %14
54: ; preds = %10, %14
ret void
}

LLVM IR (-O2):
define void @vGetCommonLanguage(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = and i32 %3, 1
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = tail call i32 @strlen(i8* %0)
%8 = icmp eq i32 %7, 0
br i1 %8, label %41, label %33
9: ; preds = %2
store i8 0, i8* %0
br label %41
10: ; preds = %33, %36
%11 = tail call i32 @strlen(i8* %1)
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %26
13: ; preds = %10, %18
%14 = phi i64 [ %19, %18 ], [ 0, %10 ]
%15 = getelementptr inbounds i8, i8* %1, i64 %14
%16 = tail call i64 @memcmp(i8* %34, i8* %15, i32 2)
%17 = icmp eq i64 %16, 0
br i1 %17, label %23, label %18
18: ; preds = %13
%19 = add nuw i64 %14, 2
%20 = trunc i64 %19 to i32
%21 = tail call i32 @strlen(i8* %1)
%22 = icmp sgt i32 %21, %20
br i1 %22, label %13, label %23
23: ; preds = %18, %13
%24 = phi i64 [ %14, %13 ], [ %19, %18 ]
%25 = trunc i64 %24 to i32
br label %26
26: ; preds = %23, %10
%27 = phi i32 [ 0, %10 ], [ %25, %23 ]
%28 = tail call i32 @strlen(i8* %1)
%29 = icmp slt i32 %27, %28
%30 = tail call i32 @strlen(i8* %35)
br i1 %29, label %31, label %36
31: ; preds = %26
%32 = icmp eq i32 %30, 0
br i1 %32, label %41, label %33
33: ; preds = %6, %31
%34 = phi i8* [ %35, %31 ], [ %0, %6 ]
%35 = getelementptr inbounds i8, i8* %34, i64 2
br label %10
36: ; preds = %26
%37 = add nsw i32 %30, 1
%38 = tail call i32 @memmove(i8* %34, i8* %35, i32 %37)
%39 = tail call i32 @strlen(i8* %34)
%40 = icmp eq i32 %39, 0
br i1 %40, label %41, label %10
41: ; preds = %31, %36, %6, %9
ret void
}