#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__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *strrchr(char *, char);
char *mapExtension(char *path) {
  static char ext[16];
  char *cp;
  char *object;
  object = "$(BLD_OBJ)";
  if ((cp = strrchr(path, '.'))) {
    strcpy(ext, cp);
    if (strcmp(cp, ".c") == 0) {
      strcpy(cp, object);
    } else if (strcmp(cp, ".cpp") == 0) {
      strcpy(cp, object);
    } else if (strcmp(cp, ".java") == 0) {
      strcpy(cp, ".class");
    } else if (strcmp(cp, ".cs") == 0) {
      strcpy(cp, "$(BLD_LIB)");
    }
  }
  return ext;
}


x86 assembly (clang, -O0):
<mapExtension>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xebd(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x2e,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     1238 <mapExtension+0x108>
mov    -0x10(%rbp),%rsi
lea    0x2ee2(%rip),%rdi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rdi
lea    0xe8d(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    119f <mapExtension+0x6f>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    1233 <mapExtension+0x103>
mov    -0x10(%rbp),%rdi
lea    0xe64(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11cb <mapExtension+0x9b>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    122e <mapExtension+0xfe>
mov    -0x10(%rbp),%rdi
lea    0xe3d(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11fa <mapExtension+0xca>
mov    -0x10(%rbp),%rdi
lea    0xe29(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1229 <mapExtension+0xf9>
mov    -0x10(%rbp),%rdi
lea    0xe1b(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1224 <mapExtension+0xf4>
mov    -0x10(%rbp),%rdi
lea    0xe05(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1229 <mapExtension+0xf9>
jmp    122e <mapExtension+0xfe>
jmp    1233 <mapExtension+0x103>
jmp    1238 <mapExtension+0x108>
lea    0x2e11(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mapExtension>:
push   %r14
push   %rbx
push   %rax
mov    $0x2e,%esi
call   1040 <strrchr@plt>
test   %rax,%rax
je     11cb <mapExtension+0x9b>
mov    %rax,%rbx
lea    0x2eff(%rip),%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
lea    0xeab(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
lea    0xe91(%rip),%r14
test   %rax,%rax
je     11c0 <mapExtension+0x90>
lea    0xe93(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11c0 <mapExtension+0x90>
lea    0xe84(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11b9 <mapExtension+0x89>
lea    0xe7d(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    11cb <mapExtension+0x9b>
lea    0xe6d(%rip),%r14
jmp    11c0 <mapExtension+0x90>
lea    0xe59(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
lea    0x2e7e(%rip),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@mapExtension.ext = internal global [16 x i8] zeroinitializer
@.str = [11 x i8] c"$(BLD_OBJ)\00"
@.str.1 = [3 x i8] c".c\00"
@.str.2 = [5 x i8] c".cpp\00"
@.str.3 = [6 x i8] c".java\00"
@.str.4 = [7 x i8] c".class\00"
@.str.5 = [4 x i8] c".cs\00"
@.str.6 = [11 x i8] c"$(BLD_LIB)\00"
define i8* @mapExtension(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %2
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %4
%5 = load i8*, i8** %2
%6 = call i8* @strrchr(i8* %5, i8 signext 46)
store i8* %6, i8** %3
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %44
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i32 @strcpy(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @mapExtension.ext, i64 0, i64 0), i8* %9)
%11 = load i8*, i8** %3
%12 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %8
%15 = load i8*, i8** %3
%16 = load i8*, i8** %4
%17 = call i32 @strcpy(i8* %15, i8* %16)
br label %43
18: ; preds = %8
%19 = load i8*, i8** %3
%20 = call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %18
%23 = load i8*, i8** %3
%24 = load i8*, i8** %4
%25 = call i32 @strcpy(i8* %23, i8* %24)
br label %42
26: ; preds = %18
%27 = load i8*, i8** %3
%28 = call i64 @strcmp(i8* %27, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %26
%31 = load i8*, i8** %3
%32 = call i32 @strcpy(i8* %31, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %41
33: ; preds = %26
%34 = load i8*, i8** %3
%35 = call i64 @strcmp(i8* %34, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %33
%38 = load i8*, i8** %3
%39 = call i32 @strcpy(i8* %38, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
br label %40
40: ; preds = %37, %33
br label %41
41: ; preds = %40, %30
br label %42
42: ; preds = %41, %22
br label %43
43: ; preds = %42, %14
br label %44
44: ; preds = %43, %1
ret i8* getelementptr inbounds ([16 x i8], [16 x i8]* @mapExtension.ext, i64 0, i64 0)
}

LLVM IR (-O2):
@mapExtension.ext = internal global [16 x i8] zeroinitializer
@.str = [11 x i8] c"$(BLD_OBJ)\00"
@.str.1 = [3 x i8] c".c\00"
@.str.2 = [5 x i8] c".cpp\00"
@.str.3 = [6 x i8] c".java\00"
@.str.4 = [7 x i8] c".class\00"
@.str.5 = [4 x i8] c".cs\00"
@.str.6 = [11 x i8] c"$(BLD_LIB)\00"
define i8* @mapExtension(i8* %0) {
%2 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 46)
%3 = icmp eq i8* %2, null
br i1 %3, label %20, label %4
4: ; preds = %1
%5 = tail call i32 @strcpy(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @mapExtension.ext, i64 0, i64 0), i8* %2)
%6 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %17, label %8
8: ; preds = %4
%9 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %17, label %11
11: ; preds = %8
%12 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %11
%15 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %14, %11, %8, %4
%18 = phi i8* [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), %4 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), %8 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), %11 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), %14 ]
%19 = tail call i32 @strcpy(i8* %2, i8* %18)
br label %20
20: ; preds = %17, %14, %1
ret i8* getelementptr inbounds ([16 x i8], [16 x i8]* @mapExtension.ext, i64 0, i64 0)
}