#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_cmp_set_cmp_ctl(uint8_t module, unsigned char shdwamode,
                           unsigned char shdwbmode, unsigned char loadamode,
                           unsigned char loadbmode) {
  if (shdwamode > 0x1 || shdwbmode > 0x1 || loadamode > 0x3 || loadbmode > 0x3)
    return -1;
  ehrpwm_reg_config(module, 0xE, shdwamode << 0x4, (1 << 4));
  ehrpwm_reg_config(module, 0xE, shdwbmode << 0x6, (1 << 6));
  ehrpwm_reg_config(module, 0xE, loadamode, ((1 << 1) | (1 << 0)));
  ehrpwm_reg_config(module, 0xE, loadbmode << 0x2, ((1 << 3) | (1 << 2)));
  return 0;
}


x86 assembly (clang, -O0):
<ehrpwm_cmp_set_cmp_ctl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %r8b,%al
mov    %edi,-0x8(%rbp)
mov    %sil,-0x9(%rbp)
mov    %dl,-0xa(%rbp)
mov    %cl,-0xb(%rbp)
mov    %al,-0xc(%rbp)
movzbl -0x9(%rbp),%eax
cmp    $0x1,%eax
jg     115f <ehrpwm_cmp_set_cmp_ctl+0x4f>
movzbl -0xa(%rbp),%eax
cmp    $0x1,%eax
jg     115f <ehrpwm_cmp_set_cmp_ctl+0x4f>
movzbl -0xb(%rbp),%eax
cmp    $0x3,%eax
jg     115f <ehrpwm_cmp_set_cmp_ctl+0x4f>
movzbl -0xc(%rbp),%eax
cmp    $0x3,%eax
jle    116b <ehrpwm_cmp_set_cmp_ctl+0x5b>
movl   $0xffffffff,-0x4(%rbp)
jmp    11dc <ehrpwm_cmp_set_cmp_ctl+0xcc>
mov    -0x8(%rbp),%edi
movzbl -0x9(%rbp),%eax
shl    $0x4,%eax
mov    $0xe,%esi
mov    $0x10,%ecx
movzbl %al,%edx
call   1030 <ehrpwm_reg_config@plt>
mov    -0x8(%rbp),%edi
movzbl -0xa(%rbp),%eax
shl    $0x6,%eax
mov    $0xe,%esi
mov    $0x40,%ecx
movzbl %al,%edx
call   1030 <ehrpwm_reg_config@plt>
mov    -0x8(%rbp),%edi
mov    $0xe,%esi
mov    $0x3,%ecx
movzbl -0xb(%rbp),%edx
call   1030 <ehrpwm_reg_config@plt>
mov    -0x8(%rbp),%edi
movzbl -0xc(%rbp),%eax
shl    $0x2,%eax
mov    $0xe,%esi
mov    $0xc,%ecx
movzbl %al,%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_cmp_set_cmp_ctl>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %edx,%ebp
mov    %ebp,%ecx
or     %sil,%cl
mov    $0xffffffff,%eax
cmp    $0x1,%cl
ja     119c <ehrpwm_cmp_set_cmp_ctl+0x8c>
mov    %r8d,%ebx
mov    %ebx,%ecx
or     %r14b,%cl
cmp    $0x3,%cl
ja     119c <ehrpwm_cmp_set_cmp_ctl+0x8c>
mov    %edi,%r15d
shl    $0x4,%sil
movzbl %sil,%edx
mov    $0xe,%esi
mov    $0x10,%ecx
call   1030 <ehrpwm_reg_config@plt>
shl    $0x6,%bpl
movzbl %bpl,%edx
mov    %r15d,%edi
mov    $0xe,%esi
mov    $0x40,%ecx
call   1030 <ehrpwm_reg_config@plt>
movzbl %r14b,%edx
mov    %r15d,%edi
mov    $0xe,%esi
mov    $0x3,%ecx
call   1030 <ehrpwm_reg_config@plt>
shl    $0x2,%bl
movzbl %bl,%edx
mov    %r15d,%edi
mov    $0xe,%esi
mov    $0xc,%ecx
call   1030 <ehrpwm_reg_config@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @ehrpwm_cmp_set_cmp_ctl(i32 %0, i8 zeroext %1, i8 zeroext %2, i8 zeroext %3, i8 zeroext %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8
%9 = alloca i8
%10 = alloca i8
%11 = alloca i8
store i32 %0, i32* %7
store i8 %1, i8* %8
store i8 %2, i8* %9
store i8 %3, i8* %10
store i8 %4, i8* %11
%12 = load i8, i8* %8
%13 = zext i8 %12 to i32
%14 = icmp sgt i32 %13, 1
br i1 %14, label %27, label %15
15: ; preds = %5
%16 = load i8, i8* %9
%17 = zext i8 %16 to i32
%18 = icmp sgt i32 %17, 1
br i1 %18, label %27, label %19
19: ; preds = %15
%20 = load i8, i8* %10
%21 = zext i8 %20 to i32
%22 = icmp sgt i32 %21, 3
br i1 %22, label %27, label %23
23: ; preds = %19
%24 = load i8, i8* %11
%25 = zext i8 %24 to i32
%26 = icmp sgt i32 %25, 3
br i1 %26, label %27, label %28
27: ; preds = %23, %19, %15, %5
store i32 -1, i32* %6
br label %50
28: ; preds = %23
%29 = load i32, i32* %7
%30 = load i8, i8* %8
%31 = zext i8 %30 to i32
%32 = shl i32 %31, 4
%33 = trunc i32 %32 to i8
%34 = call i32 @ehrpwm_reg_config(i32 %29, i32 14, i8 zeroext %33, i32 16)
%35 = load i32, i32* %7
%36 = load i8, i8* %9
%37 = zext i8 %36 to i32
%38 = shl i32 %37, 6
%39 = trunc i32 %38 to i8
%40 = call i32 @ehrpwm_reg_config(i32 %35, i32 14, i8 zeroext %39, i32 64)
%41 = load i32, i32* %7
%42 = load i8, i8* %10
%43 = call i32 @ehrpwm_reg_config(i32 %41, i32 14, i8 zeroext %42, i32 3)
%44 = load i32, i32* %7
%45 = load i8, i8* %11
%46 = zext i8 %45 to i32
%47 = shl i32 %46, 2
%48 = trunc i32 %47 to i8
%49 = call i32 @ehrpwm_reg_config(i32 %44, i32 14, i8 zeroext %48, i32 12)
store i32 0, i32* %6
br label %50
50: ; preds = %28, %27
%51 = load i32, i32* %6
ret i32 %51
}

LLVM IR (-O2):
define i32 @ehrpwm_cmp_set_cmp_ctl(i32 %0, i8 zeroext %1, i8 zeroext %2, i8 zeroext %3, i8 zeroext %4) {
%6 = or i8 %2, %1
%7 = icmp ugt i8 %6, 1
%8 = or i8 %4, %3
%9 = icmp ugt i8 %8, 3
%10 = or i1 %7, %9
br i1 %10, label %19, label %11
11: ; preds = %5
%12 = shl nuw nsw i8 %1, 4
%13 = tail call i32 @ehrpwm_reg_config(i32 %0, i32 14, i8 zeroext %12, i32 16)
%14 = shl nuw nsw i8 %2, 6
%15 = tail call i32 @ehrpwm_reg_config(i32 %0, i32 14, i8 zeroext %14, i32 64)
%16 = tail call i32 @ehrpwm_reg_config(i32 %0, i32 14, i8 zeroext %3, i32 3)
%17 = shl nuw nsw i8 %4, 2
%18 = tail call i32 @ehrpwm_reg_config(i32 %0, i32 14, i8 zeroext %17, i32 12)
br label %19
19: ; preds = %5, %11
%20 = phi i32 [ 0, %11 ], [ -1, %5 ]
ret i32 %20
}