#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 *);
char *defaultext(char *fname, char *ext, int force) {
  static char result[255];
  char c, *point, *s = result;
  strcpy(result, fname);
  while (*s)
    ++s;
  point = s;
  while (c = *s, s > result && c != '.')
    --s;
  if (c == '.') {
    point = s;
    if (!force)
      return result;
  }
  strcpy(point, ext);
  return result;
}


x86 assembly (clang, -O0):
<defaultext>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
lea    0x2f16(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rsi
lea    0x2f07(%rip),%rdi
call   1030 <strcpy@plt>
mov    -0x30(%rbp),%rax
cmpb   $0x0,(%rax)
je     115c <defaultext+0x4c>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    113e <defaultext+0x2e>
mov    -0x30(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x1d(%rbp)
xor    %eax,%eax
lea    0x2eca(%rip),%rcx
cmp    %rcx,-0x30(%rbp)
mov    %al,-0x31(%rbp)
jbe    1190 <defaultext+0x80>
movsbl -0x1d(%rbp),%eax
cmp    $0x2e,%eax
setne  %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    11a0 <defaultext+0x90>
jmp    11b1 <defaultext+0xa1>
mov    -0x30(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x30(%rbp)
jmp    1164 <defaultext+0x54>
movsbl -0x1d(%rbp),%eax
cmp    $0x2e,%eax
jne    11e5 <defaultext+0xd5>
mov    -0x30(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    11e0 <defaultext+0xd0>
lea    0x2e69(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11fd <defaultext+0xed>
jmp    11e5 <defaultext+0xd5>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
lea    0x2e47(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<defaultext>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %rdi,%rsi
lea    0x2f1c(%rip),%rbp
mov    %rbp,%rdi
call   1030 <strcpy@plt>
lea    0x2f0c(%rip),%rdi
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmpb   $0x0,0x1(%rdi)
lea    0x1(%rdi),%rdi
jne    1140 <defaultext+0x30>
cmp    %rbp,%rdi
jbe    1185 <defaultext+0x75>
mov    %rdi,%rax
add    $0xffffffffffffffff,%rax
cs nopw 0x0(%rax,%rax,1)
mov    %rax,%rdx
movzbl (%rax),%ecx
add    $0xffffffffffffffff,%rax
cmp    %rbp,%rdx
jbe    1174 <defaultext+0x64>
cmp    $0x2e,%cl
jne    1160 <defaultext+0x50>
cmp    $0x2e,%cl
jne    1185 <defaultext+0x75>
test   %r14d,%r14d
je     118d <defaultext+0x7d>
add    $0x1,%rax
mov    %rax,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
lea    0x2eac(%rip),%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@defaultext.result = internal global [255 x i8] zeroinitializer
define i8* @defaultext(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8
%9 = alloca i8*
%10 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i8* getelementptr inbounds ([255 x i8], [255 x i8]* @defaultext.result, i64 0, i64 0), i8** %10
%11 = load i8*, i8** %5
%12 = call i32 @strcpy(i8* getelementptr inbounds ([255 x i8], [255 x i8]* @defaultext.result, i64 0, i64 0), i8* %11)
br label %13
13: ; preds = %17, %3
%14 = load i8*, i8** %10
%15 = load i8, i8* %14
%16 = icmp ne i8 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %13
%18 = load i8*, i8** %10
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %10
br label %13
20: ; preds = %13
%21 = load i8*, i8** %10
store i8* %21, i8** %9
br label %22
22: ; preds = %33, %20
%23 = load i8*, i8** %10
%24 = load i8, i8* %23
store i8 %24, i8* %8
%25 = load i8*, i8** %10
%26 = icmp ugt i8* %25, getelementptr inbounds ([255 x i8], [255 x i8]* @defaultext.result, i64 0, i64 0)
br i1 %26, label %27, label %31
27: ; preds = %22
%28 = load i8, i8* %8
%29 = sext i8 %28 to i32
%30 = icmp ne i32 %29, 46
br label %31
31: ; preds = %27, %22
%32 = phi i1 [ false, %22 ], [ %30, %27 ]
br i1 %32, label %33, label %36
33: ; preds = %31
%34 = load i8*, i8** %10
%35 = getelementptr inbounds i8, i8* %34, i32 -1
store i8* %35, i8** %10
br label %22
36: ; preds = %31
%37 = load i8, i8* %8
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %38, 46
br i1 %39, label %40, label %46
40: ; preds = %36
%41 = load i8*, i8** %10
store i8* %41, i8** %9
%42 = load i32, i32* %7
%43 = icmp ne i32 %42, 0
br i1 %43, label %45, label %44
44: ; preds = %40
store i8* getelementptr inbounds ([255 x i8], [255 x i8]* @defaultext.result, i64 0, i64 0), i8** %4
br label %50
45: ; preds = %40
br label %46
46: ; preds = %45, %36
%47 = load i8*, i8** %9
%48 = load i8*, i8** %6
%49 = call i32 @strcpy(i8* %47, i8* %48)
store i8* getelementptr inbounds ([255 x i8], [255 x i8]* @defaultext.result, i64 0, i64 0), i8** %4
br label %50
50: ; preds = %46, %44
%51 = load i8*, i8** %4
ret i8* %51
}

LLVM IR (-O2):
@defaultext.result = internal global [255 x i8] zeroinitializer
define i8* @defaultext(i8* %0, i8* %1, i32 %2) {
%4 = tail call i32 @strcpy(i8* getelementptr inbounds ([255 x i8], [255 x i8]* @defaultext.result, i64 0, i64 0), i8* %0)
br label %5
5: ; preds = %5, %3
%6 = phi i8* [ getelementptr inbounds ([255 x i8], [255 x i8]* @defaultext.result, i64 0, i64 0), %3 ], [ %9, %5 ]
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 0
%9 = getelementptr inbounds i8, i8* %6, i64 1
br i1 %8, label %10, label %5
10: ; preds = %5
%11 = icmp ugt i8* %6, getelementptr inbounds ([255 x i8], [255 x i8]* @defaultext.result, i64 0, i64 0)
br i1 %11, label %12, label %23
12: ; preds = %10, %12
%13 = phi i8* [ %14, %12 ], [ %6, %10 ]
%14 = getelementptr inbounds i8, i8* %13, i64 -1
%15 = load i8, i8* %14
%16 = icmp ugt i8* %14, getelementptr inbounds ([255 x i8], [255 x i8]* @defaultext.result, i64 0, i64 0)
%17 = icmp ne i8 %15, 46
%18 = select i1 %16, i1 %17, i1 false
br i1 %18, label %12, label %19
19: ; preds = %12
%20 = icmp eq i8 %15, 46
br i1 %20, label %21, label %23
21: ; preds = %19
%22 = icmp eq i32 %2, 0
br i1 %22, label %26, label %23
23: ; preds = %10, %21, %19
%24 = phi i8* [ %14, %21 ], [ %6, %19 ], [ %6, %10 ]
%25 = tail call i32 @strcpy(i8* %24, i8* %1)
br label %26
26: ; preds = %21, %23
ret i8* getelementptr inbounds ([255 x i8], [255 x i8]* @defaultext.result, i64 0, i64 0)
}