#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*/ strcpy(char *, char const *);
scalar_t__ strlen(char const *);
int getExt(char *dest, const char *line) {
  int i;
  int len = (int)strlen(line);
  for (i = len; i > 0; --i) {
    if (line[i] == '.')
      break;
  }
  if (i == 0)
    return 0;
  strcpy(dest, &line[i]);
  return 1;
}


x86 assembly (clang, -O0):
<getExt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    1179 <getExt+0x59>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    1166 <getExt+0x46>
jmp    1179 <getExt+0x59>
jmp    116b <getExt+0x4b>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    1142 <getExt+0x22>
cmpl   $0x0,-0x1c(%rbp)
jne    118f <getExt+0x6f>
movl   $0x0,-0x4(%rbp)
jmp    11aa <getExt+0x8a>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
movslq -0x1c(%rbp),%rax
add    %rax,%rsi
call   1030 <strcpy@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getExt>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    1154 <getExt+0x34>
cs nopw 0x0(%rax,%rax,1)
mov    %eax,%ecx
cmpb   $0x2e,(%rbx,%rcx,1)
je     1156 <getExt+0x36>
lea    -0x1(%rax),%ecx
cmp    $0x1,%eax
mov    %ecx,%eax
jg     1140 <getExt+0x20>
jmp    116d <getExt+0x4d>
je     116d <getExt+0x4d>
cltq
add    %rax,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    $0x1,%eax
jmp    116f <getExt+0x4f>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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