#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 */
unsigned int insert_into(unsigned int, unsigned int, unsigned int,
                         unsigned int);
int /*<<< orphan*/ print_binary(unsigned int);
int /*<<< orphan*/ printf(char *);
int scanf(char *, unsigned int *, unsigned int *, unsigned int *,
          unsigned int *);
int main(void) {
  printf("Enter N, M, j, and i\n");
  unsigned N, M, j, i;
  while (scanf("%u%u%u%u", &N, &M, &j, &i) == 4) {
    printf("N =\t\t");
    print_binary(N);
    printf("\nM =\t\t");
    print_binary(M);
    printf("\nResult =\t");
    print_binary(insert_into(N, M, j, i));
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb4(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%r8
call   1060 <scanf@plt>
cmp    $0x4,%eax
jne    11dd <main+0x9d>
lea    0xe98(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
call   1050 <print_binary@plt>
lea    0xe8a(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%edi
call   1050 <print_binary@plt>
lea    0xe7d(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
call   1040 <insert_into@plt>
mov    %eax,%edi
call   1050 <print_binary@plt>
lea    0xe41(%rip),%rdi
call   1030 <printf@plt>
jmp    115b <main+0x1b>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xeac(%rip),%rdi
call   1040 <puts@plt>
lea    0xe7f(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
lea    0x14(%rsp),%rcx
lea    0x10(%rsp),%r8
call   1080 <scanf@plt>
cmp    $0x4,%eax
jne    1241 <main+0xe1>
lea    0xe6c(%rip),%r12
lea    0xe4f(%rip),%r13
lea    0xc(%rsp),%rbx
lea    0x8(%rsp),%rbp
lea    0x14(%rsp),%r14
lea    0x10(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xe32(%rip),%rdi
call   1050 <printf@plt>
mov    0xc(%rsp),%edi
call   1070 <print_binary@plt>
lea    0xe23(%rip),%rdi
call   1050 <printf@plt>
mov    0x8(%rsp),%edi
call   1070 <print_binary@plt>
mov    %r12,%rdi
call   1050 <printf@plt>
mov    0xc(%rsp),%edi
mov    0x8(%rsp),%esi
mov    0x14(%rsp),%edx
mov    0x10(%rsp),%ecx
call   1060 <insert_into@plt>
mov    %eax,%edi
call   1070 <print_binary@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
mov    %r14,%rcx
mov    %r15,%r8
call   1080 <scanf@plt>
cmp    $0x4,%eax
je     11d0 <main+0x70>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Enter N, M, j, and i\0A\00"
@.str.1 = [9 x i8] c"%u%u%u%u\00"
@.str.2 = [6 x i8] c"N =\09\09\00"
@.str.3 = [7 x i8] c"\0AM =\09\09\00"
@.str.4 = [11 x i8] c"\0AResult =\09\00"
@.str.5 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %10, %0
%8 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3, i32* %4, i32* %5)
%9 = icmp eq i32 %8, 4
br i1 %9, label %10, label %25
10: ; preds = %7
%11 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%12 = load i32, i32* %2
%13 = call i32 @print_binary(i32 %12)
%14 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%15 = load i32, i32* %3
%16 = call i32 @print_binary(i32 %15)
%17 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%18 = load i32, i32* %2
%19 = load i32, i32* %3
%20 = load i32, i32* %4
%21 = load i32, i32* %5
%22 = call i32 @insert_into(i32 %18, i32 %19, i32 %20, i32 %21)
%23 = call i32 @print_binary(i32 %22)
%24 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %7
25: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [9 x i8] c"%u%u%u%u\00"
@.str.2 = [6 x i8] c"N =\09\09\00"
@.str.3 = [7 x i8] c"\0AM =\09\09\00"
@.str.4 = [11 x i8] c"\0AResult =\09\00"
@str = [21 x i8] c"Enter N, M, j, and i\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%6 = bitcast i32* %1 to i8*
%7 = bitcast i32* %2 to i8*
%8 = bitcast i32* %3 to i8*
%9 = bitcast i32* %4 to i8*
%10 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2, i32* %3, i32* %4)
%11 = icmp eq i32 %10, 4
br i1 %11, label %12, label %29
12: ; preds = %0, %12
%13 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%14 = load i32, i32* %1
%15 = call i32 @print_binary(i32 %14)
%16 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%17 = load i32, i32* %2
%18 = call i32 @print_binary(i32 %17)
%19 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%20 = load i32, i32* %1
%21 = load i32, i32* %2
%22 = load i32, i32* %3
%23 = load i32, i32* %4
%24 = call i32 @insert_into(i32 %20, i32 %21, i32 %22, i32 %23)
%25 = call i32 @print_binary(i32 %24)
%26 = call i32 @putchar(i32 10)
%27 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2, i32* %3, i32* %4)
%28 = icmp eq i32 %27, 4
br i1 %28, label %12, label %29
29: ; preds = %12, %0
ret i32 0
}