#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__ exists_length(char *, int /*<<< orphan*/);
int /*<<< orphan*/ p_CopyFile(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
void backup(char *pfad) {
  char bak[250];
  if (exists_length(pfad, 0)) {
    strcpy(bak, pfad);
    strcpy(bak + strlen(bak) - 3, "bak");
    p_CopyFile(pfad, bak);
  }
}


x86 assembly (clang, -O0):
<backup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1040 <exists_length@plt>
cmp    $0x0,%rax
je     11ba <backup+0x7a>
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x110(%rbp),%rax
mov    %rax,-0x118(%rbp)
lea    -0x110(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x118(%rbp),%rdi
cltq
add    %rax,%rdi
add    $0xfffffffffffffffd,%rdi
lea    0xe5b(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rdi
lea    -0x110(%rbp),%rsi
call   1060 <p_CopyFile@plt>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<backup>:
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %rdi,%rbx
xor    %esi,%esi
call   1040 <exists_length@plt>
test   %rax,%rax
je     1190 <backup+0x50>
mov    %rsp,%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %r14,%rdi
call   1050 <strlen@plt>
cltq
lea    (%rsp,%rax,1),%rdi
add    $0xfffffffffffffffd,%rdi
lea    0xe80(%rip),%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <p_CopyFile@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"bak\00"
define void @backup(i8* %0) {
%2 = alloca i8*
%3 = alloca [250 x i8]
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i64 @exists_length(i8* %4, i32 0)
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %21
7: ; preds = %1
%8 = getelementptr inbounds [250 x i8], [250 x i8]* %3, i64 0, i64 0
%9 = load i8*, i8** %2
%10 = call i32 @strcpy(i8* %8, i8* %9)
%11 = getelementptr inbounds [250 x i8], [250 x i8]* %3, i64 0, i64 0
%12 = getelementptr inbounds [250 x i8], [250 x i8]* %3, i64 0, i64 0
%13 = call i32 @strlen(i8* %12)
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %11, i64 %14
%16 = getelementptr inbounds i8, i8* %15, i64 -3
%17 = call i32 @strcpy(i8* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%18 = load i8*, i8** %2
%19 = getelementptr inbounds [250 x i8], [250 x i8]* %3, i64 0, i64 0
%20 = call i32 @p_CopyFile(i8* %18, i8* %19)
br label %21
21: ; preds = %7, %1
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"bak\00"
define void @backup(i8* %0) {
%2 = alloca [250 x i8]
%3 = getelementptr inbounds [250 x i8], [250 x i8]* %2, i64 0, i64 0
%4 = tail call i64 @exists_length(i8* %0, i32 0)
%5 = icmp eq i64 %4, 0
br i1 %5, label %14, label %6
6: ; preds = %1
%7 = call i32 @strcpy(i8* %3, i8* %0)
%8 = call i32 @strlen(i8* %3)
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds [250 x i8], [250 x i8]* %2, i64 0, i64 %9
%11 = getelementptr inbounds i8, i8* %10, i64 -3
%12 = call i32 @strcpy(i8* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @p_CopyFile(i8* %0, i8* %3)
br label %14
14: ; preds = %6, %1
ret void
}