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

/* Variables and functions */
int /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int ioctl(int, int, struct ipl_block_fcp *);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
int get_fcp_info(struct ipl_block_fcp *fcp_info) {
  int fh = -1, rc = 0;
  fh = open("/dev/zcore", O_RDWR);
  if (fh == -1) {
    {
      fprintf(stderr, "ERROR: ");
      fprintf(stderr, "open %s failed", "/dev/zcore");
      perror("");
    };
    rc = -1;
    goto out;
  }
  if (ioctl(fh, 0x1, fcp_info) == -1) {
    {
      fprintf(stderr, "ERROR: ");
      fprintf(stderr, "ioctl 'get fcp parms' failed");
      perror("");
    };
    rc = -1;
    goto out;
  }
out:
  if (fh != -1)
    close(fh);
  return rc;
}


x86 assembly (clang, -O0):
<get_fcp_info>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0xffffffff,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    0x2e77(%rip),%rax
mov    (%rax),%esi
lea    0xe86(%rip),%rdi
call   1060 <open@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    11d9 <get_fcp_info+0x89>
mov    0x2e45(%rip),%rax
mov    (%rax),%edi
lea    0xe6f(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2e2e(%rip),%rax
mov    (%rax),%edi
lea    0xe60(%rip),%rsi
lea    0xe46(%rip),%rdx
mov    $0x0,%al
call   1050 <fprintf@plt>
lea    0xe4a(%rip),%rdi
call   1070 <perror@plt>
movl   $0xffffffff,-0x10(%rbp)
jmp    123e <get_fcp_info+0xee>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%rdx
mov    $0x1,%esi
call   1030 <ioctl@plt>
cmp    $0xffffffff,%eax
jne    1239 <get_fcp_info+0xe9>
mov    0x2dde(%rip),%rax
mov    (%rax),%edi
lea    0xe08(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2dc7(%rip),%rax
mov    (%rax),%edi
lea    0xe08(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
lea    0xdea(%rip),%rdi
call   1070 <perror@plt>
movl   $0xffffffff,-0x10(%rbp)
jmp    123e <get_fcp_info+0xee>
jmp    123e <get_fcp_info+0xee>
cmpl   $0xffffffff,-0xc(%rbp)
je     1250 <get_fcp_info+0x100>
mov    -0xc(%rbp),%edi
call   1040 <close@plt>
mov    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_fcp_info>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbp
mov    0x2e8b(%rip),%rax
mov    (%rax),%esi
lea    0xe9a(%rip),%rdi
call   1060 <open@plt>
cmp    $0xffffffff,%eax
je     1198 <get_fcp_info+0x48>
mov    %eax,%ebx
mov    %eax,%edi
mov    $0x1,%esi
mov    %rbp,%rdx
call   1030 <ioctl@plt>
xor    %ebp,%ebp
cmp    $0xffffffff,%eax
je     11d9 <get_fcp_info+0x89>
mov    %ebx,%edi
call   1040 <close@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2e39(%rip),%rbx
mov    (%rbx),%edi
lea    0xe63(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe5b(%rip),%rsi
lea    0xe41(%rip),%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    0xe45(%rip),%rdi
call   1070 <perror@plt>
mov    $0xffffffff,%ebp
jmp    118f <get_fcp_info+0x3f>
mov    0x2df8(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xe21(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xe27(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    0xe09(%rip),%rdi
call   1070 <perror@plt>
mov    $0xffffffff,%ebp
jmp    1188 <get_fcp_info+0x38>

LLVM IR (-O0):
%struct.ipl_block_fcp = type { i32 }
@.str = [11 x i8] c"/dev/zcore\00"
@O_RDWR = global i32 0
@stderr = global i32 0
@.str.1 = [8 x i8] c"ERROR: \00"
@.str.2 = [15 x i8] c"open %s failed\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [29 x i8] c"ioctl 'get fcp parms' failed\00"
define i32 @get_fcp_info(%struct.ipl_block_fcp* %0) {
%2 = alloca %struct.ipl_block_fcp*
%3 = alloca i32
%4 = alloca i32
store %struct.ipl_block_fcp* %0, %struct.ipl_block_fcp** %2
store i32 -1, i32* %3
store i32 0, i32* %4
%5 = load i32, i32* @O_RDWR
%6 = call i32 @open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %5)
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %15
9: ; preds = %1
%10 = load i32, i32* @stderr
%11 = call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%12 = load i32, i32* @stderr
%13 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @perror(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %4
br label %27
15: ; preds = %1
%16 = load i32, i32* %3
%17 = load %struct.ipl_block_fcp*, %struct.ipl_block_fcp** %2
%18 = call i32 @ioctl(i32 %16, i32 1, %struct.ipl_block_fcp* %17)
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %26
20: ; preds = %15
%21 = load i32, i32* @stderr
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%23 = load i32, i32* @stderr
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
%25 = call i32 @perror(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %4
br label %27
26: ; preds = %15
br label %27
27: ; preds = %26, %20, %9
%28 = load i32, i32* %3
%29 = icmp ne i32 %28, -1
br i1 %29, label %30, label %33
30: ; preds = %27
%31 = load i32, i32* %3
%32 = call i32 @close(i32 %31)
br label %33
33: ; preds = %30, %27
%34 = load i32, i32* %4
ret i32 %34
}

LLVM IR (-O2):
%struct.ipl_block_fcp = type { i32 }
@.str = [11 x i8] c"/dev/zcore\00"
@O_RDWR = global i32 0
@stderr = global i32 0
@.str.1 = [8 x i8] c"ERROR: \00"
@.str.2 = [15 x i8] c"open %s failed\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [29 x i8] c"ioctl 'get fcp parms' failed\00"
define i32 @get_fcp_info(%struct.ipl_block_fcp* %0) {
%2 = load i32, i32* @O_RDWR
%3 = tail call i32 @open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %2)
%4 = icmp eq i32 %3, -1
br i1 %4, label %14, label %5
5: ; preds = %1
%6 = tail call i32 @ioctl(i32 %3, i32 1, %struct.ipl_block_fcp* %0)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %20
8: ; preds = %5
%9 = load i32, i32* @stderr
%10 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%11 = load i32, i32* @stderr
%12 = tail call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
%13 = tail call i32 @perror(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
br label %20
14: ; preds = %1
%15 = load i32, i32* @stderr
%16 = tail call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%17 = load i32, i32* @stderr
%18 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%19 = tail call i32 @perror(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
br label %23
20: ; preds = %5, %8
%21 = phi i32 [ 0, %5 ], [ -1, %8 ]
%22 = tail call i32 @close(i32 %3)
br label %23
23: ; preds = %14, %20
%24 = phi i32 [ %21, %20 ], [ -1, %14 ]
ret i32 %24
}