#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 */
int /*<<< orphan*/ StoreRegister(int, int, char *);
int /*<<< orphan*/ printf(char *);
void updateButtons(int c, char *registers) {
  printf("\r\npress q to exit");
  switch (c) {
  case 97:
    StoreRegister(0b00010000, 1, registers);
    StoreRegister(0b00010001, 0, registers);
    printf("\r\nA Pressed");
    break;
  case 98:
    StoreRegister(0b00010000, 0, registers);
    StoreRegister(0b00010001, 1, registers);
    printf("\r\nB Pressed");
    break;
  default:
    StoreRegister(0b00010000, 0, registers);
    StoreRegister(0b00010001, 0, registers);
    printf("\r\n          ");
    break;
  }
}


x86 assembly (clang, -O0):
<updateButtons>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeca(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
sub    $0x61,%eax
je     1160 <updateButtons+0x40>
jmp    114f <updateButtons+0x2f>
mov    -0x14(%rbp),%eax
sub    $0x62,%eax
je     1194 <updateButtons+0x74>
jmp    11c8 <updateButtons+0xa8>
mov    -0x10(%rbp),%rdx
mov    $0x10,%edi
mov    $0x1,%esi
call   1040 <StoreRegister@plt>
mov    -0x10(%rbp),%rdx
mov    $0x11,%edi
xor    %esi,%esi
call   1040 <StoreRegister@plt>
lea    0xe88(%rip),%rdi
call   1030 <printf@plt>
jmp    11f4 <updateButtons+0xd4>
mov    -0x10(%rbp),%rdx
mov    $0x10,%edi
xor    %esi,%esi
call   1040 <StoreRegister@plt>
mov    -0x10(%rbp),%rdx
mov    $0x11,%edi
mov    $0x1,%esi
call   1040 <StoreRegister@plt>
lea    0xe60(%rip),%rdi
call   1030 <printf@plt>
jmp    11f4 <updateButtons+0xd4>
mov    -0x10(%rbp),%rdx
mov    $0x10,%edi
xor    %esi,%esi
call   1040 <StoreRegister@plt>
mov    -0x10(%rbp),%rdx
mov    $0x11,%edi
xor    %esi,%esi
call   1040 <StoreRegister@plt>
lea    0xe3b(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<updateButtons>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xed0(%rip),%rdi
call   1030 <printf@plt>
cmp    $0x61,%ebp
je     114f <updateButtons+0x2f>
cmp    $0x62,%ebp
jne    115f <updateButtons+0x3f>
lea    0xed8(%rip),%r14
mov    $0x1,%ebp
xor    %esi,%esi
jmp    116a <updateButtons+0x4a>
lea    0xebc(%rip),%r14
xor    %ebp,%ebp
mov    $0x1,%esi
jmp    116a <updateButtons+0x4a>
lea    0xec4(%rip),%r14
xor    %esi,%esi
xor    %ebp,%ebp
mov    $0x10,%edi
mov    %rbx,%rdx
call   1040 <StoreRegister@plt>
mov    $0x11,%edi
mov    %ebp,%esi
mov    %rbx,%rdx
call   1040 <StoreRegister@plt>
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"\0D\0Apress q to exit\00"
@.str.1 = [12 x i8] c"\0D\0AA Pressed\00"
@.str.2 = [12 x i8] c"\0D\0AB Pressed\00"
@.str.3 = [13 x i8] c"\0D\0A \00"
define void @updateButtons(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %3
store i8* %1, i8** %4
%5 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* %3
switch i32 %6, label %19 [
i32 97, label %7
i32 98, label %13
]
7: ; preds = %2
%8 = load i8*, i8** %4
%9 = call i32 @StoreRegister(i32 16, i32 1, i8* %8)
%10 = load i8*, i8** %4
%11 = call i32 @StoreRegister(i32 17, i32 0, i8* %10)
%12 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %25
13: ; preds = %2
%14 = load i8*, i8** %4
%15 = call i32 @StoreRegister(i32 16, i32 0, i8* %14)
%16 = load i8*, i8** %4
%17 = call i32 @StoreRegister(i32 17, i32 1, i8* %16)
%18 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %25
19: ; preds = %2
%20 = load i8*, i8** %4
%21 = call i32 @StoreRegister(i32 16, i32 0, i8* %20)
%22 = load i8*, i8** %4
%23 = call i32 @StoreRegister(i32 17, i32 0, i8* %22)
%24 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %25
25: ; preds = %19, %13, %7
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"\0D\0Apress q to exit\00"
@.str.1 = [12 x i8] c"\0D\0AA Pressed\00"
@.str.2 = [12 x i8] c"\0D\0AB Pressed\00"
@.str.3 = [13 x i8] c"\0D\0A \00"
define void @updateButtons(i32 %0, i8* %1) {
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
switch i32 %0, label %5 [
i32 97, label %6
i32 98, label %4
]
4: ; preds = %2
br label %6
5: ; preds = %2
br label %6
6: ; preds = %2, %5, %4
%7 = phi i32 [ 0, %5 ], [ 0, %4 ], [ 1, %2 ]
%8 = phi i32 [ 0, %5 ], [ 1, %4 ], [ 0, %2 ]
%9 = phi i8* [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), %5 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), %4 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), %2 ]
%10 = tail call i32 @StoreRegister(i32 16, i32 %7, i8* %1)
%11 = tail call i32 @StoreRegister(i32 17, i32 %8, i8* %1)
%12 = tail call i32 @printf(i8* dereferenceable(1) %9)
ret void
}