#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 */

/* Variables and functions */
unsigned int LCDVersionGet();
void RasterHparamConfig(unsigned int baseAddr, unsigned int numOfppl,
                        unsigned int hsw, unsigned int hfp, unsigned hbp) {
  unsigned int ppl;
  unsigned int version;
  version = LCDVersionGet();
  if (2u == version) {
    ppl = numOfppl - 1;
    ppl = (ppl & 0x000003f0) | ((ppl & 0x00000400) >> 8);
    (*((volatile unsigned int *)(baseAddr + (0x2C)))) = ppl;
  } else if (1u == version) {
    ppl = (numOfppl / 16) - 1;
    (*((volatile unsigned int *)(baseAddr + (0x2C)))) = (ppl << (0x00000004u));
  } else {
    ;
  }
  (*((volatile unsigned int *)(baseAddr + (0x2C)))) |=
      ((hsw - 1) << (0x0000000Au));
  (*((volatile unsigned int *)(baseAddr + (0x2C)))) |=
      ((hfp - 1) << (0x00000010u));
  (*((volatile unsigned int *)(baseAddr + (0x2C)))) |=
      ((hbp - 1) << (0x00000018u));
}


x86 assembly (clang, -O0):
<RasterHparamConfig>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
mov    $0x0,%al
call   1030 <LCDVersionGet@plt>
mov    %eax,-0x1c(%rbp)
mov    $0x2,%eax
cmp    -0x1c(%rbp),%eax
jne    1174 <RasterHparamConfig+0x64>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
and    $0x3f0,%eax
mov    -0x18(%rbp),%ecx
and    $0x400,%ecx
shr    $0x8,%ecx
or     %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%ecx
mov    -0x4(%rbp),%eax
add    $0x2c,%eax
mov    %eax,%eax
mov    %ecx,(%rax)
jmp    11ad <RasterHparamConfig+0x9d>
mov    $0x1,%eax
cmp    -0x1c(%rbp),%eax
jne    11a3 <RasterHparamConfig+0x93>
mov    -0x8(%rbp),%eax
shr    $0x4,%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%ecx
shl    $0x4,%ecx
mov    -0x4(%rbp),%eax
add    $0x2c,%eax
mov    %eax,%eax
mov    %ecx,(%rax)
jmp    11a8 <RasterHparamConfig+0x98>
jmp    11a8 <RasterHparamConfig+0x98>
jmp    11ad <RasterHparamConfig+0x9d>
mov    -0xc(%rbp),%edx
sub    $0x1,%edx
shl    $0xa,%edx
mov    -0x4(%rbp),%eax
add    $0x2c,%eax
mov    %eax,%eax
mov    (%rax),%ecx
or     %edx,%ecx
mov    %ecx,(%rax)
mov    -0x10(%rbp),%edx
sub    $0x1,%edx
shl    $0x10,%edx
mov    -0x4(%rbp),%eax
add    $0x2c,%eax
mov    %eax,%eax
mov    (%rax),%ecx
or     %edx,%ecx
mov    %ecx,(%rax)
mov    -0x14(%rbp),%edx
sub    $0x1,%edx
shl    $0x18,%edx
mov    -0x4(%rbp),%eax
add    $0x2c,%eax
mov    %eax,%eax
mov    (%rax),%ecx
or     %edx,%ecx
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RasterHparamConfig>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8d,%r14d
mov    %ecx,%r15d
mov    %edx,%r12d
mov    %esi,%ebp
mov    %edi,%ebx
xor    %eax,%eax
call   1030 <LCDVersionGet@plt>
cmp    $0x1,%eax
je     114a <RasterHparamConfig+0x3a>
cmp    $0x2,%eax
jne    1157 <RasterHparamConfig+0x47>
add    $0xffffffff,%ebp
mov    %ebp,%eax
and    $0x3f0,%eax
shr    $0x8,%ebp
and    $0x4,%ebp
or     %eax,%ebp
jmp    1150 <RasterHparamConfig+0x40>
add    $0xfffffff0,%ebp
and    $0xfffffff0,%ebp
add    $0x2c,%ebx
mov    %ebp,(%rbx)
jmp    115a <RasterHparamConfig+0x4a>
add    $0x2c,%ebx
shl    $0xa,%r12d
add    $0xfffffc00,%r12d
or     %r12d,(%rbx)
shl    $0x10,%r15d
add    $0xffff0000,%r15d
or     %r15d,(%rbx)
shl    $0x18,%r14d
add    $0xff000000,%r14d
or     %r14d,(%rbx)
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @RasterHparamConfig(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%13 = call i32 (...) @LCDVersionGet()
store i32 %13, i32* %12
%14 = load i32, i32* %12
%15 = icmp eq i32 2, %14
br i1 %15, label %16, label %30
16: ; preds = %5
%17 = load i32, i32* %7
%18 = sub i32 %17, 1
store i32 %18, i32* %11
%19 = load i32, i32* %11
%20 = and i32 %19, 1008
%21 = load i32, i32* %11
%22 = and i32 %21, 1024
%23 = lshr i32 %22, 8
%24 = or i32 %20, %23
store i32 %24, i32* %11
%25 = load i32, i32* %11
%26 = load i32, i32* %6
%27 = add i32 %26, 44
%28 = zext i32 %27 to i64
%29 = inttoptr i64 %28 to i32*
store volatile i32 %25, i32* %29
br label %45
30: ; preds = %5
%31 = load i32, i32* %12
%32 = icmp eq i32 1, %31
br i1 %32, label %33, label %43
33: ; preds = %30
%34 = load i32, i32* %7
%35 = udiv i32 %34, 16
%36 = sub i32 %35, 1
store i32 %36, i32* %11
%37 = load i32, i32* %11
%38 = shl i32 %37, 4
%39 = load i32, i32* %6
%40 = add i32 %39, 44
%41 = zext i32 %40 to i64
%42 = inttoptr i64 %41 to i32*
store volatile i32 %38, i32* %42
br label %44
43: ; preds = %30
br label %44
44: ; preds = %43, %33
br label %45
45: ; preds = %44, %16
%46 = load i32, i32* %8
%47 = sub i32 %46, 1
%48 = shl i32 %47, 10
%49 = load i32, i32* %6
%50 = add i32 %49, 44
%51 = zext i32 %50 to i64
%52 = inttoptr i64 %51 to i32*
%53 = load volatile i32, i32* %52
%54 = or i32 %53, %48
store volatile i32 %54, i32* %52
%55 = load i32, i32* %9
%56 = sub i32 %55, 1
%57 = shl i32 %56, 16
%58 = load i32, i32* %6
%59 = add i32 %58, 44
%60 = zext i32 %59 to i64
%61 = inttoptr i64 %60 to i32*
%62 = load volatile i32, i32* %61
%63 = or i32 %62, %57
store volatile i32 %63, i32* %61
%64 = load i32, i32* %10
%65 = sub i32 %64, 1
%66 = shl i32 %65, 24
%67 = load i32, i32* %6
%68 = add i32 %67, 44
%69 = zext i32 %68 to i64
%70 = inttoptr i64 %69 to i32*
%71 = load volatile i32, i32* %70
%72 = or i32 %71, %66
store volatile i32 %72, i32* %70
ret void
}

LLVM IR (-O2):
define void @RasterHparamConfig(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = tail call i32 (...) @LCDVersionGet()
switch i32 %6, label %7 [
i32 2, label %11
i32 1, label %20
]
7: ; preds = %5
%8 = add i32 %0, 44
%9 = zext i32 %8 to i64
%10 = inttoptr i64 %9 to i32*
br label %26
11: ; preds = %5
%12 = add i32 %1, -1
%13 = and i32 %12, 1008
%14 = lshr i32 %12, 8
%15 = and i32 %14, 4
%16 = or i32 %15, %13
%17 = add i32 %0, 44
%18 = zext i32 %17 to i64
%19 = inttoptr i64 %18 to i32*
store volatile i32 %16, i32* %19
br label %26
20: ; preds = %5
%21 = add i32 %1, -16
%22 = and i32 %21, -16
%23 = add i32 %0, 44
%24 = zext i32 %23 to i64
%25 = inttoptr i64 %24 to i32*
store volatile i32 %22, i32* %25
br label %26
26: ; preds = %7, %20, %11
%27 = phi i32* [ %10, %7 ], [ %25, %20 ], [ %19, %11 ]
%28 = shl i32 %2, 10
%29 = add i32 %28, -1024
%30 = load volatile i32, i32* %27
%31 = or i32 %30, %29
store volatile i32 %31, i32* %27
%32 = shl i32 %3, 16
%33 = add i32 %32, -65536
%34 = load volatile i32, i32* %27
%35 = or i32 %34, %33
store volatile i32 %35, i32* %27
%36 = shl i32 %4, 24
%37 = add i32 %36, -16777216
%38 = load volatile i32, i32* %27
%39 = or i32 %38, %37
store volatile i32 %39, i32* %27
ret void
}