#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 *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
char *strrchr(char *, char);
void win32_mapSo2Dll(char *path) {
  int len;
  char *p, *from;
  assert(path);
  len = strlen(path);
  if (len <= 3)
    return;
  p = path + len - 2;
  if (p[0] == '.' && p[1] >= '0' && p[1] <= '9') {
    *p = 0;
    len -= 2;
  }
  p = strrchr(path, '\\');
  if (p && len >= 3 && strncmp(p, "\\lib", 4) == 0) {
    p++;
    from = p + 3;
    for (; *from; p++, from++) {
      *p = *from;
    }
    *p = 0;
    len -= 3;
  }
  if (len > 3 && strncmp(path + len - 3, ".so", 3) == 0) {
    strcpy(path + len - 3, "_d");
    len += 2;
    strcpy(path + len - 3, ".dll");
  }
  fprintf(stderr, "win32_mapSo2Dll: '%s' )\n", path);
}


x86 assembly (clang, -O0):
<win32_mapSo2Dll>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <assert@plt>
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x3,-0xc(%rbp)
jg     1190 <win32_mapSo2Dll+0x30>
jmp    1315 <win32_mapSo2Dll+0x1b5>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
add    %rcx,%rax
add    $0xfffffffffffffffe,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    11e5 <win32_mapSo2Dll+0x85>
mov    -0x18(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x30,%eax
jl     11e5 <win32_mapSo2Dll+0x85>
mov    -0x18(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x39,%eax
jg     11e5 <win32_mapSo2Dll+0x85>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0xc(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x5c,%esi
call   1060 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1289 <win32_mapSo2Dll+0x129>
cmpl   $0x3,-0xc(%rbp)
jl     1289 <win32_mapSo2Dll+0x129>
mov    -0x18(%rbp),%rdi
lea    0xde9(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1289 <win32_mapSo2Dll+0x129>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x3,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
je     1279 <win32_mapSo2Dll+0x119>
mov    -0x20(%rbp),%rax
mov    (%rax),%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1243 <win32_mapSo2Dll+0xe3>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0xc(%rbp),%eax
sub    $0x3,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x3,-0xc(%rbp)
jle    12fc <win32_mapSo2Dll+0x19c>
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rax
add    %rax,%rdi
add    $0xfffffffffffffffd,%rdi
lea    0xd5c(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    12fc <win32_mapSo2Dll+0x19c>
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rax
add    %rax,%rdi
add    $0xfffffffffffffffd,%rdi
lea    0xd36(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0xc(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rax
add    %rax,%rdi
add    $0xfffffffffffffffd,%rdi
lea    0xd15(%rip),%rsi
call   1040 <strcpy@plt>
mov    0x2cdd(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xd01(%rip),%rsi
call   1080 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<win32_mapSo2Dll>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1070 <assert@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cmp    $0x4,%eax
jge    117e <win32_mapSo2Dll+0x1e>
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    %eax,%ebp
mov    %eax,%eax
cmpb   $0x2e,-0x2(%rbx,%rax,1)
jne    119d <win32_mapSo2Dll+0x3d>
mov    -0x1(%rbx,%rax,1),%cl
add    $0xd0,%cl
cmp    $0x9,%cl
ja     119d <win32_mapSo2Dll+0x3d>
movb   $0x0,-0x2(%rbx,%rax,1)
add    $0xfffffffe,%ebp
mov    %rbx,%rdi
mov    $0x5c,%esi
call   1060 <strrchr@plt>
test   %rax,%rax
je     11d0 <win32_mapSo2Dll+0x70>
cmp    $0x3,%ebp
jb     11d0 <win32_mapSo2Dll+0x70>
mov    %rax,%r14
lea    0xe42(%rip),%rsi
mov    %rax,%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     121e <win32_mapSo2Dll+0xbe>
cmp    $0x4,%ebp
jl     1249 <win32_mapSo2Dll+0xe9>
mov    %ebp,%r14d
lea    (%rbx,%r14,1),%rbp
add    $0xfffffffffffffffd,%rbp
lea    0xe1e(%rip),%rsi
mov    %rbp,%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1249 <win32_mapSo2Dll+0xe9>
lea    0xe09(%rip),%rsi
mov    %rbp,%rdi
call   1040 <strcpy@plt>
lea    (%r14,%rbx,1),%rdi
add    $0xffffffffffffffff,%rdi
lea    0xdf5(%rip),%rsi
call   1040 <strcpy@plt>
jmp    1249 <win32_mapSo2Dll+0xe9>
mov    %r14,%rax
add    $0x1,%rax
mov    0x4(%r14),%cl
test   %cl,%cl
je     123e <win32_mapSo2Dll+0xde>
nopl   (%rax)
mov    %cl,(%rax)
movzbl 0x4(%rax),%ecx
add    $0x1,%rax
test   %cl,%cl
jne    1230 <win32_mapSo2Dll+0xd0>
movb   $0x0,(%rax)
add    $0xfffffffd,%ebp
cmp    $0x4,%ebp
jge    11d5 <win32_mapSo2Dll+0x75>
mov    0x2d90(%rip),%rax
mov    (%rax),%edi
lea    0xdb8(%rip),%rsi
mov    %rbx,%rdx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1080 <fprintf@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"\\lib\00"
@.str.1 = [4 x i8] c".so\00"
@.str.2 = [3 x i8] c"_d\00"
@.str.3 = [5 x i8] c".dll\00"
@stderr = global i32 0
@.str.4 = [25 x i8] c"win32_mapSo2Dll: '%s' )\0A\00"
define void @win32_mapSo2Dll(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i32 @assert(i8* %6)
%8 = load i8*, i8** %2
%9 = call i32 @strlen(i8* %8)
store i32 %9, i32* %3
%10 = load i32, i32* %3
%11 = icmp sle i32 %10, 3
br i1 %11, label %12, label %13
12: ; preds = %1
br label %104
13: ; preds = %1
%14 = load i8*, i8** %2
%15 = load i32, i32* %3
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = getelementptr inbounds i8, i8* %17, i64 -2
store i8* %18, i8** %4
%19 = load i8*, i8** %4
%20 = getelementptr inbounds i8, i8* %19, i64 0
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 46
br i1 %23, label %24, label %40
24: ; preds = %13
%25 = load i8*, i8** %4
%26 = getelementptr inbounds i8, i8* %25, i64 1
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp sge i32 %28, 48
br i1 %29, label %30, label %40
30: ; preds = %24
%31 = load i8*, i8** %4
%32 = getelementptr inbounds i8, i8* %31, i64 1
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp sle i32 %34, 57
br i1 %35, label %36, label %40
36: ; preds = %30
%37 = load i8*, i8** %4
store i8 0, i8* %37
%38 = load i32, i32* %3
%39 = sub nsw i32 %38, 2
store i32 %39, i32* %3
br label %40
40: ; preds = %36, %30, %24, %13
%41 = load i8*, i8** %2
%42 = call i8* @strrchr(i8* %41, i8 signext 92)
store i8* %42, i8** %4
%43 = load i8*, i8** %4
%44 = icmp ne i8* %43, null
br i1 %44, label %45, label %74
45: ; preds = %40
%46 = load i32, i32* %3
%47 = icmp sge i32 %46, 3
br i1 %47, label %48, label %74
48: ; preds = %45
%49 = load i8*, i8** %4
%50 = call i64 @strncmp(i8* %49, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%51 = icmp eq i64 %50, 0
br i1 %51, label %52, label %74
52: ; preds = %48
%53 = load i8*, i8** %4
%54 = getelementptr inbounds i8, i8* %53, i32 1
store i8* %54, i8** %4
%55 = load i8*, i8** %4
%56 = getelementptr inbounds i8, i8* %55, i64 3
store i8* %56, i8** %5
br label %57
57: ; preds = %65, %52
%58 = load i8*, i8** %5
%59 = load i8, i8* %58
%60 = icmp ne i8 %59, 0
br i1 %60, label %61, label %70
61: ; preds = %57
%62 = load i8*, i8** %5
%63 = load i8, i8* %62
%64 = load i8*, i8** %4
store i8 %63, i8* %64
br label %65
65: ; preds = %61
%66 = load i8*, i8** %4
%67 = getelementptr inbounds i8, i8* %66, i32 1
store i8* %67, i8** %4
%68 = load i8*, i8** %5
%69 = getelementptr inbounds i8, i8* %68, i32 1
store i8* %69, i8** %5
br label %57
70: ; preds = %57
%71 = load i8*, i8** %4
store i8 0, i8* %71
%72 = load i32, i32* %3
%73 = sub nsw i32 %72, 3
store i32 %73, i32* %3
br label %74
74: ; preds = %70, %48, %45, %40
%75 = load i32, i32* %3
%76 = icmp sgt i32 %75, 3
br i1 %76, label %77, label %100
77: ; preds = %74
%78 = load i8*, i8** %2
%79 = load i32, i32* %3
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds i8, i8* %78, i64 %80
%82 = getelementptr inbounds i8, i8* %81, i64 -3
%83 = call i64 @strncmp(i8* %82, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
%84 = icmp eq i64 %83, 0
br i1 %84, label %85, label %100
85: ; preds = %77
%86 = load i8*, i8** %2
%87 = load i32, i32* %3
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds i8, i8* %86, i64 %88
%90 = getelementptr inbounds i8, i8* %89, i64 -3
%91 = call i32 @strcpy(i8* %90, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%92 = load i32, i32* %3
%93 = add nsw i32 %92, 2
store i32 %93, i32* %3
%94 = load i8*, i8** %2
%95 = load i32, i32* %3
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds i8, i8* %94, i64 %96
%98 = getelementptr inbounds i8, i8* %97, i64 -3
%99 = call i32 @strcpy(i8* %98, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %100
100: ; preds = %85, %77, %74
%101 = load i32, i32* @stderr
%102 = load i8*, i8** %2
%103 = call i32 @fprintf(i32 %101, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8* %102)
br label %104
104: ; preds = %100, %12
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"\\lib\00"
@.str.1 = [4 x i8] c".so\00"
@.str.2 = [3 x i8] c"_d\00"
@.str.3 = [5 x i8] c".dll\00"
@stderr = global i32 0
@.str.4 = [25 x i8] c"win32_mapSo2Dll: '%s' )\0A\00"
define void @win32_mapSo2Dll(i8* %0) {
%2 = tail call i32 @assert(i8* %0)
%3 = tail call i32 @strlen(i8* %0)
%4 = icmp slt i32 %3, 4
br i1 %4, label %62, label %5
5: ; preds = %1
%6 = zext i32 %3 to i64
%7 = getelementptr inbounds i8, i8* %0, i64 %6
%8 = getelementptr inbounds i8, i8* %7, i64 -2
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 46
br i1 %10, label %11, label %18
11: ; preds = %5
%12 = getelementptr inbounds i8, i8* %8, i64 1
%13 = load i8, i8* %12
%14 = add i8 %13, -48
%15 = icmp ult i8 %14, 10
br i1 %15, label %16, label %18
16: ; preds = %11
store i8 0, i8* %8
%17 = add nsw i32 %3, -2
br label %18
18: ; preds = %16, %11, %5
%19 = phi i32 [ %17, %16 ], [ %3, %11 ], [ %3, %5 ]
%20 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 92)
%21 = icmp ne i8* %20, null
%22 = icmp ugt i32 %19, 2
%23 = select i1 %21, i1 %22, i1 false
br i1 %23, label %24, label %43
24: ; preds = %18
%25 = tail call i64 @strncmp(i8* %20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %43
27: ; preds = %24
%28 = getelementptr inbounds i8, i8* %20, i64 4
%29 = getelementptr inbounds i8, i8* %20, i64 1
%30 = load i8, i8* %28
%31 = icmp eq i8 %30, 0
br i1 %31, label %40, label %32
32: ; preds = %27, %32
%33 = phi i8 [ %38, %32 ], [ %30, %27 ]
%34 = phi i8* [ %37, %32 ], [ %29, %27 ]
%35 = phi i8* [ %36, %32 ], [ %28, %27 ]
store i8 %33, i8* %34
%36 = getelementptr inbounds i8, i8* %35, i64 1
%37 = getelementptr inbounds i8, i8* %34, i64 1
%38 = load i8, i8* %36
%39 = icmp eq i8 %38, 0
br i1 %39, label %40, label %32
40: ; preds = %32, %27
%41 = phi i8* [ %29, %27 ], [ %37, %32 ]
store i8 0, i8* %41
%42 = add nsw i32 %19, -3
br label %43
43: ; preds = %40, %24, %18
%44 = phi i32 [ %42, %40 ], [ %19, %24 ], [ %19, %18 ]
%45 = icmp sgt i32 %44, 3
br i1 %45, label %46, label %59
46: ; preds = %43
%47 = zext i32 %44 to i64
%48 = getelementptr inbounds i8, i8* %0, i64 %47
%49 = getelementptr inbounds i8, i8* %48, i64 -3
%50 = tail call i64 @strncmp(i8* %49, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
%51 = icmp eq i64 %50, 0
br i1 %51, label %52, label %59
52: ; preds = %46
%53 = tail call i32 @strcpy(i8* %49, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%54 = add nuw nsw i32 %44, 2
%55 = zext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %0, i64 %55
%57 = getelementptr inbounds i8, i8* %56, i64 -3
%58 = tail call i32 @strcpy(i8* %57, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %59
59: ; preds = %52, %46, %43
%60 = load i32, i32* @stderr
%61 = tail call i32 @fprintf(i32 %60, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8* %0)
br label %62
62: ; preds = %1, %59
ret void
}