#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 xswitch {
  int dummy;
};
struct entity {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ del_dangling_hosts();
int /*<<< orphan*/ topo_del_switch(struct entity *);
struct entity *topo_get_switch(int /*<<< orphan*/);
int /*<<< orphan*/ topo_print();
int /*<<< orphan*/ topo_unlock();
int /*<<< orphan*/ topo_wrlock();
int /*<<< orphan*/ xlog(int, char *);
int /*<<< orphan*/ xswitch_get_dpid(struct xswitch *);
void topo_switch_down(struct xswitch *sw) {
  struct entity *esw;
  topo_wrlock();
  xlog(16, "-----switch down--------\n");
  esw = topo_get_switch(xswitch_get_dpid(sw));
  topo_del_switch(esw);
  del_dangling_hosts();
  topo_print();
  topo_unlock();
}


x86 assembly (clang, -O0):
<topo_switch_down>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1070 <topo_wrlock@plt>
mov    $0x10,%edi
lea    0xe61(%rip),%rsi
call   1050 <xlog@plt>
mov    -0x8(%rbp),%rdi
call   10a0 <xswitch_get_dpid@plt>
mov    %eax,%edi
call   1060 <topo_get_switch@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <topo_del_switch@plt>
mov    $0x0,%al
call   1080 <del_dangling_hosts@plt>
mov    $0x0,%al
call   1030 <topo_print@plt>
mov    $0x0,%al
call   1090 <topo_unlock@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<topo_switch_down>:
push   %rbx
mov    %rdi,%rbx
xor    %eax,%eax
call   1070 <topo_wrlock@plt>
lea    0xe6e(%rip),%rsi
mov    $0x10,%edi
call   1050 <xlog@plt>
mov    %rbx,%rdi
call   10a0 <xswitch_get_dpid@plt>
mov    %eax,%edi
call   1060 <topo_get_switch@plt>
mov    %rax,%rdi
call   1040 <topo_del_switch@plt>
xor    %eax,%eax
call   1080 <del_dangling_hosts@plt>
xor    %eax,%eax
call   1030 <topo_print@plt>
xor    %eax,%eax
pop    %rbx
jmp    1090 <topo_unlock@plt>

LLVM IR (-O0):
%struct.xswitch = type { i32 }
%struct.entity = type { i32 }
@.str = [26 x i8] c"-----switch down--------\0A\00"
define void @topo_switch_down(%struct.xswitch* %0) {
%2 = alloca %struct.xswitch*
%3 = alloca %struct.entity*
store %struct.xswitch* %0, %struct.xswitch** %2
%4 = call i32 (...) @topo_wrlock()
%5 = call i32 @xlog(i32 16, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%6 = load %struct.xswitch*, %struct.xswitch** %2
%7 = call i32 @xswitch_get_dpid(%struct.xswitch* %6)
%8 = call %struct.entity* @topo_get_switch(i32 %7)
store %struct.entity* %8, %struct.entity** %3
%9 = load %struct.entity*, %struct.entity** %3
%10 = call i32 @topo_del_switch(%struct.entity* %9)
%11 = call i32 (...) @del_dangling_hosts()
%12 = call i32 (...) @topo_print()
%13 = call i32 (...) @topo_unlock()
ret void
}

LLVM IR (-O2):
%struct.xswitch = type { i32 }
%struct.entity = type { i32 }
@.str = [26 x i8] c"-----switch down--------\0A\00"
define void @topo_switch_down(%struct.xswitch* %0) {
%2 = tail call i32 (...) @topo_wrlock()
%3 = tail call i32 @xlog(i32 16, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @xswitch_get_dpid(%struct.xswitch* %0)
%5 = tail call %struct.entity* @topo_get_switch(i32 %4)
%6 = tail call i32 @topo_del_switch(%struct.entity* %5)
%7 = tail call i32 (...) @del_dangling_hosts()
%8 = tail call i32 (...) @topo_print()
%9 = tail call i32 (...) @topo_unlock()
ret void
}