#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_tb_config_sync(uint8_t module, unsigned char phsen,
                          unsigned char syncosel) {
  if (phsen > 1 || syncosel > 0x3)
    return -1;
  ehrpwm_reg_config(module, 0x0, phsen << 0x2, (1 << 2));
  ehrpwm_reg_config(module, 0x0, syncosel << 0x4, ((1 << 5) | (1 << 4)));
  return 0;
}


x86 assembly (clang, -O0):
<ehrpwm_tb_config_sync>:
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    $0x1,%eax
jg     1140 <ehrpwm_tb_config_sync+0x30>
movzbl -0xa(%rbp),%eax
cmp    $0x3,%eax
jle    114c <ehrpwm_tb_config_sync+0x3c>
movl   $0xffffffff,-0x4(%rbp)
jmp    1185 <ehrpwm_tb_config_sync+0x75>
mov    -0x8(%rbp),%edi
movzbl -0x9(%rbp),%eax
shl    $0x2,%eax
xor    %esi,%esi
mov    $0x4,%ecx
movzbl %al,%edx
call   1030 <ehrpwm_reg_config@plt>
mov    -0x8(%rbp),%edi
movzbl -0xa(%rbp),%eax
shl    $0x4,%eax
xor    %esi,%esi
mov    $0x30,%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_tb_config_sync>:
push   %rbp
push   %r14
push   %rbx
mov    $0xffffffff,%ebx
cmp    $0x1,%sil
ja     1157 <ehrpwm_tb_config_sync+0x47>
mov    %edx,%ebp
cmp    $0x3,%bpl
ja     1157 <ehrpwm_tb_config_sync+0x47>
mov    %edi,%r14d
shl    $0x2,%sil
movzbl %sil,%edx
xor    %ebx,%ebx
xor    %esi,%esi
mov    $0x4,%ecx
call   1030 <ehrpwm_reg_config@plt>
shl    $0x4,%bpl
movzbl %bpl,%edx
mov    %r14d,%edi
xor    %esi,%esi
mov    $0x30,%ecx
call   1030 <ehrpwm_reg_config@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @ehrpwm_tb_config_sync(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, 1
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 %29
16: ; preds = %11
%17 = load i32, i32* %5
%18 = load i8, i8* %6
%19 = zext i8 %18 to i32
%20 = shl i32 %19, 2
%21 = trunc i32 %20 to i8
%22 = call i32 @ehrpwm_reg_config(i32 %17, i32 0, i8 zeroext %21, i32 4)
%23 = load i32, i32* %5
%24 = load i8, i8* %7
%25 = zext i8 %24 to i32
%26 = shl i32 %25, 4
%27 = trunc i32 %26 to i8
%28 = call i32 @ehrpwm_reg_config(i32 %23, i32 0, i8 zeroext %27, i32 48)
store i32 0, i32* %4
br label %29
29: ; preds = %16, %15
%30 = load i32, i32* %4
ret i32 %30
}

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