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

/* Variables and functions */
int /*<<< orphan*/ pci_disable_device(struct pci_dev *);
int pci_enable_device(struct pci_dev *);
int pci_request_regions(struct pci_dev *, char const *);
int comedi_pci_enable(struct pci_dev *pdev, const char *res_name) {
  int rc;
  rc = pci_enable_device(pdev);
  if (rc < 0)
    return rc;
  rc = pci_request_regions(pdev, res_name);
  if (rc < 0)
    pci_disable_device(pdev);
  return rc;
}


x86 assembly (clang, -O0):
<comedi_pci_enable>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <pci_enable_device@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    1161 <comedi_pci_enable+0x31>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    118a <comedi_pci_enable+0x5a>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <pci_request_regions@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    1184 <comedi_pci_enable+0x54>
mov    -0x10(%rbp),%rdi
call   1040 <pci_disable_device@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<comedi_pci_enable>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
call   1050 <pci_enable_device@plt>
test   %eax,%eax
js     115f <comedi_pci_enable+0x2f>
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <pci_request_regions@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    1161 <comedi_pci_enable+0x31>
mov    %r14,%rdi
call   1040 <pci_disable_device@plt>
jmp    1161 <comedi_pci_enable+0x31>
mov    %eax,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.pci_dev = type { i32 }
define i32 @comedi_pci_enable(%struct.pci_dev* %0, i8* %1) {
%3 = alloca i32
%4 = alloca %struct.pci_dev*
%5 = alloca i8*
%6 = alloca i32
store %struct.pci_dev* %0, %struct.pci_dev** %4
store i8* %1, i8** %5
%7 = load %struct.pci_dev*, %struct.pci_dev** %4
%8 = call i32 @pci_enable_device(%struct.pci_dev* %7)
store i32 %8, i32* %6
%9 = load i32, i32* %6
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = load i32, i32* %6
store i32 %12, i32* %3
br label %24
13: ; preds = %2
%14 = load %struct.pci_dev*, %struct.pci_dev** %4
%15 = load i8*, i8** %5
%16 = call i32 @pci_request_regions(%struct.pci_dev* %14, i8* %15)
store i32 %16, i32* %6
%17 = load i32, i32* %6
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %13
%20 = load %struct.pci_dev*, %struct.pci_dev** %4
%21 = call i32 @pci_disable_device(%struct.pci_dev* %20)
br label %22
22: ; preds = %19, %13
%23 = load i32, i32* %6
store i32 %23, i32* %3
br label %24
24: ; preds = %22, %11
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
%struct.pci_dev = type { i32 }
define i32 @comedi_pci_enable(%struct.pci_dev* %0, i8* %1) {
%3 = tail call i32 @pci_enable_device(%struct.pci_dev* %0)
%4 = icmp slt i32 %3, 0
br i1 %4, label %10, label %5
5: ; preds = %2
%6 = tail call i32 @pci_request_regions(%struct.pci_dev* %0, i8* %1)
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = tail call i32 @pci_disable_device(%struct.pci_dev* %0)
br label %10
10: ; preds = %5, %8, %2
%11 = phi i32 [ %3, %2 ], [ %6, %8 ], [ %6, %5 ]
ret i32 %11
}