#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 uint32_t;
typedef int ui32Base;

/* Variables and functions */
void PWMGenPeriodSet(uint32_t ui32Base, uint32_t ui32Gen, uint32_t ui32Period) {
  ;
  ;
  ui32Gen = ((ui32Base) + (ui32Gen));
  if ((*((volatile unsigned long *)(ui32Gen + 0x00000000))) & 0x00000002) {
    ;
    (*((volatile unsigned long *)(ui32Gen + 0x00000010))) = ui32Period / 2;
  } else {
    ;
    (*((volatile unsigned long *)(ui32Gen + 0x00000010))) = ui32Period - 1;
  }
}


x86 assembly (clang, -O0):
<PWMGenPeriodSet>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x0,%eax
cltq
mov    (%rax),%rax
and    $0x2,%rax
cmp    $0x0,%rax
je     114d <PWMGenPeriodSet+0x4d>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
movslq %eax,%rcx
mov    -0x8(%rbp),%eax
add    $0x10,%eax
cltq
mov    %rcx,(%rax)
jmp    1161 <PWMGenPeriodSet+0x61>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
movslq %eax,%rcx
mov    -0x8(%rbp),%eax
add    $0x10,%eax
cltq
mov    %rcx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<PWMGenPeriodSet>:
movslq %esi,%rax
movslq %edi,%rcx
testq  $0x2,(%rax,%rcx,1)
jne    1117 <PWMGenPeriodSet+0x17>
add    $0xffffffff,%edx
mov    %edx,%esi
jmp    1120 <PWMGenPeriodSet+0x20>
mov    %edx,%esi
shr    $0x1f,%esi
add    %edx,%esi
sar    %esi
movslq %esi,%rdx
mov    %rdx,0x10(%rcx,%rax,1)
ret

LLVM IR (-O0):
define void @PWMGenPeriodSet(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i32, i32* %4
%8 = load i32, i32* %5
%9 = add nsw i32 %7, %8
store i32 %9, i32* %5
%10 = load i32, i32* %5
%11 = add nsw i32 %10, 0
%12 = sext i32 %11 to i64
%13 = inttoptr i64 %12 to i64*
%14 = load volatile i64, i64* %13
%15 = and i64 %14, 2
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %25
17: ; preds = %3
%18 = load i32, i32* %6
%19 = sdiv i32 %18, 2
%20 = sext i32 %19 to i64
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 16
%23 = sext i32 %22 to i64
%24 = inttoptr i64 %23 to i64*
store volatile i64 %20, i64* %24
br label %33
25: ; preds = %3
%26 = load i32, i32* %6
%27 = sub nsw i32 %26, 1
%28 = sext i32 %27 to i64
%29 = load i32, i32* %5
%30 = add nsw i32 %29, 16
%31 = sext i32 %30 to i64
%32 = inttoptr i64 %31 to i64*
store volatile i64 %28, i64* %32
br label %33
33: ; preds = %25, %17
ret void
}

LLVM IR (-O2):
define void @PWMGenPeriodSet(i32 %0, i32 %1, i32 %2) {
%4 = add nsw i32 %1, %0
%5 = sext i32 %4 to i64
%6 = inttoptr i64 %5 to i64*
%7 = load volatile i64, i64* %6
%8 = and i64 %7, 2
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %3
%11 = sdiv i32 %2, 2
br label %14
12: ; preds = %3
%13 = add nsw i32 %2, -1
br label %14
14: ; preds = %12, %10
%15 = phi i32 [ %13, %12 ], [ %11, %10 ]
%16 = sext i32 %15 to i64
%17 = add nsw i32 %4, 16
%18 = sext i32 %17 to i64
%19 = inttoptr i64 %18 to i64*
store volatile i64 %16, i64* %19
ret void
}