#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 */
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ scanf(char *, int *);
void reg4(void) {
  uint32_t reg4 = 0;
  printf("\ninput reg4: ");
  if (scanf("%x", &reg4)) {
    printf("DIVA: %u \n", (reg4 & (0b111 << 20)) >> 20);
    printf("FB: %u \n", (reg4 & 1 << 23) != 0);
    printf("BS: %u \n",
           ((reg4 & (0xFF << 12)) >> 12) + ((reg4 & (0b11 << 24)) >> 16));
    printf("BPWR: %u \n", (reg4 & (0b11 << 6)) >> 6);
    printf("APWR: %u \n", (reg4 & (0b11 << 3)) >> 3);
    printf("RFA_EN: %u \n", (reg4 & 1 << 5) != 0);
    printf("RFB_EN: %u \n", (reg4 & 1 << 8) != 0);
  }
}


x86 assembly (clang, -O0):
<reg4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeca(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
cmp    $0x0,%rax
je     122a <reg4+0x10a>
mov    -0x4(%rbp),%esi
and    $0x700000,%esi
sar    $0x14,%esi
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
and    $0x800000,%eax
cmp    $0x0,%eax
setne  %al
and    $0x1,%al
movzbl %al,%esi
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%esi
and    $0xff000,%esi
sar    $0xc,%esi
mov    -0x4(%rbp),%eax
and    $0x3000000,%eax
sar    $0x10,%eax
add    %eax,%esi
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%esi
and    $0xc0,%esi
sar    $0x6,%esi
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%esi
and    $0x18,%esi
sar    $0x3,%esi
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
and    $0x20,%eax
cmp    $0x0,%eax
setne  %al
and    $0x1,%al
movzbl %al,%esi
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
and    $0x100,%eax
cmp    $0x0,%eax
setne  %al
and    $0x1,%al
movzbl %al,%esi
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reg4>:
push   %rax
movl   $0x0,0x4(%rsp)
lea    0xed0(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed0(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
test   %rax,%rax
je     1206 <reg4+0xe6>
mov    0x4(%rsp),%esi
shr    $0x14,%esi
and    $0x7,%esi
lea    0xeaf(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x4(%rsp),%esi
shr    $0x17,%esi
and    $0x1,%esi
lea    0xea2(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x4(%rsp),%esi
mov    %esi,%eax
shr    $0xc,%eax
movzbl %al,%eax
shr    $0x10,%esi
and    $0x300,%esi
or     %eax,%esi
lea    0xe86(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x4(%rsp),%esi
shr    $0x6,%esi
and    $0x3,%esi
lea    0xe77(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x4(%rsp),%esi
shr    $0x3,%esi
and    $0x3,%esi
lea    0xe6a(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x4(%rsp),%esi
shr    $0x5,%esi
and    $0x1,%esi
lea    0xe5d(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x4(%rsp),%esi
shr    $0x8,%esi
and    $0x1,%esi
lea    0xe52(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
pop    %rax
ret

LLVM IR (-O0):
@.str = [14 x i8] c"\0Ainput reg4: \00"
@.str.1 = [3 x i8] c"%x\00"
@.str.2 = [11 x i8] c"DIVA: %u \0A\00"
@.str.3 = [9 x i8] c"FB: %u \0A\00"
@.str.4 = [9 x i8] c"BS: %u \0A\00"
@.str.5 = [11 x i8] c"BPWR: %u \0A\00"
@.str.6 = [11 x i8] c"APWR: %u \0A\00"
@.str.7 = [13 x i8] c"RFA_EN: %u \0A\00"
@.str.8 = [13 x i8] c"RFB_EN: %u \0A\00"
define void @reg4() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%3 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%4 = icmp ne i64 %3, 0
br i1 %4, label %5, label %41
5: ; preds = %0
%6 = load i32, i32* %1
%7 = and i32 %6, 7340032
%8 = ashr i32 %7, 20
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %8)
%10 = load i32, i32* %1
%11 = and i32 %10, 8388608
%12 = icmp ne i32 %11, 0
%13 = zext i1 %12 to i32
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %13)
%15 = load i32, i32* %1
%16 = and i32 %15, 1044480
%17 = ashr i32 %16, 12
%18 = load i32, i32* %1
%19 = and i32 %18, 50331648
%20 = ashr i32 %19, 16
%21 = add nsw i32 %17, %20
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 %21)
%23 = load i32, i32* %1
%24 = and i32 %23, 192
%25 = ashr i32 %24, 6
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i32 %25)
%27 = load i32, i32* %1
%28 = and i32 %27, 24
%29 = ashr i32 %28, 3
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i32 %29)
%31 = load i32, i32* %1
%32 = and i32 %31, 32
%33 = icmp ne i32 %32, 0
%34 = zext i1 %33 to i32
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i32 %34)
%36 = load i32, i32* %1
%37 = and i32 %36, 256
%38 = icmp ne i32 %37, 0
%39 = zext i1 %38 to i32
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i32 %39)
br label %41
41: ; preds = %5, %0
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"\0Ainput reg4: \00"
@.str.1 = [3 x i8] c"%x\00"
@.str.2 = [11 x i8] c"DIVA: %u \0A\00"
@.str.3 = [9 x i8] c"FB: %u \0A\00"
@.str.4 = [9 x i8] c"BS: %u \0A\00"
@.str.5 = [11 x i8] c"BPWR: %u \0A\00"
@.str.6 = [11 x i8] c"APWR: %u \0A\00"
@.str.7 = [13 x i8] c"RFA_EN: %u \0A\00"
@.str.8 = [13 x i8] c"RFB_EN: %u \0A\00"
define void @reg4() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%4 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = icmp eq i64 %4, 0
br i1 %5, label %38, label %6
6: ; preds = %0
%7 = load i32, i32* %1
%8 = lshr i32 %7, 20
%9 = and i32 %8, 7
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%11 = load i32, i32* %1
%12 = lshr i32 %11, 23
%13 = and i32 %12, 1
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %13)
%15 = load i32, i32* %1
%16 = lshr i32 %15, 12
%17 = and i32 %16, 255
%18 = lshr i32 %15, 16
%19 = and i32 %18, 768
%20 = or i32 %17, %19
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 %20)
%22 = load i32, i32* %1
%23 = lshr i32 %22, 6
%24 = and i32 %23, 3
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i32 %24)
%26 = load i32, i32* %1
%27 = lshr i32 %26, 3
%28 = and i32 %27, 3
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i32 %28)
%30 = load i32, i32* %1
%31 = lshr i32 %30, 5
%32 = and i32 %31, 1
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i32 %32)
%34 = load i32, i32* %1
%35 = lshr i32 %34, 8
%36 = and i32 %35, 1
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i32 %36)
br label %38
38: ; preds = %6, %0
ret void
}