#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 */
typedef int /*<<< orphan*/ uint8_t;

/* Variables and functions */
int /*<<< orphan*/ ehrpwm_reg_config(int /*<<< orphan*/, int, unsigned char,
                                     int);
int ehrpwm_et_set_sel_evt(uint8_t module, unsigned char evt,
                          unsigned char prd) {
  if (evt > 0x7 || prd > 0x3)
    return -1;
  ehrpwm_reg_config(module, 0x32, evt, ((1 << 2) | (1 << 1) | (1 << 0)));
  ehrpwm_reg_config(module, 0x34, prd, ((1 << 1) | (1 << 0)));
  return 0;
}


x86 assembly (clang, -O0):
<ehrpwm_et_set_sel_evt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dl,%al
mov    %sil,%cl
mov    %edi,-0x8(%rbp)
mov    %cl,-0x9(%rbp)
mov    %al,-0xa(%rbp)
movzbl -0x9(%rbp),%eax
cmp    $0x7,%eax
jg     1140 <ehrpwm_et_set_sel_evt+0x30>
movzbl -0xa(%rbp),%eax
cmp    $0x3,%eax
jle    114c <ehrpwm_et_set_sel_evt+0x3c>
movl   $0xffffffff,-0x4(%rbp)
jmp    117f <ehrpwm_et_set_sel_evt+0x6f>
mov    -0x8(%rbp),%edi
mov    $0x32,%esi
mov    $0x7,%ecx
movzbl -0x9(%rbp),%edx
call   1030 <ehrpwm_reg_config@plt>
mov    -0x8(%rbp),%edi
mov    $0x34,%esi
mov    $0x3,%ecx
movzbl -0xa(%rbp),%edx
call   1030 <ehrpwm_reg_config@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ehrpwm_et_set_sel_evt>:
push   %rbp
push   %rbx
push   %rax
mov    $0xffffffff,%eax
cmp    $0x7,%sil
ja     1152 <ehrpwm_et_set_sel_evt+0x42>
mov    %edx,%ebp
cmp    $0x3,%bpl
ja     1152 <ehrpwm_et_set_sel_evt+0x42>
mov    %edi,%ebx
movzbl %sil,%edx
mov    $0x32,%esi
mov    $0x7,%ecx
call   1030 <ehrpwm_reg_config@plt>
movzbl %bpl,%edx
mov    %ebx,%edi
mov    $0x34,%esi
mov    $0x3,%ecx
call   1030 <ehrpwm_reg_config@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @ehrpwm_et_set_sel_evt(i32 %0, i8 zeroext %1, i8 zeroext %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8
%7 = alloca i8
store i32 %0, i32* %5
store i8 %1, i8* %6
store i8 %2, i8* %7
%8 = load i8, i8* %6
%9 = zext i8 %8 to i32
%10 = icmp sgt i32 %9, 7
br i1 %10, label %15, label %11
11: ; preds = %3
%12 = load i8, i8* %7
%13 = zext i8 %12 to i32
%14 = icmp sgt i32 %13, 3
br i1 %14, label %15, label %16
15: ; preds = %11, %3
store i32 -1, i32* %4
br label %23
16: ; preds = %11
%17 = load i32, i32* %5
%18 = load i8, i8* %6
%19 = call i32 @ehrpwm_reg_config(i32 %17, i32 50, i8 zeroext %18, i32 7)
%20 = load i32, i32* %5
%21 = load i8, i8* %7
%22 = call i32 @ehrpwm_reg_config(i32 %20, i32 52, i8 zeroext %21, i32 3)
store i32 0, i32* %4
br label %23
23: ; preds = %16, %15
%24 = load i32, i32* %4
ret i32 %24
}

LLVM IR (-O2):
define i32 @ehrpwm_et_set_sel_evt(i32 %0, i8 zeroext %1, i8 zeroext %2) {
%4 = icmp ugt i8 %1, 7
%5 = icmp ugt i8 %2, 3
%6 = or i1 %4, %5
br i1 %6, label %10, label %7
7: ; preds = %3
%8 = tail call i32 @ehrpwm_reg_config(i32 %0, i32 50, i8 zeroext %1, i32 7)
%9 = tail call i32 @ehrpwm_reg_config(i32 %0, i32 52, i8 zeroext %2, i32 3)
br label %10
10: ; preds = %3, %7
%11 = phi i32 [ 0, %7 ], [ -1, %3 ]
ret i32 %11
}