#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 */

/* Variables and functions */
int /*<<< orphan*/ _pwmss_eqep_clk_disable(unsigned int);
scalar_t__ _pwmss_eqep_clk_status_get(unsigned int);
int /*<<< orphan*/ _pwmss_eqep_clk_status_set(unsigned int, int /*<<< orphan*/);
int pwmss_eqep_clk_disable(unsigned int device_id) {
  if (device_id > 2) {
    return -1;
  }
  if (_pwmss_eqep_clk_status_get(device_id) == 0) {
    return 1;
  }
  _pwmss_eqep_clk_disable(device_id);
  _pwmss_eqep_clk_status_set(device_id, 0);
  return 0;
}


x86 assembly (clang, -O0):
<pwmss_eqep_clk_disable>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0x2,-0x8(%rbp)
jbe    1151 <pwmss_eqep_clk_disable+0x21>
movl   $0xffffffff,-0x4(%rbp)
jmp    1188 <pwmss_eqep_clk_disable+0x58>
mov    -0x8(%rbp),%edi
call   1030 <_pwmss_eqep_clk_status_get@plt>
cmp    $0x0,%rax
jne    116f <pwmss_eqep_clk_disable+0x3f>
movl   $0x1,-0x4(%rbp)
jmp    1188 <pwmss_eqep_clk_disable+0x58>
mov    -0x8(%rbp),%edi
call   1040 <_pwmss_eqep_clk_disable@plt>
mov    -0x8(%rbp),%edi
xor    %esi,%esi
call   1050 <_pwmss_eqep_clk_status_set@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pwmss_eqep_clk_disable>:
push   %rbp
push   %rbx
push   %rax
mov    $0xffffffff,%ebp
cmp    $0x2,%edi
ja     1162 <pwmss_eqep_clk_disable+0x32>
mov    %edi,%ebx
call   1030 <_pwmss_eqep_clk_status_get@plt>
test   %rax,%rax
je     115d <pwmss_eqep_clk_disable+0x2d>
mov    %ebx,%edi
call   1040 <_pwmss_eqep_clk_disable@plt>
xor    %ebp,%ebp
mov    %ebx,%edi
xor    %esi,%esi
call   1050 <_pwmss_eqep_clk_status_set@plt>
jmp    1162 <pwmss_eqep_clk_disable+0x32>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @pwmss_eqep_clk_disable(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp ugt i32 %4, 2
br i1 %5, label %6, label %7
6: ; preds = %1
store i32 -1, i32* %2
br label %17
7: ; preds = %1
%8 = load i32, i32* %3
%9 = call i64 @_pwmss_eqep_clk_status_get(i32 %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %7
store i32 1, i32* %2
br label %17
12: ; preds = %7
%13 = load i32, i32* %3
%14 = call i32 @_pwmss_eqep_clk_disable(i32 %13)
%15 = load i32, i32* %3
%16 = call i32 @_pwmss_eqep_clk_status_set(i32 %15, i32 0)
store i32 0, i32* %2
br label %17
17: ; preds = %12, %11, %6
%18 = load i32, i32* %2
ret i32 %18
}

LLVM IR (-O2):
define i32 @pwmss_eqep_clk_disable(i32 %0) {
%2 = icmp ugt i32 %0, 2
br i1 %2, label %9, label %3
3: ; preds = %1
%4 = tail call i64 @_pwmss_eqep_clk_status_get(i32 %0)
%5 = icmp eq i64 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %3
%7 = tail call i32 @_pwmss_eqep_clk_disable(i32 %0)
%8 = tail call i32 @_pwmss_eqep_clk_status_set(i32 %0, i32 0)
br label %9
9: ; preds = %3, %1, %6
%10 = phi i32 [ 0, %6 ], [ -1, %1 ], [ 1, %3 ]
ret i32 %10
}