#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 read_from_address(int);
int /*<<< orphan*/ write_to_address(int, unsigned int);
void jtag_init() {
  unsigned int register_a;
  register_a = read_from_address(0x3F200000);
  register_a &= ~(7 << 12);
  register_a |= 2 << 12;
  write_to_address(0x3F200000, register_a);
  register_a = read_from_address(0x3F200008);
  register_a &= ~(7 << 6);
  register_a |= 3 << 6;
  register_a &= ~(7 << 12);
  register_a |= 3 << 12;
  register_a &= ~(7 << 15);
  register_a |= 3 << 15;
  register_a &= ~(7 << 21);
  register_a |= 3 << 21;
  write_to_address(0x3F200008, register_a);
}


x86 assembly (clang, -O0):
<jtag_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x3f200000,%edi
call   1030 <read_from_address@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0xffff8fff,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
or     $0x2000,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
mov    $0x3f200000,%edi
call   1040 <write_to_address@plt>
mov    $0x3f200008,%edi
call   1030 <read_from_address@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0xfffffe3f,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
or     $0xc0,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0xffff8fff,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
or     $0x3000,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0xfffc7fff,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
or     $0x18000,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0xff1fffff,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
or     $0x600000,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
mov    $0x3f200008,%edi
call   1040 <write_to_address@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<jtag_init>:
push   %rax
mov    $0x3f200000,%edi
call   1030 <read_from_address@plt>
and    $0xffff8fff,%eax
lea    0x2000(%rax),%esi
mov    $0x3f200000,%edi
call   1040 <write_to_address@plt>
mov    $0x3f200008,%edi
call   1030 <read_from_address@plt>
and    $0xff1c0e3f,%eax
lea    0x61b0c0(%rax),%esi
mov    $0x3f200008,%edi
pop    %rax
jmp    1040 <write_to_address@plt>

LLVM IR (-O0):
define void @jtag_init() {
%1 = alloca i32
%2 = call i32 @read_from_address(i32 1059061760)
store i32 %2, i32* %1
%3 = load i32, i32* %1
%4 = and i32 %3, -28673
store i32 %4, i32* %1
%5 = load i32, i32* %1
%6 = or i32 %5, 8192
store i32 %6, i32* %1
%7 = load i32, i32* %1
%8 = call i32 @write_to_address(i32 1059061760, i32 %7)
%9 = call i32 @read_from_address(i32 1059061768)
store i32 %9, i32* %1
%10 = load i32, i32* %1
%11 = and i32 %10, -449
store i32 %11, i32* %1
%12 = load i32, i32* %1
%13 = or i32 %12, 192
store i32 %13, i32* %1
%14 = load i32, i32* %1
%15 = and i32 %14, -28673
store i32 %15, i32* %1
%16 = load i32, i32* %1
%17 = or i32 %16, 12288
store i32 %17, i32* %1
%18 = load i32, i32* %1
%19 = and i32 %18, -229377
store i32 %19, i32* %1
%20 = load i32, i32* %1
%21 = or i32 %20, 98304
store i32 %21, i32* %1
%22 = load i32, i32* %1
%23 = and i32 %22, -14680065
store i32 %23, i32* %1
%24 = load i32, i32* %1
%25 = or i32 %24, 6291456
store i32 %25, i32* %1
%26 = load i32, i32* %1
%27 = call i32 @write_to_address(i32 1059061768, i32 %26)
ret void
}

LLVM IR (-O2):
define void @jtag_init() {
%1 = tail call i32 @read_from_address(i32 1059061760)
%2 = and i32 %1, -28673
%3 = or i32 %2, 8192
%4 = tail call i32 @write_to_address(i32 1059061760, i32 %3)
%5 = tail call i32 @read_from_address(i32 1059061768)
%6 = and i32 %5, -14938561
%7 = or i32 %6, 6402240
%8 = tail call i32 @write_to_address(i32 1059061768, i32 %7)
ret void
}