#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 const *);
int strlen(char const *);
char *CheckExtension(const char *pString, const char *pExt) {
  int position = strlen(pString) - 1;
  for (; position >= 0; position--) {
    if (pString[position] == '.') {
      if (strcmp(&pString[++position], pExt) == 0)
        return (char *)&pString[position];
      else
        break;
    }
  }
  return NULL;
}


x86 assembly (clang, -O0):
<CheckExtension>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jl     11af <CheckExtension+0x8f>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    119c <CheckExtension+0x7c>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cltq
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1197 <CheckExtension+0x77>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
jmp    11b7 <CheckExtension+0x97>
jmp    11af <CheckExtension+0x8f>
jmp    11a1 <CheckExtension+0x81>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    113f <CheckExtension+0x1f>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CheckExtension>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %eax,%ecx
add    %rbx,%rcx
add    $0x1,%rcx
nopl   0x0(%rax,%rax,1)
test   %eax,%eax
jle    1164 <CheckExtension+0x44>
lea    -0x1(%rcx),%rbx
add    $0xffffffff,%eax
cmpb   $0x2e,-0x2(%rcx)
mov    %rbx,%rcx
jne    1140 <CheckExtension+0x20>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1166 <CheckExtension+0x46>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @CheckExtension(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %4
%8 = call i32 @strlen(i8* %7)
%9 = sub nsw i32 %8, 1
store i32 %9, i32* %6
br label %10
10: ; preds = %37, %2
%11 = load i32, i32* %6
%12 = icmp sge i32 %11, 0
br i1 %12, label %13, label %40
13: ; preds = %10
%14 = load i8*, i8** %4
%15 = load i32, i32* %6
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 46
br i1 %20, label %21, label %36
21: ; preds = %13
%22 = load i8*, i8** %4
%23 = load i32, i32* %6
%24 = add nsw i32 %23, 1
store i32 %24, i32* %6
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %22, i64 %25
%27 = load i8*, i8** %5
%28 = call i64 @strcmp(i8* %26, i8* %27)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %35
30: ; preds = %21
%31 = load i8*, i8** %4
%32 = load i32, i32* %6
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
store i8* %34, i8** %3
br label %41
35: ; preds = %21
br label %40
36: ; preds = %13
br label %37
37: ; preds = %36
%38 = load i32, i32* %6
%39 = add nsw i32 %38, -1
store i32 %39, i32* %6
br label %10
40: ; preds = %35, %10
store i8* null, i8** %3
br label %41
41: ; preds = %40, %30
%42 = load i8*, i8** %3
ret i8* %42
}

LLVM IR (-O2):
define i8* @CheckExtension(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = zext i32 %3 to i64
br label %5
5: ; preds = %10, %2
%6 = phi i64 [ %7, %10 ], [ %4, %2 ]
%7 = add nsw i64 %6, -1
%8 = trunc i64 %6 to i32
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %19
10: ; preds = %5
%11 = getelementptr inbounds i8, i8* %0, i64 %7
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 46
br i1 %13, label %14, label %5
14: ; preds = %10
%15 = and i64 %6, 4294967295
%16 = getelementptr inbounds i8, i8* %0, i64 %15
%17 = tail call i64 @strcmp(i8* %16, i8* %1)
%18 = icmp eq i64 %17, 0
br i1 %18, label %20, label %19
19: ; preds = %5, %14
br label %20
20: ; preds = %14, %19
%21 = phi i8* [ null, %19 ], [ %16, %14 ]
ret i8* %21
}