#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*/ R_OK;
scalar_t__ access(char *, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, char const *);
int isccwdev(const char *devno) {
  char path[4096];
  sprintf(path, "/sys/bus/ccw/drivers/dasd-eckd/%s", devno);
  if (access(path, R_OK) == 0)
    return 0;
  sprintf(path, "/sys/bus/ccw/drivers/dasd-fba/%s", devno);
  if (access(path, R_OK) == 0)
    return 0;
  return -1;
}


x86 assembly (clang, -O0):
<isccwdev>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1010,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x1010(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xebf(%rip),%rsi
call   1040 <sprintf@plt>
lea    -0x1010(%rbp),%rdi
mov    0x2e8c(%rip),%rax
mov    (%rax),%esi
call   1030 <access@plt>
cmp    $0x0,%rax
jne    1171 <isccwdev+0x51>
movl   $0x0,-0x4(%rbp)
jmp    11ba <isccwdev+0x9a>
lea    -0x1010(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe9f(%rip),%rsi
call   1040 <sprintf@plt>
lea    -0x1010(%rbp),%rdi
mov    0x2e4a(%rip),%rax
mov    (%rax),%esi
call   1030 <access@plt>
cmp    $0x0,%rax
jne    11b3 <isccwdev+0x93>
movl   $0x0,-0x4(%rbp)
jmp    11ba <isccwdev+0x9a>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1010,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isccwdev>:
push   %r15
push   %r14
push   %rbx
sub    $0x1000,%rsp
mov    %rdi,%rbx
lea    0xeca(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
mov    %rbx,%rdx
call   1040 <sprintf@plt>
mov    0x2e95(%rip),%r15
mov    (%r15),%esi
mov    %r14,%rdi
call   1030 <access@plt>
test   %rax,%rax
je     1182 <isccwdev+0x62>
lea    0xec0(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
mov    %rbx,%rdx
call   1040 <sprintf@plt>
mov    (%r15),%esi
mov    %r14,%rdi
call   1030 <access@plt>
neg    %rax
sbb    %eax,%eax
jmp    1184 <isccwdev+0x64>
xor    %eax,%eax
add    $0x1000,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [34 x i8] c"/sys/bus/ccw/drivers/dasd-eckd/%s\00"
@R_OK = global i32 0
@.str.1 = [33 x i8] c"/sys/bus/ccw/drivers/dasd-fba/%s\00"
define i32 @isccwdev(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [4096 x i8]
store i8* %0, i8** %3
%5 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%6 = load i8*, i8** %3
%7 = call i32 @sprintf(i8* %5, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%9 = load i32, i32* @R_OK
%10 = call i64 @access(i8* %8, i32 %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %1
store i32 0, i32* %2
br label %23
13: ; preds = %1
%14 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%15 = load i8*, i8** %3
%16 = call i32 @sprintf(i8* %14, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%18 = load i32, i32* @R_OK
%19 = call i64 @access(i8* %17, i32 %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %13
store i32 0, i32* %2
br label %23
22: ; preds = %13
store i32 -1, i32* %2
br label %23
23: ; preds = %22, %21, %12
%24 = load i32, i32* %2
ret i32 %24
}

LLVM IR (-O2):
@.str = [34 x i8] c"/sys/bus/ccw/drivers/dasd-eckd/%s\00"
@R_OK = global i32 0
@.str.1 = [33 x i8] c"/sys/bus/ccw/drivers/dasd-fba/%s\00"
define i32 @isccwdev(i8* %0) {
%2 = alloca [4096 x i8]
%3 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
%4 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = load i32, i32* @R_OK
%6 = call i64 @access(i8* %3, i32 %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %14, label %8
8: ; preds = %1
%9 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%10 = load i32, i32* @R_OK
%11 = call i64 @access(i8* %3, i32 %10)
%12 = icmp ne i64 %11, 0
%13 = sext i1 %12 to i32
br label %14
14: ; preds = %8, %1
%15 = phi i32 [ 0, %1 ], [ %13, %8 ]
ret i32 %15
}