#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 get_path_length(char *);
int /*<<< orphan*/ strcpy(char *, char *);
void change_filetype(char *fullfilename, char *filetype) {
  char tmp[256];
  char *s, *t;
  int i;
  if (*filetype == '.')
    filetype++;
  i = get_path_length(fullfilename);
  s = fullfilename + i;
  while (*s && *s != '.' && *s != ';')
    s++;
  t = s;
  while (*t && *t != ';')
    t++;
  if (*t == ';')
    strcpy(tmp, t);
  else
    tmp[0] = '\0';
  *s++ = '.';
  while (*filetype)
    *s++ = *filetype++;
  strcpy(s, tmp);
}


x86 assembly (clang, -O0):
<change_filetype>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    114f <change_filetype+0x2f>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <get_path_length@plt>
mov    %eax,-0x124(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x124(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x118(%rbp)
mov    -0x118(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x125(%rbp)
je     11bf <change_filetype+0x9f>
mov    -0x118(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x2e,%ecx
mov    %al,-0x125(%rbp)
je     11bf <change_filetype+0x9f>
mov    -0x118(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3b,%eax
setne  %al
mov    %al,-0x125(%rbp)
mov    -0x125(%rbp),%al
test   $0x1,%al
jne    11d2 <change_filetype+0xb2>
jmp    11e9 <change_filetype+0xc9>
mov    -0x118(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x118(%rbp)
jmp    1173 <change_filetype+0x53>
mov    -0x118(%rbp),%rax
mov    %rax,-0x120(%rbp)
mov    -0x120(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x126(%rbp)
je     1228 <change_filetype+0x108>
mov    -0x120(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3b,%eax
setne  %al
mov    %al,-0x126(%rbp)
mov    -0x126(%rbp),%al
test   $0x1,%al
jne    123b <change_filetype+0x11b>
jmp    1252 <change_filetype+0x132>
mov    -0x120(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x120(%rbp)
jmp    11f7 <change_filetype+0xd7>
mov    -0x120(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3b,%eax
jne    127d <change_filetype+0x15d>
lea    -0x110(%rbp),%rdi
mov    -0x120(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    1284 <change_filetype+0x164>
movb   $0x0,-0x110(%rbp)
mov    -0x118(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x118(%rbp)
movb   $0x2e,(%rax)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     12d6 <change_filetype+0x1b6>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%cl
mov    -0x118(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x118(%rbp)
mov    %cl,(%rax)
jmp    129c <change_filetype+0x17c>
mov    -0x118(%rbp),%rdi
lea    -0x110(%rbp),%rsi
call   1030 <strcpy@plt>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<change_filetype>:
push   %r15
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    %rdi,%r14
xor    %r15d,%r15d
cmpb   $0x2e,(%rsi)
sete   %r15b
add    %rsi,%r15
call   1040 <get_path_length@plt>
movslq %eax,%rbx
add    %r14,%rbx
movabs $0x800400000000001,%rcx
jmp    1164 <change_filetype+0x44>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbx
movzbl (%rbx),%eax
cmp    $0x3b,%rax
ja     1160 <change_filetype+0x40>
bt     %rax,%rcx
jae    1160 <change_filetype+0x40>
mov    %rbx,%rsi
test   %al,%al
je     1190 <change_filetype+0x70>
nopw   0x0(%rax,%rax,1)
cmp    $0x3b,%al
je     1196 <change_filetype+0x76>
movzbl 0x1(%rsi),%eax
add    $0x1,%rsi
test   %al,%al
jne    1180 <change_filetype+0x60>
movb   $0x0,(%rsp)
jmp    119e <change_filetype+0x7e>
mov    %rsp,%rdi
call   1030 <strcpy@plt>
movb   $0x2e,(%rbx)
mov    (%r15),%al
test   %al,%al
je     11c5 <change_filetype+0xa5>
mov    $0x1,%ecx
nopl   (%rax)
mov    %al,(%rbx,%rcx,1)
movzbl (%r15,%rcx,1),%eax
add    $0x1,%rcx
test   %al,%al
jne    11b0 <change_filetype+0x90>
add    %rcx,%rbx
jmp    11c9 <change_filetype+0xa9>
add    $0x1,%rbx
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @change_filetype(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [256 x i8]
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%9 = load i8*, i8** %4
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 46
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = load i8*, i8** %4
%15 = getelementptr inbounds i8, i8* %14, i32 1
store i8* %15, i8** %4
br label %16
16: ; preds = %13, %2
%17 = load i8*, i8** %3
%18 = call i32 @get_path_length(i8* %17)
store i32 %18, i32* %8
%19 = load i8*, i8** %3
%20 = load i32, i32* %8
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
store i8* %22, i8** %6
br label %23
23: ; preds = %40, %16
%24 = load i8*, i8** %6
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %38
28: ; preds = %23
%29 = load i8*, i8** %6
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp ne i32 %31, 46
br i1 %32, label %33, label %38
33: ; preds = %28
%34 = load i8*, i8** %6
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp ne i32 %36, 59
br label %38
38: ; preds = %33, %28, %23
%39 = phi i1 [ false, %28 ], [ false, %23 ], [ %37, %33 ]
br i1 %39, label %40, label %43
40: ; preds = %38
%41 = load i8*, i8** %6
%42 = getelementptr inbounds i8, i8* %41, i32 1
store i8* %42, i8** %6
br label %23
43: ; preds = %38
%44 = load i8*, i8** %6
store i8* %44, i8** %7
br label %45
45: ; preds = %57, %43
%46 = load i8*, i8** %7
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = icmp ne i32 %48, 0
br i1 %49, label %50, label %55
50: ; preds = %45
%51 = load i8*, i8** %7
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = icmp ne i32 %53, 59
br label %55
55: ; preds = %50, %45
%56 = phi i1 [ false, %45 ], [ %54, %50 ]
br i1 %56, label %57, label %60
57: ; preds = %55
%58 = load i8*, i8** %7
%59 = getelementptr inbounds i8, i8* %58, i32 1
store i8* %59, i8** %7
br label %45
60: ; preds = %55
%61 = load i8*, i8** %7
%62 = load i8, i8* %61
%63 = sext i8 %62 to i32
%64 = icmp eq i32 %63, 59
br i1 %64, label %65, label %69
65: ; preds = %60
%66 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%67 = load i8*, i8** %7
%68 = call i32 @strcpy(i8* %66, i8* %67)
br label %71
69: ; preds = %60
%70 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
store i8 0, i8* %70
br label %71
71: ; preds = %69, %65
%72 = load i8*, i8** %6
%73 = getelementptr inbounds i8, i8* %72, i32 1
store i8* %73, i8** %6
store i8 46, i8* %72
br label %74
74: ; preds = %78, %71
%75 = load i8*, i8** %4
%76 = load i8, i8* %75
%77 = icmp ne i8 %76, 0
br i1 %77, label %78, label %84
78: ; preds = %74
%79 = load i8*, i8** %4
%80 = getelementptr inbounds i8, i8* %79, i32 1
store i8* %80, i8** %4
%81 = load i8, i8* %79
%82 = load i8*, i8** %6
%83 = getelementptr inbounds i8, i8* %82, i32 1
store i8* %83, i8** %6
store i8 %81, i8* %82
br label %74
84: ; preds = %74
%85 = load i8*, i8** %6
%86 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%87 = call i32 @strcpy(i8* %85, i8* %86)
ret void
}

LLVM IR (-O2):
define void @change_filetype(i8* %0, i8* nocapture %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = load i8, i8* %1
%6 = icmp eq i8 %5, 46
%7 = zext i1 %6 to i64
%8 = getelementptr i8, i8* %1, i64 %7
%9 = tail call i32 @get_path_length(i8* %0)
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %0, i64 %10
br label %12
12: ; preds = %16, %2
%13 = phi i8* [ %11, %2 ], [ %17, %16 ]
%14 = load i8, i8* %13
switch i8 %14, label %16 [
i8 0, label %15
i8 46, label %15
i8 59, label %15
]
15: ; preds = %12, %12, %12
br label %18
16: ; preds = %12
%17 = getelementptr inbounds i8, i8* %13, i64 1
br label %12
18: ; preds = %15, %21
%19 = phi i8 [ %23, %21 ], [ %14, %15 ]
%20 = phi i8* [ %22, %21 ], [ %13, %15 ]
switch i8 %19, label %21 [
i8 59, label %24
i8 0, label %26
]
21: ; preds = %18
%22 = getelementptr inbounds i8, i8* %20, i64 1
%23 = load i8, i8* %22
br label %18
24: ; preds = %18
%25 = call i32 @strcpy(i8* %4, i8* %20)
br label %27
26: ; preds = %18
store i8 0, i8* %4
br label %27
27: ; preds = %26, %24
store i8 46, i8* %13
%28 = getelementptr inbounds i8, i8* %13, i64 1
%29 = load i8, i8* %8
%30 = icmp eq i8 %29, 0
br i1 %30, label %39, label %31
31: ; preds = %27, %31
%32 = phi i8 [ %37, %31 ], [ %29, %27 ]
%33 = phi i8* [ %36, %31 ], [ %28, %27 ]
%34 = phi i8* [ %35, %31 ], [ %8, %27 ]
%35 = getelementptr inbounds i8, i8* %34, i64 1
store i8 %32, i8* %33
%36 = getelementptr inbounds i8, i8* %33, i64 1
%37 = load i8, i8* %35
%38 = icmp eq i8 %37, 0
br i1 %38, label %39, label %31
39: ; preds = %31, %27
%40 = phi i8* [ %28, %27 ], [ %36, %31 ]
%41 = call i32 @strcpy(i8* %40, i8* %4)
ret void
}