void pwm_set(unsigned int duty) {
  (*((volatile unsigned long *)0x7F0080A0)) &= ~(0x3 << 28);
  (*((volatile unsigned long *)0x7F0080A0)) |= (0x2 << 28);
  (*((volatile unsigned long *)0x7F006000)) &= ~(0xff);
  (*((volatile unsigned long *)0x7F006000)) |= 1;
  (*((volatile unsigned long *)0x7F006004)) &= ~0xf;
  (*((volatile unsigned long *)0x7F00600C)) = 33250;
  if (duty == 1) {
    (*((volatile unsigned long *)0x7F006010)) = 33240;
  } else {
    (*((volatile unsigned long *)0x7F006010)) = 33250 / duty;
  }
  (*((volatile unsigned long *)0x7F006008)) &= ~(1 << 2);
  (*((volatile unsigned long *)0x7F006008)) |= (1 << 3);
}


x86 assembly (clang, -O0):
<pwm_set>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    $0x7f0080a0,%eax
mov    (%rax),%rcx
and    $0xffffffffcfffffff,%rcx
mov    $0x7f0080a0,%eax
mov    %rcx,(%rax)
mov    $0x7f0080a0,%eax
mov    (%rax),%rcx
or     $0x20000000,%rcx
mov    $0x7f0080a0,%eax
mov    %rcx,(%rax)
mov    $0x7f006000,%eax
mov    (%rax),%rcx
and    $0xffffffffffffff00,%rcx
mov    $0x7f006000,%eax
mov    %rcx,(%rax)
mov    $0x7f006000,%eax
mov    (%rax),%rcx
or     $0x1,%rcx
mov    $0x7f006000,%eax
mov    %rcx,(%rax)
mov    $0x7f006004,%eax
mov    (%rax),%rcx
and    $0xfffffffffffffff0,%rcx
mov    $0x7f006004,%eax
mov    %rcx,(%rax)
mov    $0x7f00600c,%eax
movq   $0x81e2,(%rax)
cmpl   $0x1,-0x4(%rbp)
jne    119b <pwm_set+0x9b>
mov    $0x7f006010,%eax
movq   $0x81d8,(%rax)
jmp    11b1 <pwm_set+0xb1>
mov    $0x81e2,%eax
xor    %edx,%edx
divl   -0x4(%rbp)
mov    %eax,%eax
mov    %eax,%ecx
mov    $0x7f006010,%eax
mov    %rcx,(%rax)
mov    $0x7f006008,%eax
mov    (%rax),%rcx
and    $0xfffffffffffffffb,%rcx
mov    $0x7f006008,%eax
mov    %rcx,(%rax)
mov    $0x7f006008,%eax
mov    (%rax),%rcx
or     $0x8,%rcx
mov    $0x7f006008,%eax
mov    %rcx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<pwm_set>:
andq   $0xffffffffcfffffff,0x7f0080a0
7f ff ff ff cf
orq    $0x20000000,0x7f0080a0
andq   $0xffffffffffffff00,0x7f006000
orq    $0x1,0x7f006000
7f 01
andq   $0xfffffffffffffff0,0x7f006004
7f f0
movq   $0x81e2,0x7f00600c
mov    $0x81d8,%eax
cmp    $0x1,%edi
je     1155 <pwm_set+0x55>
mov    $0x81e2,%eax
xor    %edx,%edx
div    %edi
mov    %rax,0x7f006010
7f
andq   $0xfffffffffffffffb,0x7f006008
7f fb
orq    $0x8,0x7f006008
7f 08
ret

LLVM IR (-O0):
define void @pwm_set(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load volatile i64, i64* inttoptr (i64 2130739360 to i64*)
%4 = and i64 %3, -805306369
store volatile i64 %4, i64* inttoptr (i64 2130739360 to i64*)
%5 = load volatile i64, i64* inttoptr (i64 2130739360 to i64*)
%6 = or i64 %5, 536870912
store volatile i64 %6, i64* inttoptr (i64 2130739360 to i64*)
%7 = load volatile i64, i64* inttoptr (i64 2130731008 to i64*)
%8 = and i64 %7, -256
store volatile i64 %8, i64* inttoptr (i64 2130731008 to i64*)
%9 = load volatile i64, i64* inttoptr (i64 2130731008 to i64*)
%10 = or i64 %9, 1
store volatile i64 %10, i64* inttoptr (i64 2130731008 to i64*)
%11 = load volatile i64, i64* inttoptr (i64 2130731012 to i64*)
%12 = and i64 %11, -16
store volatile i64 %12, i64* inttoptr (i64 2130731012 to i64*)
store volatile i64 33250, i64* inttoptr (i64 2130731020 to i64*)
%13 = load i32, i32* %2
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %16
15: ; preds = %1
store volatile i64 33240, i64* inttoptr (i64 2130731024 to i64*)
br label %20
16: ; preds = %1
%17 = load i32, i32* %2
%18 = udiv i32 33250, %17
%19 = zext i32 %18 to i64
store volatile i64 %19, i64* inttoptr (i64 2130731024 to i64*)
br label %20
20: ; preds = %16, %15
%21 = load volatile i64, i64* inttoptr (i64 2130731016 to i64*)
%22 = and i64 %21, -5
store volatile i64 %22, i64* inttoptr (i64 2130731016 to i64*)
%23 = load volatile i64, i64* inttoptr (i64 2130731016 to i64*)
%24 = or i64 %23, 8
store volatile i64 %24, i64* inttoptr (i64 2130731016 to i64*)
ret void
}

LLVM IR (-O2):
define void @pwm_set(i32 %0) {
%2 = load volatile i64, i64* inttoptr (i64 2130739360 to i64*)
%3 = and i64 %2, -805306369
store volatile i64 %3, i64* inttoptr (i64 2130739360 to i64*)
%4 = load volatile i64, i64* inttoptr (i64 2130739360 to i64*)
%5 = or i64 %4, 536870912
store volatile i64 %5, i64* inttoptr (i64 2130739360 to i64*)
%6 = load volatile i64, i64* inttoptr (i64 2130731008 to i64*)
%7 = and i64 %6, -256
store volatile i64 %7, i64* inttoptr (i64 2130731008 to i64*)
%8 = load volatile i64, i64* inttoptr (i64 2130731008 to i64*)
%9 = or i64 %8, 1
store volatile i64 %9, i64* inttoptr (i64 2130731008 to i64*)
%10 = load volatile i64, i64* inttoptr (i64 2130731012 to i64*)
%11 = and i64 %10, -16
store volatile i64 %11, i64* inttoptr (i64 2130731012 to i64*)
store volatile i64 33250, i64* inttoptr (i64 2130731020 to i64*)
%12 = icmp eq i32 %0, 1
br i1 %12, label %16, label %13
13: ; preds = %1
%14 = udiv i32 33250, %0
%15 = zext i32 %14 to i64
br label %16
16: ; preds = %1, %13
%17 = phi i64 [ %15, %13 ], [ 33240, %1 ]
store volatile i64 %17, i64* inttoptr (i64 2130731024 to i64*)
%18 = load volatile i64, i64* inttoptr (i64 2130731016 to i64*)
%19 = and i64 %18, -5
store volatile i64 %19, i64* inttoptr (i64 2130731016 to i64*)
%20 = load volatile i64, i64* inttoptr (i64 2130731016 to i64*)
%21 = or i64 %20, 8
store volatile i64 %21, i64* inttoptr (i64 2130731016 to i64*)
ret void
}