#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_pc_configure(uint8_t module, unsigned char chpduty,
                        unsigned char chpfreq, unsigned char oshtwidth) {
  if (chpduty > 0x7 || chpfreq > 0x7 || oshtwidth > 0xf)
    return -1;
  ehrpwm_reg_config(module, 0x3C, chpduty << 0x8,
                    ((1 << 10) | (1 << 9) | (1 << 8)));
  ehrpwm_reg_config(module, 0x3C, chpfreq << 0x5,
                    ((1 << 7) | (1 << 6) | (1 << 5)));
  ehrpwm_reg_config(module, 0x3C, oshtwidth << 0x1,
                    ((1 << 4) | (1 << 3) | (1 << 2) | (1 << 1)));
  return 0;
}


x86 assembly (clang, -O0):
<ehrpwm_pc_configure>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %cl,%al
mov    %dl,%cl
mov    %sil,%dl
mov    %edi,-0x8(%rbp)
mov    %dl,-0x9(%rbp)
mov    %cl,-0xa(%rbp)
mov    %al,-0xb(%rbp)
movzbl -0x9(%rbp),%eax
cmp    $0x7,%eax
jg     1152 <ehrpwm_pc_configure+0x42>
movzbl -0xa(%rbp),%eax
cmp    $0x7,%eax
jg     1152 <ehrpwm_pc_configure+0x42>
movzbl -0xb(%rbp),%eax
cmp    $0xf,%eax
jle    115e <ehrpwm_pc_configure+0x4e>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b9 <ehrpwm_pc_configure+0xa9>
mov    -0x8(%rbp),%edi
movzbl -0x9(%rbp),%eax
shl    $0x8,%eax
mov    $0x3c,%esi
mov    $0x700,%ecx
movzbl %al,%edx
call   1030 <ehrpwm_reg_config@plt>
mov    -0x8(%rbp),%edi
movzbl -0xa(%rbp),%eax
shl    $0x5,%eax
mov    $0x3c,%esi
mov    $0xe0,%ecx
movzbl %al,%edx
call   1030 <ehrpwm_reg_config@plt>
mov    -0x8(%rbp),%edi
movzbl -0xb(%rbp),%eax
shl    $0x1,%eax
mov    $0x3c,%esi
mov    $0x1e,%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_pc_configure>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
or     %edx,%esi
mov    $0xffffffff,%r14d
cmp    $0x7,%sil
ja     1177 <ehrpwm_pc_configure+0x67>
mov    %ecx,%ebp
cmp    $0xf,%bpl
ja     1177 <ehrpwm_pc_configure+0x67>
mov    %edx,%ebx
mov    %edi,%r15d
xor    %r14d,%r14d
mov    $0x3c,%esi
xor    %edx,%edx
mov    $0x700,%ecx
call   1030 <ehrpwm_reg_config@plt>
shl    $0x5,%bl
movzbl %bl,%edx
mov    %r15d,%edi
mov    $0x3c,%esi
mov    $0xe0,%ecx
call   1030 <ehrpwm_reg_config@plt>
add    %bpl,%bpl
movzbl %bpl,%edx
mov    %r15d,%edi
mov    $0x3c,%esi
mov    $0x1e,%ecx
call   1030 <ehrpwm_reg_config@plt>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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