#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 *);
int strlen(char *);
void FindTypeCreater(char *dataname, char **create, char **type) {
  static char tbuf[5];
  int len = strlen(dataname);
  if (*type == NULL) {
    if ((len > 4 && strcmp(dataname + len - 4, ".txt") == 0) ||
        (len > 4 && strcmp(dataname + len - 4, ".TXT") == 0) ||
        (len > 5 && strcmp(dataname + len - 5, ".text") == 0) ||
        (len > 5 && strcmp(dataname + len - 5, ".TEXT") == 0)) {
      strcpy(tbuf, "TEXT");
      *type = tbuf;
    }
  }
}


x86 assembly (clang, -O0):
<FindTypeCreater>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1240 <FindTypeCreater+0x110>
cmpl   $0x4,-0x1c(%rbp)
jle    118d <FindTypeCreater+0x5d>
mov    -0x8(%rbp),%rdi
movslq -0x1c(%rbp),%rax
add    %rax,%rdi
add    $0xfffffffffffffffc,%rdi
lea    0xe82(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     121a <FindTypeCreater+0xea>
cmpl   $0x4,-0x1c(%rbp)
jle    11bc <FindTypeCreater+0x8c>
mov    -0x8(%rbp),%rdi
movslq -0x1c(%rbp),%rax
add    %rax,%rdi
add    $0xfffffffffffffffc,%rdi
lea    0xe58(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     121a <FindTypeCreater+0xea>
cmpl   $0x5,-0x1c(%rbp)
jle    11eb <FindTypeCreater+0xbb>
mov    -0x8(%rbp),%rdi
movslq -0x1c(%rbp),%rax
add    %rax,%rdi
add    $0xfffffffffffffffb,%rdi
lea    0xe2e(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     121a <FindTypeCreater+0xea>
cmpl   $0x5,-0x1c(%rbp)
jle    123b <FindTypeCreater+0x10b>
mov    -0x8(%rbp),%rdi
movslq -0x1c(%rbp),%rax
add    %rax,%rdi
add    $0xfffffffffffffffb,%rdi
lea    0xe05(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    123b <FindTypeCreater+0x10b>
lea    0x2e18(%rip),%rdi
lea    0xde9(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rax
lea    0x2e01(%rip),%rcx
mov    %rcx,(%rax)
jmp    1240 <FindTypeCreater+0x110>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FindTypeCreater>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rdi,%rbx
call   1040 <strlen@plt>
cmpq   $0x0,(%r14)
jne    11d8 <FindTypeCreater+0xa8>
mov    %eax,%ebp
cmp    $0x5,%eax
jl     11d8 <FindTypeCreater+0xa8>
mov    %ebp,%r12d
lea    (%rbx,%r12,1),%r15
add    $0xfffffffffffffffc,%r15
lea    0xe96(%rip),%rsi
mov    %r15,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11bf <FindTypeCreater+0x8f>
lea    0xe87(%rip),%rsi
mov    %r15,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11bf <FindTypeCreater+0x8f>
cmp    $0x6,%ebp
jb     11d8 <FindTypeCreater+0xa8>
add    %r12,%rbx
add    $0xfffffffffffffffb,%rbx
lea    0xe6c(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11bf <FindTypeCreater+0x8f>
lea    0xe5e(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    11d8 <FindTypeCreater+0xa8>
lea    0x2e73(%rip),%rbx
lea    0xe44(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,(%r14)
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@FindTypeCreater.tbuf = internal global [5 x i8] zeroinitializer
@.str = [5 x i8] c".txt\00"
@.str.1 = [5 x i8] c".TXT\00"
@.str.2 = [6 x i8] c".text\00"
@.str.3 = [6 x i8] c".TEXT\00"
@.str.4 = [5 x i8] c"TEXT\00"
define void @FindTypeCreater(i8* %0, i8** %1, i8** %2) {
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca i32
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i8** %2, i8*** %6
%8 = load i8*, i8** %4
%9 = call i32 @strlen(i8* %8)
store i32 %9, i32* %7
%10 = load i8**, i8*** %6
%11 = load i8*, i8** %10
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %61
13: ; preds = %3
%14 = load i32, i32* %7
%15 = icmp sgt i32 %14, 4
br i1 %15, label %16, label %24
16: ; preds = %13
%17 = load i8*, i8** %4
%18 = load i32, i32* %7
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = getelementptr inbounds i8, i8* %20, i64 -4
%22 = call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %57, label %24
24: ; preds = %16, %13
%25 = load i32, i32* %7
%26 = icmp sgt i32 %25, 4
br i1 %26, label %27, label %35
27: ; preds = %24
%28 = load i8*, i8** %4
%29 = load i32, i32* %7
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
%32 = getelementptr inbounds i8, i8* %31, i64 -4
%33 = call i64 @strcmp(i8* %32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %57, label %35
35: ; preds = %27, %24
%36 = load i32, i32* %7
%37 = icmp sgt i32 %36, 5
br i1 %37, label %38, label %46
38: ; preds = %35
%39 = load i8*, i8** %4
%40 = load i32, i32* %7
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %39, i64 %41
%43 = getelementptr inbounds i8, i8* %42, i64 -5
%44 = call i64 @strcmp(i8* %43, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%45 = icmp eq i64 %44, 0
br i1 %45, label %57, label %46
46: ; preds = %38, %35
%47 = load i32, i32* %7
%48 = icmp sgt i32 %47, 5
br i1 %48, label %49, label %60
49: ; preds = %46
%50 = load i8*, i8** %4
%51 = load i32, i32* %7
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %50, i64 %52
%54 = getelementptr inbounds i8, i8* %53, i64 -5
%55 = call i64 @strcmp(i8* %54, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%56 = icmp eq i64 %55, 0
br i1 %56, label %57, label %60
57: ; preds = %49, %38, %27, %16
%58 = call i32 @strcpy(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @FindTypeCreater.tbuf, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%59 = load i8**, i8*** %6
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @FindTypeCreater.tbuf, i64 0, i64 0), i8** %59
br label %60
60: ; preds = %57, %49, %46
br label %61
61: ; preds = %60, %3
ret void
}

LLVM IR (-O2):
@FindTypeCreater.tbuf = internal global [5 x i8] zeroinitializer
@.str = [5 x i8] c".txt\00"
@.str.1 = [5 x i8] c".TXT\00"
@.str.2 = [6 x i8] c".text\00"
@.str.3 = [6 x i8] c".TEXT\00"
@.str.4 = [5 x i8] c"TEXT\00"
define void @FindTypeCreater(i8* %0, i8** nocapture readnone %1, i8** nocapture %2) {
%4 = tail call i32 @strlen(i8* %0)
%5 = load i8*, i8** %2
%6 = icmp eq i8* %5, null
%7 = icmp sgt i32 %4, 4
%8 = select i1 %6, i1 %7, i1 false
br i1 %8, label %9, label %29
9: ; preds = %3
%10 = zext i32 %4 to i64
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = getelementptr inbounds i8, i8* %11, i64 -4
%13 = tail call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %27, label %15
15: ; preds = %9
%16 = tail call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %27, label %18
18: ; preds = %15
%19 = icmp ugt i32 %4, 5
br i1 %19, label %20, label %29
20: ; preds = %18
%21 = getelementptr inbounds i8, i8* %11, i64 -5
%22 = tail call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %27, label %24
24: ; preds = %20
%25 = tail call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %24, %20, %15, %9
%28 = tail call i32 @strcpy(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @FindTypeCreater.tbuf, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @FindTypeCreater.tbuf, i64 0, i64 0), i8** %2
br label %29
29: ; preds = %18, %24, %27, %3
ret void
}