#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 */
struct stat {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
int stat(char *, struct stat *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int /*<<< orphan*/ system(char *);
void file_backup(char *src) {
  struct stat stStat;
  char dst[strlen(src) + 5];
  char ext[] = ".bkp";
  strcpy(dst, src);
  strcat(dst, ext);
  int errcode = stat("uv", &stStat);
  if (errcode == 0) {
  }
  char cmd[strlen(dst) * 2 + 10];
  sprintf(cmd, "cp %s %s", src, dst);
  system(cmd);
}


x86 assembly (clang, -O0):
<file_backup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
add    $0x5,%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x40(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x20(%rbp)
mov    0xe5f(%rip),%eax
mov    %eax,-0x25(%rbp)
mov    0xe5a(%rip),%al
mov    %al,-0x21(%rbp)
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x40(%rbp),%rdi
lea    -0x25(%rbp),%rsi
call   1070 <strcat@plt>
lea    0xe3b(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1060 <stat@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jne    11e5 <file_backup+0x85>
jmp    11e5 <file_backup+0x85>
mov    -0x40(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x40(%rbp),%rcx
mov    %eax,%edx
mov    %edx,%eax
lea    0xa(%rax,%rax,1),%eax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rdi
sub    %rdx,%rdi
mov    %rdi,-0x48(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rdx
lea    0xde7(%rip),%rsi
call   1080 <sprintf@plt>
mov    -0x48(%rbp),%rdi
call   1050 <system@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<file_backup>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
call   1040 <strlen@plt>
mov    %rsp,%r12
add    $0x5,%eax
mov    %rsp,%r15
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
movb   $0x0,-0x24(%rbp)
movl   $0x706b622e,-0x28(%rbp)
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
lea    -0x28(%rbp),%rsi
mov    %r15,%rdi
call   1070 <strcat@plt>
lea    0xe4e(%rip),%rdi
lea    -0x30(%rbp),%rsi
call   1060 <stat@plt>
mov    %r15,%rdi
call   1040 <strlen@plt>
add    %eax,%eax
add    $0xa,%eax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%rbx
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xe23(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
mov    %r15,%rcx
call   1080 <sprintf@plt>
mov    %rbx,%rdi
call   1050 <system@plt>
mov    %r12,%rsp
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@__const.file_backup.ext = [5 x i8] c".bkp\00"
@.str = [3 x i8] c"uv\00"
@.str.1 = [9 x i8] c"cp %s %s\00"
define void @file_backup(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.stat
%4 = alloca i8*
%5 = alloca i64
%6 = alloca [5 x i8]
%7 = alloca i32
%8 = alloca i64
store i8* %0, i8** %2
%9 = load i8*, i8** %2
%10 = call i32 @strlen(i8* %9)
%11 = add nsw i32 %10, 5
%12 = zext i32 %11 to i64
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %4
%14 = alloca i8, i64 %12
store i64 %12, i64* %5
%15 = bitcast [5 x i8]* %6 to i8*
%16 = load i8*, i8** %2
%17 = call i32 @strcpy(i8* %14, i8* %16)
%18 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%19 = call i32 @strcat(i8* %14, i8* %18)
%20 = call i32 @stat(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %struct.stat* %3)
store i32 %20, i32* %7
%21 = load i32, i32* %7
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %1
br label %24
24: ; preds = %23, %1
%25 = call i32 @strlen(i8* %14)
%26 = mul nsw i32 %25, 2
%27 = add nsw i32 %26, 10
%28 = zext i32 %27 to i64
%29 = alloca i8, i64 %28
store i64 %28, i64* %8
%30 = load i8*, i8** %2
%31 = call i32 @sprintf(i8* %29, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %30, i8* %14)
%32 = call i32 @system(i8* %29)
%33 = load i8*, i8** %4
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@__const.file_backup.ext = [5 x i8] c".bkp\00"
@.str = [3 x i8] c"uv\00"
@.str.1 = [9 x i8] c"cp %s %s\00"
define void @file_backup(i8* %0) {
%2 = alloca %struct.stat
%3 = alloca [5 x i8]
%4 = bitcast %struct.stat* %2 to i8*
%5 = tail call i32 @strlen(i8* %0)
%6 = add nsw i32 %5, 5
%7 = zext i32 %6 to i64
%8 = tail call i8* @llvm.stacksave()
%9 = alloca i8, i64 %7
%10 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%11 = call i32 @strcpy(i8* %9, i8* %0)
%12 = call i32 @strcat(i8* %9, i8* %10)
%13 = call i32 @stat(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %struct.stat* %2)
%14 = call i32 @strlen(i8* %9)
%15 = shl nsw i32 %14, 1
%16 = add nsw i32 %15, 10
%17 = zext i32 %16 to i64
%18 = alloca i8, i64 %17
%19 = call i32 @sprintf(i8* %18, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %9)
%20 = call i32 @system(i8* %18)
ret void
}