#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 reg0(void) {
  uint32_t reg0 = 0;
  printf("\ninput reg0: ");
  if (scanf("%x", &reg0)) {
    printf("INT enable: %u \n", (reg0 & 1 << 31) != 0);
    printf("N: %u \n", (reg0 & (0xFFFF << 15)) >> 15);
    printf("F: %u \n", (reg0 & (0xFFF << 3)) >> 3);
  }
}


x86 assembly (clang, -O0):
<reg0>:
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     11ac <reg0+0x8c>
mov    -0x4(%rbp),%eax
and    $0x80000000,%eax
cmp    $0x0,%eax
setne  %al
and    $0x1,%al
movzbl %al,%esi
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%esi
and    $0x7fff8000,%esi
sar    $0xf,%esi
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%esi
and    $0x7ff8,%esi
sar    $0x3,%esi
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reg0>:
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     1195 <reg0+0x75>
mov    0x4(%rsp),%esi
shr    $0x1f,%esi
lea    0xeb6(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x4(%rsp),%eax
shr    $0xf,%eax
movzwl %ax,%esi
lea    0xeaf(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x4(%rsp),%esi
shr    $0x3,%esi
and    $0xfff,%esi
lea    0xe9c(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
pop    %rax
ret

LLVM IR (-O0):
@.str = [14 x i8] c"\0Ainput reg0: \00"
@.str.1 = [3 x i8] c"%x\00"
@.str.2 = [17 x i8] c"INT enable: %u \0A\00"
@.str.3 = [8 x i8] c"N: %u \0A\00"
@.str.4 = [8 x i8] c"F: %u \0A\00"
define void @reg0() {
%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 %19
5: ; preds = %0
%6 = load i32, i32* %1
%7 = and i32 %6, -2147483648
%8 = icmp ne i32 %7, 0
%9 = zext i1 %8 to i32
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%11 = load i32, i32* %1
%12 = and i32 %11, 2147450880
%13 = ashr i32 %12, 15
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %13)
%15 = load i32, i32* %1
%16 = and i32 %15, 32760
%17 = ashr i32 %16, 3
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %17)
br label %19
19: ; preds = %5, %0
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"\0Ainput reg0: \00"
@.str.1 = [3 x i8] c"%x\00"
@.str.2 = [17 x i8] c"INT enable: %u \0A\00"
@.str.3 = [8 x i8] c"N: %u \0A\00"
@.str.4 = [8 x i8] c"F: %u \0A\00"
define void @reg0() {
%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 %18, label %6
6: ; preds = %0
%7 = load i32, i32* %1
%8 = lshr i32 %7, 31
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %8)
%10 = load i32, i32* %1
%11 = lshr i32 %10, 15
%12 = and i32 %11, 65535
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %12)
%14 = load i32, i32* %1
%15 = lshr i32 %14, 3
%16 = and i32 %15, 4095
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %16)
br label %18
18: ; preds = %6, %0
ret void
}