#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;
typedef unsigned short uint16_t;

/* Variables and functions */
unsigned short ehrpwm_read(int /*<<< orphan*/, unsigned short);
int /*<<< orphan*/ ehrpwm_write(int /*<<< orphan*/, unsigned short,
                                unsigned short);
void ehrpwm_reg_config(uint8_t module, uint16_t offset, uint16_t val,
                       uint16_t mask) {
  unsigned short read_val;
  read_val = ehrpwm_read(module, offset);
  read_val = read_val & ~mask;
  read_val = read_val | val;
  ehrpwm_write(module, offset, read_val);
}


x86 assembly (clang, -O0):
<ehrpwm_reg_config>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %cx,%ax
mov    %dx,%cx
mov    %si,%dx
mov    %edi,-0x4(%rbp)
mov    %dx,-0x6(%rbp)
mov    %cx,-0x8(%rbp)
mov    %ax,-0xa(%rbp)
mov    -0x4(%rbp),%edi
movzwl -0x6(%rbp),%esi
call   1030 <ehrpwm_read@plt>
mov    %ax,-0xc(%rbp)
movzwl -0xc(%rbp),%eax
movzwl -0xa(%rbp),%ecx
xor    $0xffffffff,%ecx
and    %ecx,%eax
mov    %ax,-0xc(%rbp)
movzwl -0xc(%rbp),%eax
movzwl -0x8(%rbp),%ecx
or     %ecx,%eax
mov    %ax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x6(%rbp),%ax
movzwl %ax,%esi
movzwl -0xc(%rbp),%edx
call   1040 <ehrpwm_write@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ehrpwm_reg_config>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%ebx
mov    %edx,%r14d
mov    %esi,%r15d
mov    %edi,%ebp
call   1030 <ehrpwm_read@plt>
not    %ebx
and    %eax,%ebx
or     %r14d,%ebx
movzwl %bx,%edx
mov    %ebp,%edi
mov    %r15d,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <ehrpwm_write@plt>

LLVM IR (-O0):
define void @ehrpwm_reg_config(i32 %0, i16 zeroext %1, i16 zeroext %2, i16 zeroext %3) {
%5 = alloca i32
%6 = alloca i16
%7 = alloca i16
%8 = alloca i16
%9 = alloca i16
store i32 %0, i32* %5
store i16 %1, i16* %6
store i16 %2, i16* %7
store i16 %3, i16* %8
%10 = load i32, i32* %5
%11 = load i16, i16* %6
%12 = call zeroext i16 @ehrpwm_read(i32 %10, i16 zeroext %11)
store i16 %12, i16* %9
%13 = load i16, i16* %9
%14 = zext i16 %13 to i32
%15 = load i16, i16* %8
%16 = zext i16 %15 to i32
%17 = xor i32 %16, -1
%18 = and i32 %14, %17
%19 = trunc i32 %18 to i16
store i16 %19, i16* %9
%20 = load i16, i16* %9
%21 = zext i16 %20 to i32
%22 = load i16, i16* %7
%23 = zext i16 %22 to i32
%24 = or i32 %21, %23
%25 = trunc i32 %24 to i16
store i16 %25, i16* %9
%26 = load i32, i32* %5
%27 = load i16, i16* %6
%28 = load i16, i16* %9
%29 = call i32 @ehrpwm_write(i32 %26, i16 zeroext %27, i16 zeroext %28)
ret void
}

LLVM IR (-O2):
define void @ehrpwm_reg_config(i32 %0, i16 zeroext %1, i16 zeroext %2, i16 zeroext %3) {
%5 = tail call zeroext i16 @ehrpwm_read(i32 %0, i16 zeroext %1)
%6 = xor i16 %3, -1
%7 = and i16 %5, %6
%8 = or i16 %7, %2
%9 = tail call i32 @ehrpwm_write(i32 %0, i16 zeroext %1, i16 zeroext %8)
ret void
}