#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 key_filenames {
  int dummy;
};

/* Variables and functions */
int ENOENT;
int EPERM;
int _keystore_exists_keyfiles(struct key_filenames *);
int /*<<< orphan*/ warnx(char *, char const *);
int _keystore_ensure_keyfiles_exist(struct key_filenames *file_names,
                                    const char *name) {
  int rc;
  rc = _keystore_exists_keyfiles(file_names);
  if (rc == 0) {
    warnx("Key '%s' does not exist", name);
    return -ENOENT;
  }
  if (rc == -1) {
    warnx("Key '%s' is in an inconsistent state", name);
    return -EPERM;
  }
  return 0;
}


x86 assembly (clang, -O0):
<_keystore_ensure_keyfiles_exist>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <_keystore_exists_keyfiles@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    1169 <_keystore_ensure_keyfiles_exist+0x49>
mov    -0x18(%rbp),%rsi
lea    0xeaf(%rip),%rdi
call   1030 <warnx@plt>
xor    %eax,%eax
mov    0x2e79(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    119d <_keystore_ensure_keyfiles_exist+0x7d>
cmpl   $0xffffffff,-0x1c(%rbp)
jne    1196 <_keystore_ensure_keyfiles_exist+0x76>
mov    -0x18(%rbp),%rsi
lea    0xe9a(%rip),%rdi
call   1030 <warnx@plt>
xor    %eax,%eax
mov    0x2e44(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    119d <_keystore_ensure_keyfiles_exist+0x7d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_keystore_ensure_keyfiles_exist>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
call   1040 <_keystore_exists_keyfiles@plt>
test   %eax,%eax
je     1149 <_keystore_ensure_keyfiles_exist+0x29>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0xffffffff,%ecx
jne    1163 <_keystore_ensure_keyfiles_exist+0x43>
mov    0x2e90(%rip),%rbx
lea    0xed1(%rip),%rdi
jmp    1157 <_keystore_ensure_keyfiles_exist+0x37>
mov    0x2e88(%rip),%rbx
lea    0xea9(%rip),%rdi
mov    %r14,%rsi
call   1030 <warnx@plt>
xor    %eax,%eax
sub    (%rbx),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.key_filenames = type { i32 }
@.str = [24 x i8] c"Key '%s' does not exist\00"
@ENOENT = global i32 0
@.str.1 = [37 x i8] c"Key '%s' is in an inconsistent state\00"
@EPERM = global i32 0
define i32 @_keystore_ensure_keyfiles_exist(%struct.key_filenames* %0, i8* %1) {
%3 = alloca i32
%4 = alloca %struct.key_filenames*
%5 = alloca i8*
%6 = alloca i32
store %struct.key_filenames* %0, %struct.key_filenames** %4
store i8* %1, i8** %5
%7 = load %struct.key_filenames*, %struct.key_filenames** %4
%8 = call i32 @_keystore_exists_keyfiles(%struct.key_filenames* %7)
store i32 %8, i32* %6
%9 = load i32, i32* %6
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load i8*, i8** %5
%13 = call i32 @warnx(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = load i32, i32* @ENOENT
%15 = sub nsw i32 0, %14
store i32 %15, i32* %3
br label %25
16: ; preds = %2
%17 = load i32, i32* %6
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %24
19: ; preds = %16
%20 = load i8*, i8** %5
%21 = call i32 @warnx(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = load i32, i32* @EPERM
%23 = sub nsw i32 0, %22
store i32 %23, i32* %3
br label %25
24: ; preds = %16
store i32 0, i32* %3
br label %25
25: ; preds = %24, %19, %11
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
%struct.key_filenames = type { i32 }
@.str = [24 x i8] c"Key '%s' does not exist\00"
@ENOENT = global i32 0
@.str.1 = [37 x i8] c"Key '%s' is in an inconsistent state\00"
@EPERM = global i32 0
define i32 @_keystore_ensure_keyfiles_exist(%struct.key_filenames* %0, i8* %1) {
%3 = tail call i32 @_keystore_exists_keyfiles(%struct.key_filenames* %0)
switch i32 %3, label %11 [
i32 0, label %5
i32 -1, label %4
]
4: ; preds = %2
br label %5
5: ; preds = %2, %4
%6 = phi i8* [ getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), %4 ], [ getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), %2 ]
%7 = phi i32* [ @EPERM, %4 ], [ @ENOENT, %2 ]
%8 = tail call i32 @warnx(i8* %6, i8* %1)
%9 = load i32, i32* %7
%10 = sub nsw i32 0, %9
br label %11
11: ; preds = %5, %2
%12 = phi i32 [ 0, %2 ], [ %10, %5 ]
ret i32 %12
}