int check_trace_type(char *trace_Ptr) {
  if (~strcmp(trace_Ptr + strlen(trace_Ptr) - 4, "pcap"))
    return (1);
  else if (~strcmp(trace_Ptr + strlen(trace_Ptr) - 4, "dump"))
    return (1);
  else if (~strcmp(trace_Ptr + strlen(trace_Ptr) - 3, "tsh"))
    return (2);
  else
    return (3);
}


x86 assembly (clang, -O0):
<check_trace_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x18(%rbp),%rdi
add    %rax,%rdi
add    $0xfffffffffffffffc,%rdi
lea    0xeb1(%rip),%rsi
call   1040 <strcmp@plt>
xor    $0xffffffff,%eax
cmp    $0x0,%eax
je     116c <check_trace_type+0x4c>
movl   $0x1,-0x4(%rbp)
jmp    11f3 <check_trace_type+0xd3>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x20(%rbp),%rdi
add    %rax,%rdi
add    $0xfffffffffffffffc,%rdi
lea    0xe76(%rip),%rsi
call   1040 <strcmp@plt>
xor    $0xffffffff,%eax
cmp    $0x0,%eax
je     11ac <check_trace_type+0x8c>
movl   $0x1,-0x4(%rbp)
jmp    11f3 <check_trace_type+0xd3>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x28(%rbp),%rdi
add    %rax,%rdi
add    $0xfffffffffffffffd,%rdi
lea    0xe3b(%rip),%rsi
call   1040 <strcmp@plt>
xor    $0xffffffff,%eax
cmp    $0x0,%eax
je     11ec <check_trace_type+0xcc>
movl   $0x2,-0x4(%rbp)
jmp    11f3 <check_trace_type+0xd3>
movl   $0x3,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_trace_type>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %rax,%r14
lea    (%rbx,%rax,1),%rbp
add    $0xfffffffffffffffc,%rbp
lea    0xebf(%rip),%rsi
mov    %rbp,%rdi
call   1040 <strcmp@plt>
mov    $0x1,%r15d
cmp    $0xffffffff,%eax
jne    118c <check_trace_type+0x6c>
lea    0xeaa(%rip),%rsi
mov    %rbp,%rdi
call   1040 <strcmp@plt>
cmp    $0xffffffff,%eax
jne    118c <check_trace_type+0x6c>
add    %r14,%rbx
add    $0xfffffffffffffffd,%rbx
lea    0xe94(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
xor    %r15d,%r15d
cmp    $0xffffffff,%eax
sete   %r15b
or     $0x2,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"pcap\00"
@.str.1 = [5 x i8] c"dump\00"
@.str.2 = [4 x i8] c"tsh\00"
define i32 @check_trace_type(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = load i8*, i8** %3
%6 = call i64 @strlen(i8* %5)
%7 = getelementptr inbounds i8, i8* %4, i64 %6
%8 = getelementptr inbounds i8, i8* %7, i64 -4
%9 = call i32 @strcmp(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%10 = xor i32 %9, -1
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %1
store i32 1, i32* %2
br label %34
13: ; preds = %1
%14 = load i8*, i8** %3
%15 = load i8*, i8** %3
%16 = call i64 @strlen(i8* %15)
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = getelementptr inbounds i8, i8* %17, i64 -4
%19 = call i32 @strcmp(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%20 = xor i32 %19, -1
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %13
store i32 1, i32* %2
br label %34
23: ; preds = %13
%24 = load i8*, i8** %3
%25 = load i8*, i8** %3
%26 = call i64 @strlen(i8* %25)
%27 = getelementptr inbounds i8, i8* %24, i64 %26
%28 = getelementptr inbounds i8, i8* %27, i64 -3
%29 = call i32 @strcmp(i8* %28, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%30 = xor i32 %29, -1
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %23
store i32 2, i32* %2
br label %34
33: ; preds = %23
store i32 3, i32* %2
br label %34
34: ; preds = %33, %32, %22, %12
%35 = load i32, i32* %2
ret i32 %35
}

LLVM IR (-O2):
@.str = [5 x i8] c"pcap\00"
@.str.1 = [5 x i8] c"dump\00"
@.str.2 = [4 x i8] c"tsh\00"
define i32 @check_trace_type(i8* nocapture %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = getelementptr inbounds i8, i8* %0, i64 %2
%4 = getelementptr inbounds i8, i8* %3, i64 -4
%5 = tail call i32 @strcmp(i8* %4, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %15
7: ; preds = %1
%8 = tail call i32 @strcmp(i8* %4, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %15
10: ; preds = %7
%11 = getelementptr inbounds i8, i8* %3, i64 -3
%12 = tail call i32 @strcmp(i8* %11, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp eq i32 %12, -1
%14 = select i1 %13, i32 3, i32 2
br label %15
15: ; preds = %10, %7, %1
%16 = phi i32 [ 1, %1 ], [ 1, %7 ], [ %14, %10 ]
ret i32 %16
}