#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 uint32_t *)(ui32Gen + 0x00000000))) & 0x00000002) {
    ;
    (*((volatile uint32_t *)(ui32Gen + 0x00000010))) = ui32Period / 2;
  } else {
    ;
    (*((volatile uint32_t *)(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),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     1148 <PWMGenPeriodSet+0x48>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x8(%rbp),%eax
add    $0x10,%eax
cltq
mov    %ecx,(%rax)
jmp    1158 <PWMGenPeriodSet+0x58>
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x8(%rbp),%eax
add    $0x10,%eax
cltq
mov    %ecx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<PWMGenPeriodSet>:
movslq %esi,%rax
movslq %edi,%rcx
testl  $0x2,(%rax,%rcx,1)
jne    1117 <PWMGenPeriodSet+0x17>
add    $0xffffffff,%edx
mov    %edx,0x10(%rcx,%rax,1)
ret
mov    %edx,%esi
shr    $0x1f,%esi
add    %edx,%esi
sar    %esi
mov    %esi,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 i32*
%14 = load volatile i32, i32* %13
%15 = and i32 %14, 2
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %24
17: ; preds = %3
%18 = load i32, i32* %6
%19 = sdiv i32 %18, 2
%20 = load i32, i32* %5
%21 = add nsw i32 %20, 16
%22 = sext i32 %21 to i64
%23 = inttoptr i64 %22 to i32*
store volatile i32 %19, i32* %23
br label %31
24: ; preds = %3
%25 = load i32, i32* %6
%26 = sub nsw i32 %25, 1
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 16
%29 = sext i32 %28 to i64
%30 = inttoptr i64 %29 to i32*
store volatile i32 %26, i32* %30
br label %31
31: ; preds = %24, %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 i32*
%7 = load volatile i32, i32* %6
%8 = and i32 %7, 2
%9 = icmp eq i32 %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 = add nsw i32 %4, 16
%17 = sext i32 %16 to i64
%18 = inttoptr i64 %17 to i32*
store volatile i32 %15, i32* %18
ret void
}