#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
scalar_t__ strcmp(char *, char *);
void overwrite_prevent(int argc, char **argv) {
  if (argc == 4) {
    if ((strcmp(argv[1], argv[3]) == 0) || (strcmp(argv[2], argv[3]) == 0)) {
      printf("Please do not use any input files as output!\n");
      exit(EXIT_FAILURE);
    }
  }
}


x86 assembly (clang, -O0):
<overwrite_prevent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x4(%rbp)
jne    11a6 <overwrite_prevent+0x76>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     1187 <overwrite_prevent+0x57>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11a1 <overwrite_prevent+0x71>
lea    0xe72(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e46(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
jmp    11a6 <overwrite_prevent+0x76>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<overwrite_prevent>:
push   %rbx
cmp    $0x4,%edi
jne    115d <overwrite_prevent+0x2d>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
mov    0x18(%rsi),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     115f <overwrite_prevent+0x2f>
mov    0x10(%rbx),%rdi
mov    0x18(%rbx),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     115f <overwrite_prevent+0x2f>
pop    %rbx
ret
lea    0xe9a(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e6e(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [46 x i8] c"Please do not use any input files as output!\0A\00"
@EXIT_FAILURE = global i32 0
define void @overwrite_prevent(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
store i32 %0, i32* %3
store i8** %1, i8*** %4
%5 = load i32, i32* %3
%6 = icmp eq i32 %5, 4
br i1 %6, label %7, label %30
7: ; preds = %2
%8 = load i8**, i8*** %4
%9 = getelementptr inbounds i8*, i8** %8, i64 1
%10 = load i8*, i8** %9
%11 = load i8**, i8*** %4
%12 = getelementptr inbounds i8*, i8** %11, i64 3
%13 = load i8*, i8** %12
%14 = call i64 @strcmp(i8* %10, i8* %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %25, label %16
16: ; preds = %7
%17 = load i8**, i8*** %4
%18 = getelementptr inbounds i8*, i8** %17, i64 2
%19 = load i8*, i8** %18
%20 = load i8**, i8*** %4
%21 = getelementptr inbounds i8*, i8** %20, i64 3
%22 = load i8*, i8** %21
%23 = call i64 @strcmp(i8* %19, i8* %22)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %16, %7
%26 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%27 = load i32, i32* @EXIT_FAILURE
%28 = call i32 @exit(i32 %27)
unreachable
29: ; preds = %16
br label %30
30: ; preds = %29, %2
ret void
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@str = [45 x i8] c"Please do not use any input files as output!\00"
define void @overwrite_prevent(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 4
br i1 %3, label %4, label %21
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = getelementptr inbounds i8*, i8** %1, i64 3
%8 = load i8*, i8** %7
%9 = tail call i64 @strcmp(i8* %6, i8* %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %17, label %11
11: ; preds = %4
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = load i8*, i8** %7
%15 = tail call i64 @strcmp(i8* %13, i8* %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %11, %4
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str, i64 0, i64 0))
%19 = load i32, i32* @EXIT_FAILURE
%20 = tail call i32 @exit(i32 %19)
unreachable
21: ; preds = %11, %2
ret void
}