#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 usb_hcd {
  int dummy;
};
struct ehci_hcd {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ ehci_ppc_soc_errata(struct ehci_hcd *);
int ehci_ppc_soc_hcd_init(struct ehci_hcd *);
int ehci_run(struct usb_hcd *);
int /*<<< orphan*/ ehci_stop(struct usb_hcd *);
int /*<<< orphan*/ err(char *);
struct ehci_hcd *hcd_to_ehci(struct usb_hcd *);
int ehci_ppc_soc_start(struct usb_hcd *hcd) {
  struct ehci_hcd *ehci = hcd_to_ehci(hcd);
  int ret;
  if ((ret = ehci_ppc_soc_hcd_init(ehci)) < 0)
    return ret;
  if ((ret = ehci_run(hcd)) < 0) {
    err("can't start\n");
    ehci_stop(hcd);
    return ret;
  }
  ehci_ppc_soc_errata(ehci);
  return 0;
}


x86 assembly (clang, -O0):
<ehci_ppc_soc_start>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1080 <hcd_to_ehci@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <ehci_ppc_soc_hcd_init@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jge    1199 <ehci_ppc_soc_start+0x39>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11de <ehci_ppc_soc_start+0x7e>
mov    -0x10(%rbp),%rdi
call   1050 <ehci_run@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jge    11ce <ehci_ppc_soc_start+0x6e>
lea    0xe4b(%rip),%rdi
call   1060 <err@plt>
mov    -0x10(%rbp),%rdi
call   1030 <ehci_stop@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11de <ehci_ppc_soc_start+0x7e>
mov    -0x18(%rbp),%rdi
call   1070 <ehci_ppc_soc_errata@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ehci_ppc_soc_start>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
call   1080 <hcd_to_ehci@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <ehci_ppc_soc_hcd_init@plt>
test   %eax,%eax
js     1193 <ehci_ppc_soc_start+0x33>
mov    %r14,%rdi
call   1050 <ehci_run@plt>
test   %eax,%eax
js     1197 <ehci_ppc_soc_start+0x37>
mov    %rbx,%rdi
call   1070 <ehci_ppc_soc_errata@plt>
xor    %ebp,%ebp
jmp    11ad <ehci_ppc_soc_start+0x4d>
mov    %eax,%ebp
jmp    11ad <ehci_ppc_soc_start+0x4d>
mov    %eax,%ebp
lea    0xe60(%rip),%rdi
call   1060 <err@plt>
mov    %r14,%rdi
call   1030 <ehci_stop@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.usb_hcd = type { i32 }
%struct.ehci_hcd = type { i32 }
@.str = [13 x i8] c"can't start\0A\00"
define i32 @ehci_ppc_soc_start(%struct.usb_hcd* %0) {
%2 = alloca i32
%3 = alloca %struct.usb_hcd*
%4 = alloca %struct.ehci_hcd*
%5 = alloca i32
store %struct.usb_hcd* %0, %struct.usb_hcd** %3
%6 = load %struct.usb_hcd*, %struct.usb_hcd** %3
%7 = call %struct.ehci_hcd* @hcd_to_ehci(%struct.usb_hcd* %6)
store %struct.ehci_hcd* %7, %struct.ehci_hcd** %4
%8 = load %struct.ehci_hcd*, %struct.ehci_hcd** %4
%9 = call i32 @ehci_ppc_soc_hcd_init(%struct.ehci_hcd* %8)
store i32 %9, i32* %5
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %1
%12 = load i32, i32* %5
store i32 %12, i32* %2
br label %25
13: ; preds = %1
%14 = load %struct.usb_hcd*, %struct.usb_hcd** %3
%15 = call i32 @ehci_run(%struct.usb_hcd* %14)
store i32 %15, i32* %5
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %13
%18 = call i32 @err(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%19 = load %struct.usb_hcd*, %struct.usb_hcd** %3
%20 = call i32 @ehci_stop(%struct.usb_hcd* %19)
%21 = load i32, i32* %5
store i32 %21, i32* %2
br label %25
22: ; preds = %13
%23 = load %struct.ehci_hcd*, %struct.ehci_hcd** %4
%24 = call i32 @ehci_ppc_soc_errata(%struct.ehci_hcd* %23)
store i32 0, i32* %2
br label %25
25: ; preds = %22, %17, %11
%26 = load i32, i32* %2
ret i32 %26
}

LLVM IR (-O2):
%struct.usb_hcd = type { i32 }
%struct.ehci_hcd = type { i32 }
@.str = [13 x i8] c"can't start\0A\00"
define i32 @ehci_ppc_soc_start(%struct.usb_hcd* %0) {
%2 = tail call %struct.ehci_hcd* @hcd_to_ehci(%struct.usb_hcd* %0)
%3 = tail call i32 @ehci_ppc_soc_hcd_init(%struct.ehci_hcd* %2)
%4 = icmp slt i32 %3, 0
br i1 %4, label %13, label %5
5: ; preds = %1
%6 = tail call i32 @ehci_run(%struct.usb_hcd* %0)
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %5
%9 = tail call i32 @err(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 @ehci_stop(%struct.usb_hcd* %0)
br label %13
11: ; preds = %5
%12 = tail call i32 @ehci_ppc_soc_errata(%struct.ehci_hcd* %2)
br label %13
13: ; preds = %1, %11, %8
%14 = phi i32 [ %6, %8 ], [ 0, %11 ], [ %3, %1 ]
ret i32 %14
}