int InitPad(void) {
  int pad_connected = 3;
  unsigned char temp;
  int count;
  (*(volatile unsigned char *)(0x20100000 + 0x79)) = 0x60;
  (*(volatile unsigned char *)(0x20100000 + 0x7b)) = 0x60;
  (*(volatile unsigned char *)(0x20100000 + 0x7d)) = 1 | 2;
  (*(volatile unsigned char *)(0x20100000 + 0x7f)) = 0x00;
  (*(volatile unsigned char *)(0x20100000 + 0x75)) = 0x60;
  for (count = 0; count < 16; count++) {
    (*(volatile unsigned char *)(0x20100000 + 0x75)) = 0x60;
  }
  temp = (*(volatile unsigned char *)(0x20100000 + 0x75));
  if ((temp & 0x1) != 0x00) {
    pad_connected -= 1;
  }
  (*(volatile unsigned char *)(0x20100000 + 0x77)) = 0x60;
  for (count = 0; count < 16; count++) {
    (*(volatile unsigned char *)(0x20100000 + 0x77)) = 0x60;
  }
  temp = (*(volatile unsigned char *)(0x20100000 + 0x77));
  if ((temp & 0x1) != 0x00) {
    pad_connected -= 2;
  }
  return pad_connected;
}


x86 assembly (clang, -O0):
<InitPad>:
push   %rbp
mov    %rsp,%rbp
movl   $0x3,-0x4(%rbp)
mov    $0x20100079,%eax
movb   $0x60,(%rax)
mov    $0x2010007b,%eax
movb   $0x60,(%rax)
mov    $0x2010007d,%eax
movb   $0x3,(%rax)
mov    $0x2010007f,%eax
movb   $0x0,(%rax)
mov    $0x20100075,%eax
movb   $0x60,(%rax)
movl   $0x0,-0xc(%rbp)
cmpl   $0x10,-0xc(%rbp)
jge    115a <InitPad+0x5a>
mov    $0x20100075,%eax
movb   $0x60,(%rax)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    113a <InitPad+0x3a>
mov    $0x20100075,%eax
mov    (%rax),%al
mov    %al,-0x5(%rbp)
movzbl -0x5(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     117d <InitPad+0x7d>
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    $0x20100077,%eax
movb   $0x60,(%rax)
movl   $0x0,-0xc(%rbp)
cmpl   $0x10,-0xc(%rbp)
jge    11ac <InitPad+0xac>
mov    $0x20100077,%eax
movb   $0x60,(%rax)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    118c <InitPad+0x8c>
mov    $0x20100077,%eax
mov    (%rax),%al
mov    %al,-0x5(%rbp)
movzbl -0x5(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     11cf <InitPad+0xcf>
mov    -0x4(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<InitPad>:
movb   $0x60,0x20100079
60
movb   $0x60,0x2010007b
60
movb   $0x3,0x2010007d
03
movb   $0x0,0x2010007f
movb   $0x60,0x20100075
60
movb   $0x60,0x20100075
60
movb   $0x60,0x20100075
60
movb   $0x60,0x20100075
60
movb   $0x60,0x20100075
60
movb   $0x60,0x20100075
60
movb   $0x60,0x20100075
60
movb   $0x60,0x20100075
60
movb   $0x60,0x20100075
60
movb   $0x60,0x20100075
60
movb   $0x60,0x20100075
60
movb   $0x60,0x20100075
60
movb   $0x60,0x20100075
60
movb   $0x60,0x20100075
60
movb   $0x60,0x20100075
60
movb   $0x60,0x20100075
60
movb   $0x60,0x20100075
60
movzbl 0x20100075,%ecx
20
xor    %eax,%eax
and    $0x1,%ecx
sete   %al
movb   $0x60,0x20100077
60
movb   $0x60,0x20100077
60
movb   $0x60,0x20100077
60
movb   $0x60,0x20100077
60
movb   $0x60,0x20100077
60
movb   $0x60,0x20100077
60
movb   $0x60,0x20100077
60
movb   $0x60,0x20100077
60
movb   $0x60,0x20100077
60
movb   $0x60,0x20100077
60
movb   $0x60,0x20100077
60
movb   $0x60,0x20100077
60
movb   $0x60,0x20100077
60
movb   $0x60,0x20100077
60
movb   $0x60,0x20100077
60
movb   $0x60,0x20100077
60
movb   $0x60,0x20100077
60
xor    $0x3,%ecx
testb  $0x1,0x20100077
01
cmove  %ecx,%eax
ret

LLVM IR (-O0):
define i32 @InitPad() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
store i32 3, i32* %1
store volatile i8 96, i8* inttoptr (i64 537919609 to i8*)
store volatile i8 96, i8* inttoptr (i64 537919611 to i8*)
store volatile i8 3, i8* inttoptr (i64 537919613 to i8*)
store volatile i8 0, i8* inttoptr (i64 537919615 to i8*)
store volatile i8 96, i8* inttoptr (i64 537919605 to i8*)
store i32 0, i32* %3
br label %4
4: ; preds = %8, %0
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 16
br i1 %6, label %7, label %11
7: ; preds = %4
store volatile i8 96, i8* inttoptr (i64 537919605 to i8*)
br label %8
8: ; preds = %7
%9 = load i32, i32* %3
%10 = add nsw i32 %9, 1
store i32 %10, i32* %3
br label %4
11: ; preds = %4
%12 = load volatile i8, i8* inttoptr (i64 537919605 to i8*)
store i8 %12, i8* %2
%13 = load i8, i8* %2
%14 = zext i8 %13 to i32
%15 = and i32 %14, 1
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %11
%18 = load i32, i32* %1
%19 = sub nsw i32 %18, 1
store i32 %19, i32* %1
br label %20
20: ; preds = %17, %11
store volatile i8 96, i8* inttoptr (i64 537919607 to i8*)
store i32 0, i32* %3
br label %21
21: ; preds = %25, %20
%22 = load i32, i32* %3
%23 = icmp slt i32 %22, 16
br i1 %23, label %24, label %28
24: ; preds = %21
store volatile i8 96, i8* inttoptr (i64 537919607 to i8*)
br label %25
25: ; preds = %24
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 1
store i32 %27, i32* %3
br label %21
28: ; preds = %21
%29 = load volatile i8, i8* inttoptr (i64 537919607 to i8*)
store i8 %29, i8* %2
%30 = load i8, i8* %2
%31 = zext i8 %30 to i32
%32 = and i32 %31, 1
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %28
%35 = load i32, i32* %1
%36 = sub nsw i32 %35, 2
store i32 %36, i32* %1
br label %37
37: ; preds = %34, %28
%38 = load i32, i32* %1
ret i32 %38
}

LLVM IR (-O2):
define i32 @InitPad() {
store volatile i8 96, i8* inttoptr (i64 537919609 to i8*)
store volatile i8 96, i8* inttoptr (i64 537919611 to i8*)
store volatile i8 3, i8* inttoptr (i64 537919613 to i8*)
store volatile i8 0, i8* inttoptr (i64 537919615 to i8*)
store volatile i8 96, i8* inttoptr (i64 537919605 to i8*)
store volatile i8 96, i8* inttoptr (i64 537919605 to i8*)
store volatile i8 96, i8* inttoptr (i64 537919605 to i8*)
store volatile i8 96, i8* inttoptr (i64 537919605 to i8*)
store volatile i8 96, i8* inttoptr (i64 537919605 to i8*)
store volatile i8 96, i8* inttoptr (i64 537919605 to i8*)
store volatile i8 96, i8* inttoptr (i64 537919605 to i8*)
store volatile i8 96, i8* inttoptr (i64 537919605 to i8*)
store volatile i8 96, i8* inttoptr (i64 537919605 to i8*)
store volatile i8 96, i8* inttoptr (i64 537919605 to i8*)
store volatile i8 96, i8* inttoptr (i64 537919605 to i8*)
store volatile i8 96, i8* inttoptr (i64 537919605 to i8*)
store volatile i8 96, i8* inttoptr (i64 537919605 to i8*)
store volatile i8 96, i8* inttoptr (i64 537919605 to i8*)
store volatile i8 96, i8* inttoptr (i64 537919605 to i8*)
store volatile i8 96, i8* inttoptr (i64 537919605 to i8*)
store volatile i8 96, i8* inttoptr (i64 537919605 to i8*)
%1 = load volatile i8, i8* inttoptr (i64 537919605 to i8*)
%2 = and i8 %1, 1
%3 = icmp eq i8 %2, 0
store volatile i8 96, i8* inttoptr (i64 537919607 to i8*)
store volatile i8 96, i8* inttoptr (i64 537919607 to i8*)
store volatile i8 96, i8* inttoptr (i64 537919607 to i8*)
store volatile i8 96, i8* inttoptr (i64 537919607 to i8*)
store volatile i8 96, i8* inttoptr (i64 537919607 to i8*)
store volatile i8 96, i8* inttoptr (i64 537919607 to i8*)
store volatile i8 96, i8* inttoptr (i64 537919607 to i8*)
store volatile i8 96, i8* inttoptr (i64 537919607 to i8*)
store volatile i8 96, i8* inttoptr (i64 537919607 to i8*)
store volatile i8 96, i8* inttoptr (i64 537919607 to i8*)
store volatile i8 96, i8* inttoptr (i64 537919607 to i8*)
store volatile i8 96, i8* inttoptr (i64 537919607 to i8*)
store volatile i8 96, i8* inttoptr (i64 537919607 to i8*)
store volatile i8 96, i8* inttoptr (i64 537919607 to i8*)
store volatile i8 96, i8* inttoptr (i64 537919607 to i8*)
store volatile i8 96, i8* inttoptr (i64 537919607 to i8*)
store volatile i8 96, i8* inttoptr (i64 537919607 to i8*)
%4 = select i1 %3, i32 3, i32 2
%5 = load volatile i8, i8* inttoptr (i64 537919607 to i8*)
%6 = and i8 %5, 1
%7 = icmp eq i8 %6, 0
%8 = add nsw i32 %4, -2
%9 = select i1 %7, i32 %4, i32 %8
ret i32 %9
}