#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, short *);
int main() {
  short N, M, i, j;
  printf("Enter the value of N\n");
  scanf("%d", &N);
  printf("Enter the value of M\n");
  scanf("%d", &M);
  printf("Enter the value of i\n");
  scanf("%d", &i);
  printf("Enter the value of j\n");
  scanf("%d", &j);
  int mask;
  mask = ~0;
  printf("%d\n", mask);
  mask = mask << (32 - j);
  printf("%d\n", mask);
  mask = mask >> (32 - j);
  printf("%d\n", mask);
  mask = mask >> i;
  printf("%d\n", mask);
  mask = mask << i;
  printf("%d\n", mask);
  mask = ~0 ^ mask;
  printf("%d\n", mask);
  N = N & mask;
  N = N | (M << i);
  printf("\n%d", N);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf20(%rip),%rdi
lea    -0x2(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xec9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf02(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee4(%rip),%rdi
lea    -0x6(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec6(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0xffffffff,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
movswl -0x8(%rbp),%edx
mov    $0x20,%ecx
sub    %edx,%ecx
shl    %cl,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
movswl -0x8(%rbp),%edx
mov    $0x20,%ecx
sub    %edx,%ecx
sar    %cl,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
movswl -0x6(%rbp),%ecx
sar    %cl,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
movswl -0x6(%rbp),%ecx
shl    %cl,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
xor    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movswl -0x2(%rbp),%eax
and    -0xc(%rbp),%eax
mov    %ax,-0x2(%rbp)
movswl -0x2(%rbp),%eax
movswl -0x4(%rbp),%edx
movswl -0x6(%rbp),%ecx
shl    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
mov    %ax,-0x2(%rbp)
movswl -0x2(%rbp),%esi
lea    0xdda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xecd(%rip),%rdi
call   1030 <puts@plt>
lea    0xebe(%rip),%rbx
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xec2(%rip),%rdi
call   1030 <puts@plt>
lea    0x6(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xebe(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xebc(%rip),%rdi
call   1030 <puts@plt>
lea    0x2(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xe5c(%rip),%r14
mov    $0xffffffff,%ebx
mov    %r14,%rdi
mov    $0xffffffff,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %ecx,%ecx
sub    0x2(%rsp),%cl
shl    %cl,%ebx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %ecx,%ecx
sub    0x2(%rsp),%cl
sar    %cl,%ebx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp),%cl
sar    %cl,%ebx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp),%cl
shl    %cl,%ebx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
not    %ebx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
and    0x4(%rsp),%bx
movzwl 0x6(%rsp),%eax
mov    (%rsp),%cl
shl    %cl,%eax
or     %ebx,%eax
mov    %ax,0x4(%rsp)
movswl %ax,%esi
lea    0xdd4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Enter the value of N\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [22 x i8] c"Enter the value of M\0A\00"
@.str.3 = [22 x i8] c"Enter the value of i\0A\00"
@.str.4 = [22 x i8] c"Enter the value of j\0A\00"
@.str.5 = [4 x i8] c"%d\0A\00"
@.str.6 = [4 x i8] c"\0A%d\00"
define i32 @main() {
%1 = alloca i16
%2 = alloca i16
%3 = alloca i16
%4 = alloca i16
%5 = alloca i32
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i16* %1)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i16* %2)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i16* %3)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i16* %4)
store i32 -1, i32* %5
%14 = load i32, i32* %5
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %14)
%16 = load i32, i32* %5
%17 = load i16, i16* %4
%18 = sext i16 %17 to i32
%19 = sub nsw i32 32, %18
%20 = shl i32 %16, %19
store i32 %20, i32* %5
%21 = load i32, i32* %5
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %21)
%23 = load i32, i32* %5
%24 = load i16, i16* %4
%25 = sext i16 %24 to i32
%26 = sub nsw i32 32, %25
%27 = ashr i32 %23, %26
store i32 %27, i32* %5
%28 = load i32, i32* %5
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %28)
%30 = load i32, i32* %5
%31 = load i16, i16* %3
%32 = sext i16 %31 to i32
%33 = ashr i32 %30, %32
store i32 %33, i32* %5
%34 = load i32, i32* %5
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %34)
%36 = load i32, i32* %5
%37 = load i16, i16* %3
%38 = sext i16 %37 to i32
%39 = shl i32 %36, %38
store i32 %39, i32* %5
%40 = load i32, i32* %5
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %40)
%42 = load i32, i32* %5
%43 = xor i32 -1, %42
store i32 %43, i32* %5
%44 = load i32, i32* %5
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %44)
%46 = load i16, i16* %1
%47 = sext i16 %46 to i32
%48 = load i32, i32* %5
%49 = and i32 %47, %48
%50 = trunc i32 %49 to i16
store i16 %50, i16* %1
%51 = load i16, i16* %1
%52 = sext i16 %51 to i32
%53 = load i16, i16* %2
%54 = sext i16 %53 to i32
%55 = load i16, i16* %3
%56 = sext i16 %55 to i32
%57 = shl i32 %54, %56
%58 = or i32 %52, %57
%59 = trunc i32 %58 to i16
store i16 %59, i16* %1
%60 = load i16, i16* %1
%61 = sext i16 %60 to i32
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %61)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.5 = [4 x i8] c"%d\0A\00"
@.str.6 = [4 x i8] c"\0A%d\00"
@str = [21 x i8] c"Enter the value of N\00"
@str.7 = [21 x i8] c"Enter the value of M\00"
@str.8 = [21 x i8] c"Enter the value of i\00"
@str.9 = [21 x i8] c"Enter the value of j\00"
define i32 @main() {
%1 = alloca i16
%2 = alloca i16
%3 = alloca i16
%4 = alloca i16
%5 = bitcast i16* %1 to i8*
%6 = bitcast i16* %2 to i8*
%7 = bitcast i16* %3 to i8*
%8 = bitcast i16* %4 to i8*
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i16* %1)
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.7, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i16* %2)
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.8, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i16* %3)
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.9, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i16* %4)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 -1)
%18 = load i16, i16* %4
%19 = sext i16 %18 to i32
%20 = sub nsw i32 32, %19
%21 = shl nsw i32 -1, %20
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %21)
%23 = load i16, i16* %4
%24 = sext i16 %23 to i32
%25 = sub nsw i32 32, %24
%26 = ashr i32 %21, %25
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %26)
%28 = load i16, i16* %3
%29 = zext i16 %28 to i32
%30 = ashr i32 %26, %29
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %30)
%32 = load i16, i16* %3
%33 = zext i16 %32 to i32
%34 = shl i32 %30, %33
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %34)
%36 = xor i32 %34, -1
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %36)
%38 = load i16, i16* %1
%39 = trunc i32 %36 to i16
%40 = and i16 %38, %39
%41 = load i16, i16* %2
%42 = zext i16 %41 to i32
%43 = load i16, i16* %3
%44 = zext i16 %43 to i32
%45 = shl i32 %42, %44
%46 = trunc i32 %45 to i16
%47 = or i16 %40, %46
store i16 %47, i16* %1
%48 = sext i16 %47 to i32
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %48)
ret i32 0
}