#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 */
char *make_permenent_string(char *);
char *rstrstr(char *, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
char *back_up_file_extension_finder(char *url) {
  char *fileExtension = rstrstr(url, ".");
  if (fileExtension == NULL || fileExtension[1] == '\0' ||
      fileExtension[2] == '\0' || fileExtension[3] == '\0') {
    fileExtension = "\0";
  }
  char fileExtensionBuffer[5];
  snprintf(fileExtensionBuffer, 5, "%s", fileExtension);
  return make_permenent_string(fileExtensionBuffer);
}


x86 assembly (clang, -O0):
<back_up_file_extension_finder>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb9(%rip),%rsi
call   1050 <rstrstr@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     118e <back_up_file_extension_finder+0x5e>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
je     118e <back_up_file_extension_finder+0x5e>
mov    -0x10(%rbp),%rax
movsbl 0x2(%rax),%eax
cmp    $0x0,%eax
je     118e <back_up_file_extension_finder+0x5e>
mov    -0x10(%rbp),%rax
movsbl 0x3(%rax),%eax
cmp    $0x0,%eax
jne    1199 <back_up_file_extension_finder+0x69>
lea    0xe70(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    -0x15(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x5,%esi
lea    0xe55(%rip),%rdx
call   1030 <snprintf@plt>
lea    -0x15(%rbp),%rdi
call   1040 <make_permenent_string@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<back_up_file_extension_finder>:
push   %rbx
sub    $0x10,%rsp
lea    0xec4(%rip),%rsi
call   1050 <rstrstr@plt>
test   %rax,%rax
je     1158 <back_up_file_extension_finder+0x28>
cmpb   $0x0,0x1(%rax)
je     1158 <back_up_file_extension_finder+0x28>
cmpb   $0x0,0x2(%rax)
je     1158 <back_up_file_extension_finder+0x28>
cmpb   $0x0,0x3(%rax)
jne    115f <back_up_file_extension_finder+0x2f>
lea    0xea6(%rip),%rax
lea    0xe9c(%rip),%rdx
lea    0xb(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x5,%esi
mov    %rax,%rcx
call   1030 <snprintf@plt>
mov    %rbx,%rdi
call   1040 <make_permenent_string@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c".\00"
@.str.1 = [2 x i8] zeroinitializer
@.str.2 = [3 x i8] c"%s\00"
define i8* @back_up_file_extension_finder(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca [5 x i8]
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i8* @rstrstr(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %6, i8** %3
%7 = load i8*, i8** %3
%8 = icmp eq i8* %7, null
br i1 %8, label %27, label %9
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = getelementptr inbounds i8, i8* %10, i64 1
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 0
br i1 %14, label %27, label %15
15: ; preds = %9
%16 = load i8*, i8** %3
%17 = getelementptr inbounds i8, i8* %16, i64 2
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 0
br i1 %20, label %27, label %21
21: ; preds = %15
%22 = load i8*, i8** %3
%23 = getelementptr inbounds i8, i8* %22, i64 3
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %21, %15, %9, %1
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %28
28: ; preds = %27, %21
%29 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%30 = load i8*, i8** %3
%31 = call i32 @snprintf(i8* %29, i32 5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %30)
%32 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%33 = call i8* @make_permenent_string(i8* %32)
ret i8* %33
}

LLVM IR (-O2):
@.str = [2 x i8] c".\00"
@.str.1 = [2 x i8] zeroinitializer
@.str.2 = [3 x i8] c"%s\00"
define i8* @back_up_file_extension_finder(i8* %0) {
%2 = alloca [5 x i8]
%3 = tail call i8* @rstrstr(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i8* %3, null
br i1 %4, label %17, label %5
5: ; preds = %1
%6 = getelementptr inbounds i8, i8* %3, i64 1
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 0
br i1 %8, label %17, label %9
9: ; preds = %5
%10 = getelementptr inbounds i8, i8* %3, i64 2
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %9
%14 = getelementptr inbounds i8, i8* %3, i64 3
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %13, %9, %5, %1
br label %18
18: ; preds = %17, %13
%19 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), %17 ], [ %3, %13 ]
%20 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%21 = call i32 @snprintf(i8* %20, i32 5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %19)
%22 = call i8* @make_permenent_string(i8* %20)
ret i8* %22
}