#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 const *, char *);
char *strrchr(char const *, char);
int checkExt(const char *filename) {
  const char *dot = strrchr(filename, '.');
  if (!dot || dot == filename) {
    return 2;
  }
  const char *ext = dot + 1;
  if (strcmp(ext, "orc") == 0) {
    return 0;
  } else if (strcmp(ext, "sco") == 0) {
    return 1;
  } else {
    return 2;
  }
}


x86 assembly (clang, -O0):
<checkExt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2e,%esi
call   1030 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1157 <checkExt+0x37>
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jne    1163 <checkExt+0x43>
movl   $0x2,-0x4(%rbp)
jmp    11c2 <checkExt+0xa2>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe86(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1195 <checkExt+0x75>
movl   $0x0,-0x4(%rbp)
jmp    11c2 <checkExt+0xa2>
mov    -0x20(%rbp),%rdi
lea    0xe64(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11bb <checkExt+0x9b>
movl   $0x1,-0x4(%rbp)
jmp    11c2 <checkExt+0xa2>
movl   $0x2,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkExt>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x2e,%esi
call   1030 <strrchr@plt>
mov    %rax,%rbx
mov    $0x2,%eax
test   %rbx,%rbx
je     117a <checkExt+0x5a>
cmp    %r14,%rbx
je     117a <checkExt+0x5a>
add    $0x1,%rbx
lea    0xeb2(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1178 <checkExt+0x58>
lea    0xea2(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
cmp    $0x1,%rax
mov    $0x2,%eax
sbb    $0x0,%eax
jmp    117a <checkExt+0x5a>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"orc\00"
@.str.1 = [4 x i8] c"sco\00"
define i32 @checkExt(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i8* @strrchr(i8* %6, i8 signext 46)
store i8* %7, i8** %4
%8 = load i8*, i8** %4
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %14
10: ; preds = %1
%11 = load i8*, i8** %4
%12 = load i8*, i8** %3
%13 = icmp eq i8* %11, %12
br i1 %13, label %14, label %15
14: ; preds = %10, %1
store i32 2, i32* %2
br label %28
15: ; preds = %10
%16 = load i8*, i8** %4
%17 = getelementptr inbounds i8, i8* %16, i64 1
store i8* %17, i8** %5
%18 = load i8*, i8** %5
%19 = call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %15
store i32 0, i32* %2
br label %28
22: ; preds = %15
%23 = load i8*, i8** %5
%24 = call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %22
store i32 1, i32* %2
br label %28
27: ; preds = %22
store i32 2, i32* %2
br label %28
28: ; preds = %27, %26, %21, %14
%29 = load i32, i32* %2
ret i32 %29
}

LLVM IR (-O2):
@.str = [4 x i8] c"orc\00"
@.str.1 = [4 x i8] c"sco\00"
define i32 @checkExt(i8* %0) {
%2 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 46)
%3 = icmp eq i8* %2, null
%4 = icmp eq i8* %2, %0
%5 = or i1 %3, %4
br i1 %5, label %14, label %6
6: ; preds = %1
%7 = getelementptr inbounds i8, i8* %2, i64 1
%8 = tail call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %6
%11 = tail call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
%13 = select i1 %12, i32 1, i32 2
br label %14
14: ; preds = %6, %10, %1
%15 = phi i32 [ 2, %1 ], [ 0, %6 ], [ %13, %10 ]
ret i32 %15
}