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

/* Variables and functions */
struct tag_osn_state *ons_get_common_parent_state(struct tag_osn_state *,
                                                  struct tag_osn_state *);
int /*<<< orphan*/ osn_enter_state(struct tag_osn_state *,
                                   struct tag_osn_state *);
int /*<<< orphan*/ osn_exit_state(struct tag_osn_state *,
                                  struct tag_osn_state *);
void osn_change_state(struct tag_osn_state *new_state,
                      struct tag_osn_state *old_state) {
  if (new_state != old_state) {
    struct tag_osn_state *parent_state;
    parent_state = ons_get_common_parent_state(new_state, old_state);
    osn_exit_state(parent_state, old_state);
    osn_enter_state(parent_state, new_state);
  }
}


x86 assembly (clang, -O0):
<osn_change_state>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cmp    -0x10(%rbp),%rax
je     1179 <osn_change_state+0x49>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <ons_get_common_parent_state@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <osn_exit_state@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <osn_enter_state@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<osn_change_state>:
cmp    %rsi,%rdi
je     1163 <osn_change_state+0x33>
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
call   1040 <ons_get_common_parent_state@plt>
mov    %rax,%r15
mov    %rax,%rdi
mov    %rbx,%rsi
call   1050 <osn_exit_state@plt>
mov    %r15,%rdi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <osn_enter_state@plt>
ret

LLVM IR (-O0):
%struct.tag_osn_state = type { i32 }
define void @osn_change_state(%struct.tag_osn_state* %0, %struct.tag_osn_state* %1) {
%3 = alloca %struct.tag_osn_state*
%4 = alloca %struct.tag_osn_state*
%5 = alloca %struct.tag_osn_state*
store %struct.tag_osn_state* %0, %struct.tag_osn_state** %3
store %struct.tag_osn_state* %1, %struct.tag_osn_state** %4
%6 = load %struct.tag_osn_state*, %struct.tag_osn_state** %3
%7 = load %struct.tag_osn_state*, %struct.tag_osn_state** %4
%8 = icmp ne %struct.tag_osn_state* %6, %7
br i1 %8, label %9, label %19
9: ; preds = %2
%10 = load %struct.tag_osn_state*, %struct.tag_osn_state** %3
%11 = load %struct.tag_osn_state*, %struct.tag_osn_state** %4
%12 = call %struct.tag_osn_state* @ons_get_common_parent_state(%struct.tag_osn_state* %10, %struct.tag_osn_state* %11)
store %struct.tag_osn_state* %12, %struct.tag_osn_state** %5
%13 = load %struct.tag_osn_state*, %struct.tag_osn_state** %5
%14 = load %struct.tag_osn_state*, %struct.tag_osn_state** %4
%15 = call i32 @osn_exit_state(%struct.tag_osn_state* %13, %struct.tag_osn_state* %14)
%16 = load %struct.tag_osn_state*, %struct.tag_osn_state** %5
%17 = load %struct.tag_osn_state*, %struct.tag_osn_state** %3
%18 = call i32 @osn_enter_state(%struct.tag_osn_state* %16, %struct.tag_osn_state* %17)
br label %19
19: ; preds = %9, %2
ret void
}

LLVM IR (-O2):
%struct.tag_osn_state = type { i32 }
define void @osn_change_state(%struct.tag_osn_state* %0, %struct.tag_osn_state* %1) {
%3 = icmp eq %struct.tag_osn_state* %0, %1
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = tail call %struct.tag_osn_state* @ons_get_common_parent_state(%struct.tag_osn_state* %0, %struct.tag_osn_state* %1)
%6 = tail call i32 @osn_exit_state(%struct.tag_osn_state* %5, %struct.tag_osn_state* %1)
%7 = tail call i32 @osn_enter_state(%struct.tag_osn_state* %5, %struct.tag_osn_state* %0)
br label %8
8: ; preds = %4, %2
ret void
}