#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 /*<<< orphan*/ bit_ids;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int inl(int);
int /*<<< orphan*/ iopl(int);
int /*<<< orphan*/ outl(unsigned int, int);
int /*<<< orphan*/ stderr;
int main(int nargs, char **argv) {
  unsigned int val;
  unsigned int mask = 0x3a2f3fff;
  unsigned char bit_ids[] = {32, 33, 34, 35, 36, 37, 39};
  unsigned char bit_cfg[] = {0x44, 0x44, 0x45, 0x45, 0x45, 0x45, 0x45};
  int ix;
  iopl(3);
  val = inl(0x9030);
  fprintf(stderr, "PMR register was %08x, setting it to %08x\n", val,
          val & mask);
  val = val & mask;
  outl(val, 0x9030);
  val = inl(0x9030);
  fprintf(stderr, "PMR register now %08x\n", val);
  val = inl(0xf400 + 0x18);
  fprintf(stderr, "GPIO Int Enable1 was %08x, clearing our bits\n", val);
  val &= 0xffc0;
  outl(val, 0xf400 + 0x18);
  for (ix = 0; ix < sizeof(bit_ids); ix++) {
    fprintf(stderr, "Writing %08x to 0x20\n", (unsigned)bit_ids[ix]);
    outl((unsigned)bit_ids[ix], 0xf400 + 0x20);
    fprintf(stderr, "Writing %08x to 0x24\n", (unsigned)bit_cfg[ix]);
    outl((unsigned)bit_cfg[ix], 0xf400 + 0x24);
  }
  val = inl(0xf400 + 0x10) & 0x3f;
  outl(val, 0xf400 + 0x10);
  fprintf(stderr, "All done\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x3a2f3fff,-0x18(%rbp)
mov    0xe9d(%rip),%eax
mov    %eax,-0x1f(%rbp)
mov    0xe97(%rip),%ax
mov    %ax,-0x1b(%rbp)
mov    0xe8f(%rip),%al
mov    %al,-0x19(%rbp)
mov    0xe87(%rip),%eax
mov    %eax,-0x26(%rbp)
mov    0xe81(%rip),%ax
mov    %ax,-0x22(%rbp)
mov    0xe79(%rip),%al
mov    %al,-0x20(%rbp)
mov    $0x3,%edi
call   1030 <iopl@plt>
mov    $0x9030,%edi
call   1060 <inl@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e2b(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
mov    -0x14(%rbp),%ecx
and    -0x18(%rbp),%ecx
lea    0xe47(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x14(%rbp),%eax
and    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    $0x9030,%esi
call   1040 <outl@plt>
mov    $0x9030,%edi
call   1060 <inl@plt>
mov    %eax,-0x14(%rbp)
mov    0x2de8(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xe35(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0xf418,%edi
call   1060 <inl@plt>
mov    %eax,-0x14(%rbp)
mov    0x2dc1(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xe25(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x14(%rbp),%eax
and    $0xffc0,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    $0xf418,%esi
call   1040 <outl@plt>
movl   $0x0,-0x2c(%rbp)
movslq -0x2c(%rbp),%rax
cmp    $0x7,%rax
jae    12d3 <main+0x193>
mov    0x2d7a(%rip),%rax
mov    (%rax),%edi
movslq -0x2c(%rbp),%rax
movzbl -0x1f(%rbp,%rax,1),%edx
lea    0xe06(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movslq -0x2c(%rbp),%rax
movzbl -0x1f(%rbp,%rax,1),%edi
mov    $0xf420,%esi
call   1040 <outl@plt>
mov    0x2d47(%rip),%rax
mov    (%rax),%edi
movslq -0x2c(%rbp),%rax
movzbl -0x26(%rbp,%rax,1),%edx
lea    0xde9(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movslq -0x2c(%rbp),%rax
movzbl -0x26(%rbp,%rax,1),%edi
mov    $0xf424,%esi
call   1040 <outl@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1251 <main+0x111>
mov    $0xf410,%edi
call   1060 <inl@plt>
and    $0x3f,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    $0xf410,%esi
call   1040 <outl@plt>
mov    0x2ce9(%rip),%rax
mov    (%rax),%edi
lea    0xdaa(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    $0x3,%edi
call   1030 <iopl@plt>
mov    $0x9030,%edi
call   1060 <inl@plt>
mov    0x2e80(%rip),%r15
mov    (%r15),%edi
mov    %eax,%ebx
and    $0x3a2f3fff,%ebx
lea    0xe8e(%rip),%rsi
mov    %eax,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %ebx,%edi
mov    $0x9030,%esi
call   1040 <outl@plt>
mov    $0x9030,%edi
call   1060 <inl@plt>
mov    (%r15),%edi
lea    0xe8e(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0xf418,%edi
call   1060 <inl@plt>
mov    %eax,%ebx
mov    (%r15),%edi
lea    0xe86(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
and    $0xffc0,%ebx
mov    %ebx,%edi
mov    $0xf418,%esi
call   1040 <outl@plt>
mov    (%r15),%edi
lea    0xe8f(%rip),%r14
mov    %r14,%rsi
mov    $0x20,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x20,%edi
mov    $0xf420,%esi
call   1040 <outl@plt>
mov    (%r15),%edi
lea    0xe7d(%rip),%rbx
mov    %rbx,%rsi
mov    $0x44,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x44,%edi
mov    $0xf424,%esi
call   1040 <outl@plt>
mov    (%r15),%edi
mov    %r14,%rsi
mov    $0x21,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x21,%edi
mov    $0xf420,%esi
call   1040 <outl@plt>
mov    (%r15),%edi
mov    %rbx,%rsi
mov    $0x44,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x44,%edi
mov    $0xf424,%esi
call   1040 <outl@plt>
mov    (%r15),%edi
mov    %r14,%rsi
mov    $0x22,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x22,%edi
mov    $0xf420,%esi
call   1040 <outl@plt>
mov    (%r15),%edi
mov    %rbx,%rsi
mov    $0x45,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x45,%edi
mov    $0xf424,%esi
call   1040 <outl@plt>
mov    (%r15),%edi
mov    %r14,%rsi
mov    $0x23,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x23,%edi
mov    $0xf420,%esi
call   1040 <outl@plt>
mov    (%r15),%edi
mov    %rbx,%rsi
mov    $0x45,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x45,%edi
mov    $0xf424,%esi
call   1040 <outl@plt>
mov    (%r15),%edi
mov    %r14,%rsi
mov    $0x24,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x24,%edi
mov    $0xf420,%esi
call   1040 <outl@plt>
mov    (%r15),%edi
mov    %rbx,%rsi
mov    $0x45,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x45,%edi
mov    $0xf424,%esi
call   1040 <outl@plt>
mov    (%r15),%edi
mov    %r14,%rsi
mov    $0x25,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x25,%edi
mov    $0xf420,%esi
call   1040 <outl@plt>
mov    (%r15),%edi
mov    %rbx,%rsi
mov    $0x45,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x45,%edi
mov    $0xf424,%esi
call   1040 <outl@plt>
mov    (%r15),%edi
mov    %r14,%rsi
mov    $0x27,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x27,%edi
mov    $0xf420,%esi
call   1040 <outl@plt>
mov    (%r15),%edi
mov    %rbx,%rsi
mov    $0x45,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x45,%edi
mov    $0xf424,%esi
call   1040 <outl@plt>
mov    $0xf410,%edi
call   1060 <inl@plt>
and    $0x3f,%eax
mov    %eax,%edi
mov    $0xf410,%esi
call   1040 <outl@plt>
mov    (%r15),%edi
lea    0xcc6(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.bit_ids = [7 x i8] c" !\22#$%'"
@__const.main.bit_cfg = [7 x i8] c"DDEEEEE"
@stderr = global i32 0
@.str = [43 x i8] c"PMR register was %08x, setting it to %08x\0A\00"
@.str.1 = [23 x i8] c"PMR register now %08x\0A\00"
@.str.2 = [46 x i8] c"GPIO Int Enable1 was %08x, clearing our bits\0A\00"
@.str.3 = [22 x i8] c"Writing %08x to 0x20\0A\00"
@.str.4 = [22 x i8] c"Writing %08x to 0x24\0A\00"
@.str.5 = [10 x i8] c"All done\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 [7 x i8]
%9 = alloca [7 x i8]
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 976175103, i32* %7
%11 = bitcast [7 x i8]* %8 to i8*
%12 = bitcast [7 x i8]* %9 to i8*
%13 = call i32 @iopl(i32 3)
%14 = call i32 @inl(i32 36912)
store i32 %14, i32* %6
%15 = load i32, i32* @stderr
%16 = load i32, i32* %6
%17 = load i32, i32* %6
%18 = load i32, i32* %7
%19 = and i32 %17, %18
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 %16, i32 %19)
%21 = load i32, i32* %6
%22 = load i32, i32* %7
%23 = and i32 %21, %22
store i32 %23, i32* %6
%24 = load i32, i32* %6
%25 = call i32 @outl(i32 %24, i32 36912)
%26 = call i32 @inl(i32 36912)
store i32 %26, i32* %6
%27 = load i32, i32* @stderr
%28 = load i32, i32* %6
%29 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %28)
%30 = call i32 @inl(i32 62488)
store i32 %30, i32* %6
%31 = load i32, i32* @stderr
%32 = load i32, i32* %6
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0), i32 %32)
%34 = load i32, i32* %6
%35 = and i32 %34, 65472
store i32 %35, i32* %6
%36 = load i32, i32* %6
%37 = call i32 @outl(i32 %36, i32 62488)
store i32 0, i32* %10
br label %38
38: ; preds = %69, %2
%39 = load i32, i32* %10
%40 = sext i32 %39 to i64
%41 = icmp ult i64 %40, 7
br i1 %41, label %42, label %72
42: ; preds = %38
%43 = load i32, i32* @stderr
%44 = load i32, i32* %10
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [7 x i8], [7 x i8]* %8, i64 0, i64 %45
%47 = load i8, i8* %46
%48 = zext i8 %47 to i32
%49 = call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %48)
%50 = load i32, i32* %10
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [7 x i8], [7 x i8]* %8, i64 0, i64 %51
%53 = load i8, i8* %52
%54 = zext i8 %53 to i32
%55 = call i32 @outl(i32 %54, i32 62496)
%56 = load i32, i32* @stderr
%57 = load i32, i32* %10
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [7 x i8], [7 x i8]* %9, i64 0, i64 %58
%60 = load i8, i8* %59
%61 = zext i8 %60 to i32
%62 = call i32 (i32, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i32 %61)
%63 = load i32, i32* %10
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [7 x i8], [7 x i8]* %9, i64 0, i64 %64
%66 = load i8, i8* %65
%67 = zext i8 %66 to i32
%68 = call i32 @outl(i32 %67, i32 62500)
br label %69
69: ; preds = %42
%70 = load i32, i32* %10
%71 = add nsw i32 %70, 1
store i32 %71, i32* %10
br label %38
72: ; preds = %38
%73 = call i32 @inl(i32 62480)
%74 = and i32 %73, 63
store i32 %74, i32* %6
%75 = load i32, i32* %6
%76 = call i32 @outl(i32 %75, i32 62480)
%77 = load i32, i32* @stderr
%78 = call i32 (i32, i8*, ...) @fprintf(i32 %77, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [43 x i8] c"PMR register was %08x, setting it to %08x\0A\00"
@.str.1 = [23 x i8] c"PMR register now %08x\0A\00"
@.str.2 = [46 x i8] c"GPIO Int Enable1 was %08x, clearing our bits\0A\00"
@.str.3 = [22 x i8] c"Writing %08x to 0x20\0A\00"
@.str.4 = [22 x i8] c"Writing %08x to 0x24\0A\00"
@.str.5 = [10 x i8] c"All done\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @iopl(i32 3)
%4 = tail call i32 @inl(i32 36912)
%5 = load i32, i32* @stderr
%6 = and i32 %4, 976175103
%7 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %6)
%8 = tail call i32 @outl(i32 %6, i32 36912)
%9 = tail call i32 @inl(i32 36912)
%10 = load i32, i32* @stderr
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%12 = tail call i32 @inl(i32 62488)
%13 = load i32, i32* @stderr
%14 = tail call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%15 = and i32 %12, 65472
%16 = tail call i32 @outl(i32 %15, i32 62488)
%17 = load i32, i32* @stderr
%18 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 32)
%19 = tail call i32 @outl(i32 32, i32 62496)
%20 = load i32, i32* @stderr
%21 = tail call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i32 68)
%22 = tail call i32 @outl(i32 68, i32 62500)
%23 = load i32, i32* @stderr
%24 = tail call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 33)
%25 = tail call i32 @outl(i32 33, i32 62496)
%26 = load i32, i32* @stderr
%27 = tail call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i32 68)
%28 = tail call i32 @outl(i32 68, i32 62500)
%29 = load i32, i32* @stderr
%30 = tail call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 34)
%31 = tail call i32 @outl(i32 34, i32 62496)
%32 = load i32, i32* @stderr
%33 = tail call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i32 69)
%34 = tail call i32 @outl(i32 69, i32 62500)
%35 = load i32, i32* @stderr
%36 = tail call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 35)
%37 = tail call i32 @outl(i32 35, i32 62496)
%38 = load i32, i32* @stderr
%39 = tail call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i32 69)
%40 = tail call i32 @outl(i32 69, i32 62500)
%41 = load i32, i32* @stderr
%42 = tail call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 36)
%43 = tail call i32 @outl(i32 36, i32 62496)
%44 = load i32, i32* @stderr
%45 = tail call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i32 69)
%46 = tail call i32 @outl(i32 69, i32 62500)
%47 = load i32, i32* @stderr
%48 = tail call i32 (i32, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 37)
%49 = tail call i32 @outl(i32 37, i32 62496)
%50 = load i32, i32* @stderr
%51 = tail call i32 (i32, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i32 69)
%52 = tail call i32 @outl(i32 69, i32 62500)
%53 = load i32, i32* @stderr
%54 = tail call i32 (i32, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 39)
%55 = tail call i32 @outl(i32 39, i32 62496)
%56 = load i32, i32* @stderr
%57 = tail call i32 (i32, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i32 69)
%58 = tail call i32 @outl(i32 69, i32 62500)
%59 = tail call i32 @inl(i32 62480)
%60 = and i32 %59, 63
%61 = tail call i32 @outl(i32 %60, i32 62480)
%62 = load i32, i32* @stderr
%63 = tail call i32 (i32, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}