#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 */
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
char *strrchr(char const *, char);
char tolower(char const);
void get_extension(char dst[4], const char *src) {
  const char *tmp;
  int ii;
  memset(dst, 0, 4);
  tmp = strrchr(src, '.');
  if (tmp) {
    for (ii = 0; ii < 4; ii++) {
      dst[ii] = tolower(tmp[ii]);
    }
  }
}


x86 assembly (clang, -O0):
<get_extension>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
mov    -0x10(%rbp),%rdi
mov    $0x2e,%esi
call   1030 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11af <get_extension+0x7f>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x4,-0x1c(%rbp)
jge    11aa <get_extension+0x7a>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1050 <tolower@plt>
mov    %al,%dl
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1174 <get_extension+0x44>
jmp    11af <get_extension+0x7f>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_extension>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
mov    %rbx,%rdi
mov    $0x2e,%esi
call   1030 <strrchr@plt>
test   %rax,%rax
je     118d <get_extension+0x5d>
mov    %rax,%rbx
movsbl (%rax),%edi
call   1050 <tolower@plt>
mov    %al,(%r14)
movsbl 0x1(%rbx),%edi
call   1050 <tolower@plt>
mov    %al,0x1(%r14)
movsbl 0x2(%rbx),%edi
call   1050 <tolower@plt>
mov    %al,0x2(%r14)
movsbl 0x3(%rbx),%edi
call   1050 <tolower@plt>
mov    %al,0x3(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @get_extension(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
%8 = call i32 @memset(i8* %7, i32 0, i32 4)
%9 = load i8*, i8** %4
%10 = call i8* @strrchr(i8* %9, i8 signext 46)
store i8* %10, i8** %5
%11 = load i8*, i8** %5
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %32
13: ; preds = %2
store i32 0, i32* %6
br label %14
14: ; preds = %28, %13
%15 = load i32, i32* %6
%16 = icmp slt i32 %15, 4
br i1 %16, label %17, label %31
17: ; preds = %14
%18 = load i8*, i8** %5
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = load i8, i8* %21
%23 = call signext i8 @tolower(i8 signext %22)
%24 = load i8*, i8** %3
%25 = load i32, i32* %6
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
store i8 %23, i8* %27
br label %28
28: ; preds = %17
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 1
store i32 %30, i32* %6
br label %14
31: ; preds = %14
br label %32
32: ; preds = %31, %2
ret void
}

LLVM IR (-O2):
define void @get_extension(i8* %0, i8* %1) {
%3 = tail call i32 @memset(i8* %0, i32 0, i32 4)
%4 = tail call i8* @strrchr(i8* dereferenceable(1) %1, i8 signext 46)
%5 = icmp eq i8* %4, null
br i1 %5, label %21, label %6
6: ; preds = %2
%7 = load i8, i8* %4
%8 = tail call signext i8 @tolower(i8 signext %7)
store i8 %8, i8* %0
%9 = getelementptr inbounds i8, i8* %4, i64 1
%10 = load i8, i8* %9
%11 = tail call signext i8 @tolower(i8 signext %10)
%12 = getelementptr inbounds i8, i8* %0, i64 1
store i8 %11, i8* %12
%13 = getelementptr inbounds i8, i8* %4, i64 2
%14 = load i8, i8* %13
%15 = tail call signext i8 @tolower(i8 signext %14)
%16 = getelementptr inbounds i8, i8* %0, i64 2
store i8 %15, i8* %16
%17 = getelementptr inbounds i8, i8* %4, i64 3
%18 = load i8, i8* %17
%19 = tail call signext i8 @tolower(i8 signext %18)
%20 = getelementptr inbounds i8, i8* %0, i64 3
store i8 %19, i8* %20
br label %21
21: ; preds = %6, %2
ret void
}