#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*/ snprintf(char *, int, char *, char const *, ...);
scalar_t__ system(char *);
int update_old_pls(const char *old_pls, const char *new_pls) {
  char cmdx[300];
  snprintf(cmdx, 300, "sudo rm -f %s", old_pls);
  if (system(cmdx) == 0) {
    snprintf(cmdx, 300, "sudo mv -f \"%s\" \"%s\"", new_pls, old_pls);
    return (system(cmdx) == 0) ? 0 : -1;
  } else {
    return -1;
  }
}


x86 assembly (clang, -O0):
<update_old_pls>:
push   %rbp
mov    %rsp,%rbp
sub    $0x150,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x150(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x12c,%esi
lea    0xeb6(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
lea    -0x150(%rbp),%rdi
call   1030 <system@plt>
cmp    $0x0,%rax
jne    11ae <update_old_pls+0x8e>
lea    -0x150(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%r8
mov    $0x12c,%esi
lea    0xe8c(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
lea    -0x150(%rbp),%rdi
call   1030 <system@plt>
mov    %rax,%rdx
mov    $0xffffffff,%eax
xor    %ecx,%ecx
cmp    $0x0,%rdx
cmove  %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    11b5 <update_old_pls+0x95>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x150,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<update_old_pls>:
push   %r15
push   %r14
push   %rbx
sub    $0x130,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xec7(%rip),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x12c,%esi
mov    %r15,%rcx
xor    %eax,%eax
call   1040 <snprintf@plt>
mov    %rbx,%rdi
call   1030 <system@plt>
mov    %rax,%rcx
mov    $0xffffffff,%eax
test   %rcx,%rcx
jne    118f <update_old_pls+0x6f>
lea    0xea4(%rip),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x12c,%esi
mov    %r14,%rcx
mov    %r15,%r8
xor    %eax,%eax
call   1040 <snprintf@plt>
mov    %rbx,%rdi
call   1030 <system@plt>
neg    %rax
sbb    %eax,%eax
add    $0x130,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [14 x i8] c"sudo rm -f %s\00"
@.str.1 = [21 x i8] c"sudo mv -f \22%s\22 \22%s\22\00"
define i32 @update_old_pls(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [300 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = getelementptr inbounds [300 x i8], [300 x i8]* %6, i64 0, i64 0
%8 = load i8*, i8** %4
%9 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %7, i32 300, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = getelementptr inbounds [300 x i8], [300 x i8]* %6, i64 0, i64 0
%11 = call i64 @system(i8* %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %23
13: ; preds = %2
%14 = getelementptr inbounds [300 x i8], [300 x i8]* %6, i64 0, i64 0
%15 = load i8*, i8** %5
%16 = load i8*, i8** %4
%17 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %14, i32 300, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %15, i8* %16)
%18 = getelementptr inbounds [300 x i8], [300 x i8]* %6, i64 0, i64 0
%19 = call i64 @system(i8* %18)
%20 = icmp eq i64 %19, 0
%21 = zext i1 %20 to i64
%22 = select i1 %20, i32 0, i32 -1
store i32 %22, i32* %3
br label %24
23: ; preds = %2
store i32 -1, i32* %3
br label %24
24: ; preds = %23, %13
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
@.str = [14 x i8] c"sudo rm -f %s\00"
@.str.1 = [21 x i8] c"sudo mv -f \22%s\22 \22%s\22\00"
define i32 @update_old_pls(i8* %0, i8* %1) {
%3 = alloca [300 x i8]
%4 = getelementptr inbounds [300 x i8], [300 x i8]* %3, i64 0, i64 0
%5 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %4, i32 300, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %0)
%6 = call i64 @system(i8* %4)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %4, i32 300, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %1, i8* %0)
%10 = call i64 @system(i8* %4)
%11 = icmp ne i64 %10, 0
%12 = sext i1 %11 to i32
br label %13
13: ; preds = %2, %8
%14 = phi i32 [ %12, %8 ], [ -1, %2 ]
ret i32 %14
}