#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;

/* Variables and functions */
int /*<<< orphan*/ MAP_SHARED;
int O_RDWR;
int O_SYNC;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ mmap(int /*<<< orphan*/ *, int, int, int /*<<< orphan*/, int, int);
int munmap(int *, int);
int open(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
float strtod(char *, int /*<<< orphan*/ *);
int strtol(char *, int /*<<< orphan*/ *, int);
int main(int argc, char *argv[]) {
  volatile uint32_t *map = NULL;
  int memfd = 0;
  int err = 0;
  float sum = 0;
  float clock = 0;
  struct cm_gpctl {
    uint32_t src : 4;
    uint32_t enab : 1;
    uint32_t kill : 1;
    uint32_t unused : 1;
    uint32_t busy : 1;
    uint32_t flip : 1;
    uint32_t mash : 2;
    uint32_t unused2 : 13;
    uint32_t passwd : 8;
  } gpctl = {6, 1, 0, 0, 0, 0, 0, 0, 0x5a};
  if (argc < 2) {
    printf("%s", "\n  \033[1mGPCLK0 Frequency Controller by blog.everpi.net\n\n"
                 "\tUsage: freq_g [frequency] [source]\n\n"
                 "\t\t [frequency] in Mhz with or without float pointing\n"
                 "\t\t [source]    number is the frequency source argument\n\n"
                 "\tSupported sources: 1 - XTAL 19.2Mhz\n"
                 "\t\t\t   5 - PLLC 1000Mhz\n"
                 "\t\t\t   6 - PLLD 500Mhz default\n"
                 "\t\t\t   7 - HDMI aux 216Mhz\033[0m\n\n");
    return 0;
  }
  memfd = open("/dev/mem", O_RDWR | O_SYNC);
  if (memfd == -1) {
    fprintf(stderr, "%s\n", strerror(errno));
    return 1;
  };
  map = (unsigned int *)mmap(NULL, 0x01000000, PROT_READ | PROT_WRITE,
                             MAP_SHARED, memfd, 0x20000000);
  if ((int)map == -1) {
    fprintf(stderr, "%s\n", strerror(errno));
    return 1;
  };
  *(volatile uint32_t *)((uint32_t)map + 0x200000) &= ~(7 << 12);
  *(volatile uint32_t *)((uint32_t)map + 0x200000) |= (4 << 12);
  if (argc > 2) {
    gpctl.src = strtol(argv[2], NULL, 10);
    switch (gpctl.src) {
    case 1:
      clock = 19.2;
      break;
    case 5:
      clock = 1000.0;
      break;
    case 6:
      clock = 500.0;
      break;
    case 7:
      clock = 216.0;
      break;
    }
  } else {
    clock = 500.0;
    gpctl.src = 6;
  }
  *(volatile uint32_t *)((uint32_t)map + 0x101070) = *((int *)&gpctl);
  printf("%p - %p\n", map, ((uint32_t)map + 0x101070));
  sum = strtod(argv[1], NULL);
  printf("Frequency:%f\n", sum);
  printf("Normal divisor:%f\n", clock / sum);
  printf("Divisor:%d\n", (int)((clock / sum) * (float)(1 << 12) + 0.5));
  *(volatile uint32_t *)((uint32_t)map + 0x101074) =
      (0x5a << 24) + (int)((clock / sum) * (float)(1 << 12) + 0.5);
  err = munmap((uint32_t *)map, 0x01000000);
  if (err == -1) {
    fprintf(stderr, "%s\n", strerror(errno));
    return 1;
  };
  close(memfd);
  if (err == -1) {
    fprintf(stderr, "%s\n", strerror(errno));
    return 1;
  };
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x24(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x28(%rbp)
mov    0xe42(%rip),%eax
mov    %eax,-0x30(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1200 <main+0x70>
lea    0xe56(%rip),%rdi
lea    0xe52(%rip),%rsi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1559 <main+0x3c9>
mov    0x2dd1(%rip),%rax
mov    (%rax),%esi
mov    0x2dc0(%rip),%rax
or     (%rax),%esi
lea    0xf69(%rip),%rdi
call   10a0 <open@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    1263 <main+0xd3>
mov    0x2d8e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    0x2d7a(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0x34(%rbp),%edi
mov    %rax,%rdx
lea    0xf39(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1559 <main+0x3c9>
mov    0x2d8e(%rip),%rax
mov    (%rax),%edx
mov    0x2d3d(%rip),%rax
or     (%rax),%edx
mov    0x2d6c(%rip),%rax
mov    (%rax),%ecx
mov    -0x1c(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
mov    $0x1000000,%esi
mov    $0x20000000,%r9d
call   1040 <mmap@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    $0xffffffff,%eax
jne    12df <main+0x14f>
mov    0x2d12(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    0x2cfe(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0x38(%rbp),%edi
mov    %rax,%rdx
lea    0xebd(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1559 <main+0x3c9>
mov    -0x18(%rbp),%rax
add    $0x200000,%eax
cltq
mov    (%rax),%ecx
and    $0xffff8fff,%ecx
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
add    $0x200000,%eax
cltq
mov    (%rax),%ecx
or     $0x4000,%ecx
mov    %ecx,(%rax)
cmpl   $0x2,-0x8(%rbp)
jle    13b0 <main+0x220>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1080 <strtol@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
and    $0xf,%ecx
and    $0xfffffff0,%eax
or     %ecx,%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
shl    $0x1c,%eax
sar    $0x1c,%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x40(%rbp)
sub    $0x6,%eax
ja     13ab <main+0x21b>
mov    -0x40(%rbp),%rax
lea    0xcc1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  0xc9c(%rip),%xmm0
movss  %xmm0,-0x28(%rbp)
jmp    13ab <main+0x21b>
movss  0xc86(%rip),%xmm0
movss  %xmm0,-0x28(%rbp)
jmp    13ab <main+0x21b>
movss  0xc6c(%rip),%xmm0
movss  %xmm0,-0x28(%rbp)
jmp    13ab <main+0x21b>
movss  0xc5e(%rip),%xmm0
movss  %xmm0,-0x28(%rbp)
jmp    13c9 <main+0x239>
movss  0xc48(%rip),%xmm0
movss  %xmm0,-0x28(%rbp)
mov    -0x30(%rbp),%eax
and    $0xfffffff0,%eax
or     $0x6,%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%ecx
mov    -0x18(%rbp),%rax
add    $0x101070,%eax
cltq
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rsi
mov    -0x18(%rbp),%rax
mov    %eax,%edx
add    $0x101070,%edx
lea    0xd9f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <strtod@plt>
movss  %xmm0,-0x24(%rbp)
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd7b(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movss  -0x28(%rbp),%xmm0
divss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd6d(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movss  -0x28(%rbp),%xmm0
divss  -0x24(%rbp),%xmm0
movss  0xbbe(%rip),%xmm1
mulss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xbb6(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
lea    0xd48(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movss  -0x28(%rbp),%xmm0
divss  -0x24(%rbp),%xmm0
movss  0xb86(%rip),%xmm1
mulss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xb7e(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ecx
add    $0x5a000000,%ecx
mov    -0x18(%rbp),%rax
add    $0x101074,%eax
cltq
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rdi
mov    $0x1000000,%esi
call   1090 <munmap@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0xffffffff,-0x20(%rbp)
jne    1508 <main+0x378>
mov    0x2ae9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    0x2ad5(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0x44(%rbp),%edi
mov    %rax,%rdx
lea    0xc94(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1559 <main+0x3c9>
mov    -0x1c(%rbp),%edi
call   1060 <close@plt>
cmpl   $0xffffffff,-0x20(%rbp)
jne    1552 <main+0x3c2>
mov    0x2a9f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
mov    0x2a8b(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0x48(%rbp),%edi
mov    %rax,%rdx
lea    0xc4a(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1559 <main+0x3c9>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x1,%edi
jg     11c3 <main+0x23>
lea    0xec8(%rip),%rdi
call   1030 <puts@plt>
xor    %ebp,%ebp
jmp    13c5 <main+0x225>
mov    %rsi,%r15
mov    %edi,%ebp
mov    0x2e09(%rip),%rax
mov    0x2dfa(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
lea    0xe5b(%rip),%rdi
call   10b0 <open@plt>
cmp    $0xffffffff,%eax
je     1398 <main+0x1f8>
mov    %eax,%r14d
mov    0x2dff(%rip),%rax
mov    0x2db0(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2ddd(%rip),%rax
mov    (%rax),%ecx
xor    %edi,%edi
mov    $0x1000000,%esi
mov    %r14d,%r8d
mov    $0x20000000,%r9d
call   1050 <mmap@plt>
mov    %rax,%r12
cmp    $0xffffffff,%r12d
je     1398 <main+0x1f8>
mov    %r12,%r13
shl    $0x20,%r13
movabs $0x20000000000000,%rax
add    %r13,%rax
sar    $0x20,%rax
andl   $0xffff8fff,(%rax)
orl    $0x4000,(%rax)
mov    $0x5a000016,%ecx
movss  0xda0(%rip),%xmm0
cmp    $0x3,%ebp
jb     12c7 <main+0x127>
mov    0x10(%r15),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1090 <strtol@plt>
mov    %eax,%ecx
and    $0xf,%ecx
or     $0x5a000010,%ecx
shl    $0x1c,%eax
sar    $0x1c,%eax
xorps  %xmm0,%xmm0
add    $0xffffffff,%eax
cmp    $0x6,%eax
ja     12c7 <main+0x127>
lea    0xd88(%rip),%rdx
movslq (%rdx,%rax,4),%rax
add    %rdx,%rax
jmp    *%rax
movss  0xd63(%rip),%xmm0
jmp    12c7 <main+0x127>
movss  0xd55(%rip),%xmm0
jmp    12c7 <main+0x127>
movss  0xd43(%rip),%xmm0
jmp    12c7 <main+0x127>
movss  0xd3d(%rip),%xmm0
movss  %xmm0,(%rsp)
movslq %r12d,%rdx
mov    %ecx,0x101070(%rdx)
add    $0x101070,%rdx
lea    0xd66(%rip),%rdi
xor    %ebp,%ebp
mov    %r12,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x8(%r15),%rdi
xor    %esi,%esi
call   1040 <strtod@plt>
movss  %xmm0,0x4(%rsp)
cvtss2sd %xmm0,%xmm0
lea    0xd47(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movss  (%rsp),%xmm0
divss  0x4(%rsp),%xmm0
movss  %xmm0,(%rsp)
cvtss2sd %xmm0,%xmm0
lea    0xd33(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movss  (%rsp),%xmm0
mulss  0xccf(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  0xccb(%rip),%xmm0
cvttsd2si %xmm0,%ebx
lea    0xd1b(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x5a000000,%ebx
movabs $0x10107400000000,%rax
add    %rax,%r13
sar    $0x20,%r13
mov    %ebx,0x0(%r13)
mov    %r12,%rdi
mov    $0x1000000,%esi
call   10a0 <munmap@plt>
cmp    $0xffffffff,%eax
je     1398 <main+0x1f8>
mov    %r14d,%edi
call   1070 <close@plt>
jmp    13c5 <main+0x225>
mov    0x2c21(%rip),%rax
mov    (%rax),%ebx
mov    0x2c10(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
lea    0xc8f(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1080 <fprintf@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.cm_gpctl = type { i32 }
@__const.main.gpctl = { i8, i8, i8, i8 } { i8 22, i8 0, i8 0, i8 90 }
@.str = [3 x i8] c"%s\00"
@.str.1 = [323 x i8] c"\0A \1B[1mGPCLK0 Frequency Controller by blog.everpi.net\0A\0A\09Usage: freq_g [frequency] [source]\0A\0A\09\09 [frequency] in Mhz with or without float pointing\0A\09\09 [source] number is the frequency source argument\0A\0A\09Supported sources: 1 - XTAL 19.2Mhz\0A\09\09\09 5 - PLLC 1000Mhz\0A\09\09\09 6 - PLLD 500Mhz default\0A\09\09\09 7 - HDMI aux 216Mhz\1B[0m\0A\0A\00"
@.str.2 = [9 x i8] c"/dev/mem\00"
@O_RDWR = global i32 0
@O_SYNC = global i32 0
@stderr = global i32 0
@.str.3 = [4 x i8] c"%s\0A\00"
@errno = global i32 0
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@.str.4 = [9 x i8] c"%p - %p\0A\00"
@.str.5 = [14 x i8] c"Frequency:%f\0A\00"
@.str.6 = [19 x i8] c"Normal divisor:%f\0A\00"
@.str.7 = [12 x i8] c"Divisor:%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca float
%10 = alloca float
%11 = alloca %struct.cm_gpctl
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32* null, i32** %6
store i32 0, i32* %7
store i32 0, i32* %8
store float 0.000000e+00, float* %9
store float 0.000000e+00, float* %10
%12 = bitcast %struct.cm_gpctl* %11 to i8*
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 2
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([323 x i8], [323 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %154
17: ; preds = %2
%18 = load i32, i32* @O_RDWR
%19 = load i32, i32* @O_SYNC
%20 = or i32 %18, %19
%21 = call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %20)
store i32 %21, i32* %7
%22 = load i32, i32* %7
%23 = icmp eq i32 %22, -1
br i1 %23, label %24, label %29
24: ; preds = %17
%25 = load i32, i32* @stderr
%26 = load i32, i32* @errno
%27 = call i8* @strerror(i32 %26)
%28 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %27)
store i32 1, i32* %3
br label %154
29: ; preds = %17
%30 = load i32, i32* @PROT_READ
%31 = load i32, i32* @PROT_WRITE
%32 = or i32 %30, %31
%33 = load i32, i32* @MAP_SHARED
%34 = load i32, i32* %7
%35 = call i64 @mmap(i32* null, i32 16777216, i32 %32, i32 %33, i32 %34, i32 536870912)
%36 = inttoptr i64 %35 to i32*
store i32* %36, i32** %6
%37 = load i32*, i32** %6
%38 = ptrtoint i32* %37 to i32
%39 = icmp eq i32 %38, -1
br i1 %39, label %40, label %45
40: ; preds = %29
%41 = load i32, i32* @stderr
%42 = load i32, i32* @errno
%43 = call i8* @strerror(i32 %42)
%44 = call i32 @fprintf(i32 %41, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %43)
store i32 1, i32* %3
br label %154
45: ; preds = %29
%46 = load i32*, i32** %6
%47 = ptrtoint i32* %46 to i32
%48 = add nsw i32 %47, 2097152
%49 = sext i32 %48 to i64
%50 = inttoptr i64 %49 to i32*
%51 = load volatile i32, i32* %50
%52 = and i32 %51, -28673
store volatile i32 %52, i32* %50
%53 = load i32*, i32** %6
%54 = ptrtoint i32* %53 to i32
%55 = add nsw i32 %54, 2097152
%56 = sext i32 %55 to i64
%57 = inttoptr i64 %56 to i32*
%58 = load volatile i32, i32* %57
%59 = or i32 %58, 16384
store volatile i32 %59, i32* %57
%60 = load i32, i32* %4
%61 = icmp sgt i32 %60, 2
br i1 %61, label %62, label %83
62: ; preds = %45
%63 = load i8**, i8*** %5
%64 = getelementptr inbounds i8*, i8** %63, i64 2
%65 = load i8*, i8** %64
%66 = call i32 @strtol(i8* %65, i32* null, i32 10)
%67 = bitcast %struct.cm_gpctl* %11 to i32*
%68 = load i32, i32* %67
%69 = and i32 %66, 15
%70 = and i32 %68, -16
%71 = or i32 %70, %69
store i32 %71, i32* %67
%72 = shl i32 %69, 28
%73 = ashr i32 %72, 28
%74 = bitcast %struct.cm_gpctl* %11 to i32*
%75 = load i32, i32* %74
%76 = shl i32 %75, 28
%77 = ashr i32 %76, 28
switch i32 %77, label %82 [
i32 1, label %78
i32 5, label %79
i32 6, label %80
i32 7, label %81
]
78: ; preds = %62
store float 0x4033333340000000, float* %10
br label %82
79: ; preds = %62
store float 1.000000e+03, float* %10
br label %82
80: ; preds = %62
store float 5.000000e+02, float* %10
br label %82
81: ; preds = %62
store float 2.160000e+02, float* %10
br label %82
82: ; preds = %62, %81, %80, %79, %78
br label %88
83: ; preds = %45
store float 5.000000e+02, float* %10
%84 = bitcast %struct.cm_gpctl* %11 to i32*
%85 = load i32, i32* %84
%86 = and i32 %85, -16
%87 = or i32 %86, 6
store i32 %87, i32* %84
br label %88
88: ; preds = %83, %82
%89 = bitcast %struct.cm_gpctl* %11 to i32*
%90 = load i32, i32* %89
%91 = load i32*, i32** %6
%92 = ptrtoint i32* %91 to i32
%93 = add nsw i32 %92, 1052784
%94 = sext i32 %93 to i64
%95 = inttoptr i64 %94 to i32*
store volatile i32 %90, i32* %95
%96 = load i32*, i32** %6
%97 = load i32*, i32** %6
%98 = ptrtoint i32* %97 to i32
%99 = add nsw i32 %98, 1052784
%100 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32* %96, i32 %99)
%101 = load i8**, i8*** %5
%102 = getelementptr inbounds i8*, i8** %101, i64 1
%103 = load i8*, i8** %102
%104 = call float @strtod(i8* %103, i32* null)
store float %104, float* %9
%105 = load float, float* %9
%106 = fpext float %105 to double
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), double %106)
%108 = load float, float* %10
%109 = load float, float* %9
%110 = fdiv float %108, %109
%111 = fpext float %110 to double
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), double %111)
%113 = load float, float* %10
%114 = load float, float* %9
%115 = fdiv float %113, %114
%116 = fmul float %115, 4.096000e+03
%117 = fpext float %116 to double
%118 = fadd double %117, 5.000000e-01
%119 = fptosi double %118 to i32
%120 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i32 %119)
%121 = load float, float* %10
%122 = load float, float* %9
%123 = fdiv float %121, %122
%124 = fmul float %123, 4.096000e+03
%125 = fpext float %124 to double
%126 = fadd double %125, 5.000000e-01
%127 = fptosi double %126 to i32
%128 = add nsw i32 1509949440, %127
%129 = load i32*, i32** %6
%130 = ptrtoint i32* %129 to i32
%131 = add nsw i32 %130, 1052788
%132 = sext i32 %131 to i64
%133 = inttoptr i64 %132 to i32*
store volatile i32 %128, i32* %133
%134 = load i32*, i32** %6
%135 = call i32 @munmap(i32* %134, i32 16777216)
store i32 %135, i32* %8
%136 = load i32, i32* %8
%137 = icmp eq i32 %136, -1
br i1 %137, label %138, label %143
138: ; preds = %88
%139 = load i32, i32* @stderr
%140 = load i32, i32* @errno
%141 = call i8* @strerror(i32 %140)
%142 = call i32 @fprintf(i32 %139, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %141)
store i32 1, i32* %3
br label %154
143: ; preds = %88
%144 = load i32, i32* %7
%145 = call i32 @close(i32 %144)
%146 = load i32, i32* %8
%147 = icmp eq i32 %146, -1
br i1 %147, label %148, label %153
148: ; preds = %143
%149 = load i32, i32* @stderr
%150 = load i32, i32* @errno
%151 = call i8* @strerror(i32 %150)
%152 = call i32 @fprintf(i32 %149, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %151)
store i32 1, i32* %3
br label %154
153: ; preds = %143
store i32 0, i32* %3
br label %154
154: ; preds = %153, %148, %138, %40, %24, %15
%155 = load i32, i32* %3
ret i32 %155
}

LLVM IR (-O2):
@.str.2 = [9 x i8] c"/dev/mem\00"
@O_RDWR = global i32 0
@O_SYNC = global i32 0
@stderr = global i32 0
@.str.3 = [4 x i8] c"%s\0A\00"
@errno = global i32 0
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@.str.4 = [9 x i8] c"%p - %p\0A\00"
@.str.5 = [14 x i8] c"Frequency:%f\0A\00"
@.str.6 = [19 x i8] c"Normal divisor:%f\0A\00"
@.str.7 = [12 x i8] c"Divisor:%d\0A\00"
@str = [322 x i8] c"\0A \1B[1mGPCLK0 Frequency Controller by blog.everpi.net\0A\0A\09Usage: freq_g [frequency] [source]\0A\0A\09\09 [frequency] in Mhz with or without float pointing\0A\09\09 [source] number is the frequency source argument\0A\0A\09Supported sources: 1 - XTAL 19.2Mhz\0A\09\09\09 5 - PLLC 1000Mhz\0A\09\09\09 6 - PLLD 500Mhz default\0A\09\09\09 7 - HDMI aux 216Mhz\1B[0m\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([322 x i8], [322 x i8]* @str, i64 0, i64 0))
br label %86
6: ; preds = %2
%7 = load i32, i32* @O_RDWR
%8 = load i32, i32* @O_SYNC
%9 = or i32 %8, %7
%10 = tail call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %17
12: ; preds = %6
%13 = load i32, i32* @stderr
%14 = load i32, i32* @errno
%15 = tail call i8* @strerror(i32 %14)
%16 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %15)
br label %86
17: ; preds = %6
%18 = load i32, i32* @PROT_READ
%19 = load i32, i32* @PROT_WRITE
%20 = or i32 %19, %18
%21 = load i32, i32* @MAP_SHARED
%22 = tail call i64 @mmap(i32* null, i32 16777216, i32 %20, i32 %21, i32 %10, i32 536870912)
%23 = inttoptr i64 %22 to i32*
%24 = trunc i64 %22 to i32
%25 = icmp eq i32 %24, -1
br i1 %25, label %26, label %31
26: ; preds = %17
%27 = load i32, i32* @stderr
%28 = load i32, i32* @errno
%29 = tail call i8* @strerror(i32 %28)
%30 = tail call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %29)
br label %86
31: ; preds = %17
%32 = shl i64 %22, 32
%33 = add i64 %32, 9007199254740992
%34 = ashr exact i64 %33, 32
%35 = inttoptr i64 %34 to i32*
%36 = load volatile i32, i32* %35
%37 = and i32 %36, -28673
store volatile i32 %37, i32* %35
%38 = load volatile i32, i32* %35
%39 = or i32 %38, 16384
store volatile i32 %39, i32* %35
%40 = icmp ugt i32 %0, 2
br i1 %40, label %41, label %53
41: ; preds = %31
%42 = getelementptr inbounds i8*, i8** %1, i64 2
%43 = load i8*, i8** %42
%44 = tail call i32 @strtol(i8* nocapture %43, i32* null, i32 10)
%45 = and i32 %44, 15
%46 = or i32 %45, 1509949456
%47 = shl i32 %44, 28
%48 = ashr exact i32 %47, 28
switch i32 %48, label %53 [
i32 1, label %49
i32 5, label %50
i32 6, label %51
i32 7, label %52
]
49: ; preds = %41
br label %53
50: ; preds = %41
br label %53
51: ; preds = %41
br label %53
52: ; preds = %41
br label %53
53: ; preds = %31, %49, %50, %51, %52, %41
%54 = phi float [ 0.000000e+00, %41 ], [ 2.160000e+02, %52 ], [ 5.000000e+02, %51 ], [ 1.000000e+03, %50 ], [ 0x4033333340000000, %49 ], [ 5.000000e+02, %31 ]
%55 = phi i32 [ %46, %41 ], [ %46, %52 ], [ %46, %51 ], [ %46, %50 ], [ %46, %49 ], [ 1509949462, %31 ]
%56 = add nsw i32 %24, 1052784
%57 = sext i32 %56 to i64
%58 = inttoptr i64 %57 to i32*
store volatile i32 %55, i32* %58
%59 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32* %23, i32 %56)
%60 = getelementptr inbounds i8*, i8** %1, i64 1
%61 = load i8*, i8** %60
%62 = tail call float @strtod(i8* nocapture %61, i32* null)
%63 = fpext float %62 to double
%64 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), double %63)
%65 = fdiv float %54, %62
%66 = fpext float %65 to double
%67 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), double %66)
%68 = fmul float %65, 4.096000e+03
%69 = fpext float %68 to double
%70 = fadd double %69, 5.000000e-01
%71 = fptosi double %70 to i32
%72 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i32 %71)
%73 = add nsw i32 %71, 1509949440
%74 = add i64 %32, 4521690029621248
%75 = ashr exact i64 %74, 32
%76 = inttoptr i64 %75 to i32*
store volatile i32 %73, i32* %76
%77 = tail call i32 @munmap(i32* %23, i32 16777216)
%78 = icmp eq i32 %77, -1
br i1 %78, label %79, label %84
79: ; preds = %53
%80 = load i32, i32* @stderr
%81 = load i32, i32* @errno
%82 = tail call i8* @strerror(i32 %81)
%83 = tail call i32 @fprintf(i32 %80, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %82)
br label %86
84: ; preds = %53
%85 = tail call i32 @close(i32 %10)
br label %86
86: ; preds = %84, %79, %26, %12, %4
%87 = phi i32 [ 0, %4 ], [ 1, %12 ], [ 1, %26 ], [ 1, %79 ], [ 0, %84 ]
ret i32 %87
}