#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 */
void uart_set_pinmux(int port) {
  uint32_t mux_conf = 0;
  volatile uint32_t *mux_addr = (uint32_t *)(0x01c14000 + 0x120);
  if (port == 0) {
    mux_addr += (8);
    mux_conf = *mux_addr;
    mux_conf &= ~(0xf << ((3) * 4));
    mux_conf |= 0x1 << ((3) * 4);
    mux_conf &= ~(0xf << ((4) * 4));
    mux_conf |= 0x1 << ((4) * 4);
    *mux_addr = mux_conf;
  } else if (port == 1) {
    mux_addr = (uint32_t *)(0x01c14000 + 0x120);
    mux_addr += (11);
    mux_conf = *mux_addr;
    mux_conf &= ~(0xf << ((2) * 4));
    mux_conf |= 0x1 << ((2) * 4);
    mux_conf &= ~(0xf << ((3) * 4));
    mux_conf |= 0x1 << ((3) * 4);
    *mux_addr = mux_conf;
  }
}


x86 assembly (clang, -O0):
<uart_set_pinmux>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    $0x1c14120,%eax
mov    %rax,-0x10(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1170 <uart_set_pinmux+0x70>
mov    -0x10(%rbp),%rax
add    $0x20,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
and    $0xffff0fff,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
or     $0x1000,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
and    $0xfff0ffff,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
or     $0x10000,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    11d2 <uart_set_pinmux+0xd2>
cmpl   $0x1,-0x4(%rbp)
jne    11cd <uart_set_pinmux+0xcd>
mov    $0x1c14120,%eax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x2c,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
and    $0xfffff0ff,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
or     $0x100,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
and    $0xffff0fff,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
or     $0x1000,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    11d2 <uart_set_pinmux+0xd2>
pop    %rbp
ret

x86 assembly (clang, -O2):
<uart_set_pinmux>:
cmp    $0x1,%edi
je     1122 <uart_set_pinmux+0x22>
test   %edi,%edi
jne    113a <uart_set_pinmux+0x3a>
mov    $0xfff00fff,%eax
and    0x1c14140,%eax
or     $0x11000,%eax
mov    %eax,0x1c14140
ret
mov    $0xffff00ff,%eax
and    0x1c1414c,%eax
or     $0x1100,%eax
mov    %eax,0x1c1414c
ret

LLVM IR (-O0):
define void @uart_set_pinmux(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32*
store i32 %0, i32* %2
store i32 0, i32* %3
store i32* inttoptr (i64 29442336 to i32*), i32** %4
%5 = load i32, i32* %2
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %22
7: ; preds = %1
%8 = load i32*, i32** %4
%9 = getelementptr inbounds i32, i32* %8, i64 8
store i32* %9, i32** %4
%10 = load i32*, i32** %4
%11 = load volatile i32, i32* %10
store i32 %11, i32* %3
%12 = load i32, i32* %3
%13 = and i32 %12, -61441
store i32 %13, i32* %3
%14 = load i32, i32* %3
%15 = or i32 %14, 4096
store i32 %15, i32* %3
%16 = load i32, i32* %3
%17 = and i32 %16, -983041
store i32 %17, i32* %3
%18 = load i32, i32* %3
%19 = or i32 %18, 65536
store i32 %19, i32* %3
%20 = load i32, i32* %3
%21 = load i32*, i32** %4
store volatile i32 %20, i32* %21
br label %41
22: ; preds = %1
%23 = load i32, i32* %2
%24 = icmp eq i32 %23, 1
br i1 %24, label %25, label %40
25: ; preds = %22
store i32* inttoptr (i64 29442336 to i32*), i32** %4
%26 = load i32*, i32** %4
%27 = getelementptr inbounds i32, i32* %26, i64 11
store i32* %27, i32** %4
%28 = load i32*, i32** %4
%29 = load volatile i32, i32* %28
store i32 %29, i32* %3
%30 = load i32, i32* %3
%31 = and i32 %30, -3841
store i32 %31, i32* %3
%32 = load i32, i32* %3
%33 = or i32 %32, 256
store i32 %33, i32* %3
%34 = load i32, i32* %3
%35 = and i32 %34, -61441
store i32 %35, i32* %3
%36 = load i32, i32* %3
%37 = or i32 %36, 4096
store i32 %37, i32* %3
%38 = load i32, i32* %3
%39 = load i32*, i32** %4
store volatile i32 %38, i32* %39
br label %40
40: ; preds = %25, %22
br label %41
41: ; preds = %40, %7
ret void
}

LLVM IR (-O2):
define void @uart_set_pinmux(i32 %0) {
switch i32 %0, label %10 [
i32 0, label %2
i32 1, label %6
]
2: ; preds = %1
%3 = load volatile i32, i32* inttoptr (i64 29442368 to i32*)
%4 = and i32 %3, -1044481
%5 = or i32 %4, 69632
store volatile i32 %5, i32* inttoptr (i64 29442368 to i32*)
br label %10
6: ; preds = %1
%7 = load volatile i32, i32* inttoptr (i64 29442380 to i32*)
%8 = and i32 %7, -65281
%9 = or i32 %8, 4352
store volatile i32 %9, i32* inttoptr (i64 29442380 to i32*)
br label %10
10: ; preds = %1, %6, %2
ret void
}