#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*/ strcat(char *, char *);
scalar_t__ strcmp(char *, char *);
int strlen(char *);
void append_postfix(char *filename, char *affix) {
  if ((strcmp(&filename[strlen(filename) - strlen(affix)], affix)) &&
      ((filename[strlen(filename) - 1]) != '.'))
    strcat(filename, affix);
}


x86 assembly (clang, -O0):
<append_postfix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
sub    %ecx,%eax
cltq
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     11b7 <append_postfix+0x87>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
je     11b7 <append_postfix+0x87>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <strcat@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<append_postfix>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1030 <strlen@plt>
sub    %eax,%ebp
movslq %ebp,%rdi
add    %rbx,%rdi
mov    %r14,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     116f <append_postfix+0x3f>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
cmpb   $0x2e,-0x1(%rax,%rbx,1)
jne    1174 <append_postfix+0x44>
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    %rbx,%rdi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <strcat@plt>

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

LLVM IR (-O2):
define void @append_postfix(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = tail call i32 @strlen(i8* %1)
%5 = sub nsw i32 %3, %4
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds i8, i8* %0, i64 %6
%8 = tail call i64 @strcmp(i8* %7, i8* %1)
%9 = icmp eq i64 %8, 0
br i1 %9, label %19, label %10
10: ; preds = %2
%11 = tail call i32 @strlen(i8* %0)
%12 = add nsw i32 %11, -1
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %0, i64 %13
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 46
br i1 %16, label %19, label %17
17: ; preds = %10
%18 = tail call i32 @strcat(i8* %0, i8* %1)
br label %19
19: ; preds = %17, %10, %2
ret void
}