#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 gbphy_device {
  int dummy;
};
struct gb_connection {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ gb_connection_destroy(struct gb_connection *);
int /*<<< orphan*/ gb_connection_disable(struct gb_connection *);
struct gb_connection *gb_gbphy_get_data(struct gbphy_device *);
int /*<<< orphan*/ gb_spilib_master_exit(struct gb_connection *);
int /*<<< orphan*/ gbphy_runtime_get_noresume(struct gbphy_device *);
int gbphy_runtime_get_sync(struct gbphy_device *);
void gb_spi_remove(struct gbphy_device *gbphy_dev) {
  struct gb_connection *connection = gb_gbphy_get_data(gbphy_dev);
  int ret;
  ret = gbphy_runtime_get_sync(gbphy_dev);
  if (ret)
    gbphy_runtime_get_noresume(gbphy_dev);
  gb_spilib_master_exit(connection);
  gb_connection_disable(connection);
  gb_connection_destroy(connection);
}


x86 assembly (clang, -O0):
<gb_spi_remove>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <gb_gbphy_get_data@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <gbphy_runtime_get_sync@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1198 <gb_spi_remove+0x38>
mov    -0x8(%rbp),%rdi
call   1050 <gbphy_runtime_get_noresume@plt>
mov    -0x10(%rbp),%rdi
call   1080 <gb_spilib_master_exit@plt>
mov    -0x10(%rbp),%rdi
call   1060 <gb_connection_disable@plt>
mov    -0x10(%rbp),%rdi
call   1030 <gb_connection_destroy@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gb_spi_remove>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1070 <gb_gbphy_get_data@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1040 <gbphy_runtime_get_sync@plt>
test   %eax,%eax
je     1183 <gb_spi_remove+0x23>
mov    %rbx,%rdi
call   1050 <gbphy_runtime_get_noresume@plt>
mov    %r14,%rdi
call   1080 <gb_spilib_master_exit@plt>
mov    %r14,%rdi
call   1060 <gb_connection_disable@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <gb_connection_destroy@plt>

LLVM IR (-O0):
%struct.gbphy_device = type { i32 }
%struct.gb_connection = type { i32 }
define void @gb_spi_remove(%struct.gbphy_device* %0) {
%2 = alloca %struct.gbphy_device*
%3 = alloca %struct.gb_connection*
%4 = alloca i32
store %struct.gbphy_device* %0, %struct.gbphy_device** %2
%5 = load %struct.gbphy_device*, %struct.gbphy_device** %2
%6 = call %struct.gb_connection* @gb_gbphy_get_data(%struct.gbphy_device* %5)
store %struct.gb_connection* %6, %struct.gb_connection** %3
%7 = load %struct.gbphy_device*, %struct.gbphy_device** %2
%8 = call i32 @gbphy_runtime_get_sync(%struct.gbphy_device* %7)
store i32 %8, i32* %4
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %1
%12 = load %struct.gbphy_device*, %struct.gbphy_device** %2
%13 = call i32 @gbphy_runtime_get_noresume(%struct.gbphy_device* %12)
br label %14
14: ; preds = %11, %1
%15 = load %struct.gb_connection*, %struct.gb_connection** %3
%16 = call i32 @gb_spilib_master_exit(%struct.gb_connection* %15)
%17 = load %struct.gb_connection*, %struct.gb_connection** %3
%18 = call i32 @gb_connection_disable(%struct.gb_connection* %17)
%19 = load %struct.gb_connection*, %struct.gb_connection** %3
%20 = call i32 @gb_connection_destroy(%struct.gb_connection* %19)
ret void
}

LLVM IR (-O2):
%struct.gbphy_device = type { i32 }
%struct.gb_connection = type { i32 }
define void @gb_spi_remove(%struct.gbphy_device* %0) {
%2 = tail call %struct.gb_connection* @gb_gbphy_get_data(%struct.gbphy_device* %0)
%3 = tail call i32 @gbphy_runtime_get_sync(%struct.gbphy_device* %0)
%4 = icmp eq i32 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %1
%6 = tail call i32 @gbphy_runtime_get_noresume(%struct.gbphy_device* %0)
br label %7
7: ; preds = %5, %1
%8 = tail call i32 @gb_spilib_master_exit(%struct.gb_connection* %2)
%9 = tail call i32 @gb_connection_disable(%struct.gb_connection* %2)
%10 = tail call i32 @gb_connection_destroy(%struct.gb_connection* %2)
ret void
}