#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*/ crash();
scalar_t__ stat(char const *, struct stat *);
int /*<<< orphan*/ warn(char *, char const *);
int /*<<< orphan*/ warnx(char *, char const *);
void checkfiles(const char *infile, const char *outfile) {
  struct stat buf;
  if (infile)
    if (stat(infile, &buf) < 0) {
      warn("%s", infile);
      crash();
    };
  if (outfile) {
    if (stat(outfile, &buf) < 0)
      return;
    else {
      warnx("file '%s' already exists and may be overwritten", outfile);
      crash();
    }
  }
}


x86 assembly (clang, -O0):
<checkfiles>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     118e <checkfiles+0x4e>
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1060 <stat@plt>
cmp    $0x0,%rax
jge    1189 <checkfiles+0x49>
mov    -0x8(%rbp),%rsi
lea    0xe83(%rip),%rdi
call   1040 <warn@plt>
mov    $0x0,%al
call   1030 <crash@plt>
jmp    118e <checkfiles+0x4e>
cmpq   $0x0,-0x10(%rbp)
je     11d1 <checkfiles+0x91>
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1060 <stat@plt>
cmp    $0x0,%rax
jge    11b5 <checkfiles+0x75>
jmp    11d1 <checkfiles+0x91>
mov    -0x10(%rbp),%rsi
lea    0xe43(%rip),%rdi
call   1050 <warnx@plt>
mov    $0x0,%al
call   1030 <crash@plt>
jmp    11d1 <checkfiles+0x91>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkfiles>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
test   %rdi,%rdi
je     115c <checkfiles+0x1c>
mov    %rdi,%rbx
mov    %rsp,%rsi
call   1060 <stat@plt>
test   %rax,%rax
js     1189 <checkfiles+0x49>
test   %r14,%r14
je     11a4 <checkfiles+0x64>
mov    %rsp,%rsi
mov    %r14,%rdi
call   1060 <stat@plt>
test   %rax,%rax
js     11a4 <checkfiles+0x64>
lea    0xe8b(%rip),%rdi
mov    %r14,%rsi
call   1050 <warnx@plt>
xor    %eax,%eax
call   1030 <crash@plt>
jmp    11a4 <checkfiles+0x64>
lea    0xe70(%rip),%rdi
mov    %rbx,%rsi
call   1040 <warn@plt>
xor    %eax,%eax
call   1030 <crash@plt>
test   %r14,%r14
jne    1161 <checkfiles+0x21>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [3 x i8] c"%s\00"
@.str.1 = [48 x i8] c"file '%s' already exists and may be overwritten\00"
define void @checkfiles(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca %struct.stat
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %3
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %17
8: ; preds = %2
%9 = load i8*, i8** %3
%10 = call i64 @stat(i8* %9, %struct.stat* %5)
%11 = icmp slt i64 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %8
%13 = load i8*, i8** %3
%14 = call i32 @warn(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = call i32 (...) @crash()
br label %16
16: ; preds = %12, %8
br label %17
17: ; preds = %16, %2
%18 = load i8*, i8** %4
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %30
20: ; preds = %17
%21 = load i8*, i8** %4
%22 = call i64 @stat(i8* %21, %struct.stat* %5)
%23 = icmp slt i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %20
br label %30
25: ; preds = %20
%26 = load i8*, i8** %4
%27 = call i32 @warnx(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i8* %26)
%28 = call i32 (...) @crash()
br label %29
29: ; preds = %25
br label %30
30: ; preds = %24, %29, %17
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [3 x i8] c"%s\00"
@.str.1 = [48 x i8] c"file '%s' already exists and may be overwritten\00"
define void @checkfiles(i8* %0, i8* %1) {
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %3 to i8*
%5 = icmp eq i8* %0, null
br i1 %5, label %12, label %6
6: ; preds = %2
%7 = call i64 @stat(i8* %0, %struct.stat* %3)
%8 = icmp slt i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %6
%10 = call i32 @warn(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %0)
%11 = call i32 (...) @crash()
br label %12
12: ; preds = %6, %9, %2
%13 = icmp eq i8* %1, null
br i1 %13, label %20, label %14
14: ; preds = %12
%15 = call i64 @stat(i8* %1, %struct.stat* %3)
%16 = icmp slt i64 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %14
%18 = call i32 @warnx(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%19 = call i32 (...) @crash()
br label %20
20: ; preds = %12, %17, %14
ret void
}