#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 dec_bin(unsigned short);
int /*<<< orphan*/ printf(char *, unsigned short, int, ...);
unsigned short setbits(unsigned short, unsigned short, unsigned short,
                       unsigned short);
void main() {
  unsigned short int n = 0;
  unsigned short int p = 0;
  unsigned short int setb = 0;
  unsigned short int x = 0;
  unsigned short int y = 0;
  n = 3;
  p = 7;
  x = 466;
  y = 0245;
  printf("n = %d;\np = %d;\nx = %d;\ny = %d;\n", n, p, x, y);
  printf("n in binary = %36d;\np in binary = %36d;\nx in binary = %36d;\ny in "
         "binary = %36d;\n\n",
         dec_bin(n), dec_bin(p), dec_bin(x), dec_bin(y));
  setb = setbits(x, p, n, y);
  printf("rezult = %4d; and in binary = %19d;\n", setb, dec_bin(setb));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movw   $0x0,-0x2(%rbp)
movw   $0x0,-0x4(%rbp)
movw   $0x0,-0x6(%rbp)
movw   $0x0,-0x8(%rbp)
movw   $0x0,-0xa(%rbp)
movw   $0x3,-0x2(%rbp)
movw   $0x7,-0x4(%rbp)
movw   $0x1d2,-0x8(%rbp)
movw   $0xa5,-0xa(%rbp)
mov    -0x2(%rbp),%ax
movzwl -0x4(%rbp),%edx
movzwl -0x8(%rbp),%ecx
movzwl -0xa(%rbp),%r8d
lea    0xe7a(%rip),%rdi
movzwl %ax,%esi
mov    $0x0,%al
call   1030 <printf@plt>
movzwl -0x2(%rbp),%edi
call   1040 <dec_bin@plt>
mov    %ax,-0xe(%rbp)
movzwl -0x4(%rbp),%edi
call   1040 <dec_bin@plt>
mov    %eax,-0x18(%rbp)
movzwl -0x8(%rbp),%edi
call   1040 <dec_bin@plt>
mov    %eax,-0x14(%rbp)
movzwl -0xa(%rbp),%edi
call   1040 <dec_bin@plt>
mov    -0x18(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    %eax,%r8d
mov    -0xe(%rbp),%ax
lea    0xe4f(%rip),%rdi
movzwl %ax,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%dx
mov    -0x4(%rbp),%cx
mov    -0x2(%rbp),%ax
movzwl %dx,%edi
movzwl %cx,%esi
movzwl %ax,%edx
movzwl -0xa(%rbp),%ecx
call   1050 <setbits@plt>
mov    %ax,-0x6(%rbp)
mov    -0x6(%rbp),%ax
mov    %ax,-0xc(%rbp)
movzwl -0x6(%rbp),%edi
call   1040 <dec_bin@plt>
mov    %eax,%edx
mov    -0xc(%rbp),%ax
lea    0xe57(%rip),%rdi
movzwl %ax,%esi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
lea    0xec5(%rip),%rdi
mov    $0x3,%esi
mov    $0x7,%edx
mov    $0x1d2,%ecx
mov    $0xa5,%r8d
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x3,%edi
call   1040 <dec_bin@plt>
mov    %eax,%r14d
mov    $0x7,%edi
call   1040 <dec_bin@plt>
mov    %eax,%ebp
mov    $0x1d2,%edi
call   1040 <dec_bin@plt>
mov    %eax,%ebx
mov    $0xa5,%edi
call   1040 <dec_bin@plt>
movzwl %r14w,%esi
lea    0xe90(%rip),%rdi
mov    %ebp,%edx
mov    %ebx,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1d2,%edi
mov    $0x7,%esi
mov    $0x3,%edx
mov    $0xa5,%ecx
call   1050 <setbits@plt>
movzwl %ax,%ebx
mov    %ebx,%edi
call   1040 <dec_bin@plt>
lea    0xeaa(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [33 x i8] c"n = %d;\0Ap = %d;\0Ax = %d;\0Ay = %d;\0A\00"
@.str.1 = [82 x i8] c"n in binary = %36d;\0Ap in binary = %36d;\0Ax in binary = %36d;\0Ay in binary = %36d;\0A\0A\00"
@.str.2 = [37 x i8] c"rezult = %4d; and in binary = %19d;\0A\00"
define void @main() {
%1 = alloca i16
%2 = alloca i16
%3 = alloca i16
%4 = alloca i16
%5 = alloca i16
store i16 0, i16* %1
store i16 0, i16* %2
store i16 0, i16* %3
store i16 0, i16* %4
store i16 0, i16* %5
store i16 3, i16* %1
store i16 7, i16* %2
store i16 466, i16* %4
store i16 165, i16* %5
%6 = load i16, i16* %1
%7 = load i16, i16* %2
%8 = zext i16 %7 to i32
%9 = load i16, i16* %4
%10 = zext i16 %9 to i32
%11 = load i16, i16* %5
%12 = zext i16 %11 to i32
%13 = call i32 (i8*, i16, i32, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i16 zeroext %6, i32 %8, i32 %10, i32 %12)
%14 = load i16, i16* %1
%15 = call i32 @dec_bin(i16 zeroext %14)
%16 = trunc i32 %15 to i16
%17 = load i16, i16* %2
%18 = call i32 @dec_bin(i16 zeroext %17)
%19 = load i16, i16* %4
%20 = call i32 @dec_bin(i16 zeroext %19)
%21 = load i16, i16* %5
%22 = call i32 @dec_bin(i16 zeroext %21)
%23 = call i32 (i8*, i16, i32, ...) @printf(i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.1, i64 0, i64 0), i16 zeroext %16, i32 %18, i32 %20, i32 %22)
%24 = load i16, i16* %4
%25 = load i16, i16* %2
%26 = load i16, i16* %1
%27 = load i16, i16* %5
%28 = call zeroext i16 @setbits(i16 zeroext %24, i16 zeroext %25, i16 zeroext %26, i16 zeroext %27)
store i16 %28, i16* %3
%29 = load i16, i16* %3
%30 = load i16, i16* %3
%31 = call i32 @dec_bin(i16 zeroext %30)
%32 = call i32 (i8*, i16, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i16 zeroext %29, i32 %31)
ret void
}

LLVM IR (-O2):
@.str = [33 x i8] c"n = %d;\0Ap = %d;\0Ax = %d;\0Ay = %d;\0A\00"
@.str.1 = [82 x i8] c"n in binary = %36d;\0Ap in binary = %36d;\0Ax in binary = %36d;\0Ay in binary = %36d;\0A\0A\00"
@.str.2 = [37 x i8] c"rezult = %4d; and in binary = %19d;\0A\00"
define void @main() {
%1 = tail call i32 (i8*, i16, i32, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i16 zeroext 3, i32 7, i32 466, i32 165)
%2 = tail call i32 @dec_bin(i16 zeroext 3)
%3 = trunc i32 %2 to i16
%4 = tail call i32 @dec_bin(i16 zeroext 7)
%5 = tail call i32 @dec_bin(i16 zeroext 466)
%6 = tail call i32 @dec_bin(i16 zeroext 165)
%7 = tail call i32 (i8*, i16, i32, ...) @printf(i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.1, i64 0, i64 0), i16 zeroext %3, i32 %4, i32 %5, i32 %6)
%8 = tail call zeroext i16 @setbits(i16 zeroext 466, i16 zeroext 7, i16 zeroext 3, i16 zeroext 165)
%9 = tail call i32 @dec_bin(i16 zeroext %8)
%10 = tail call i32 (i8*, i16, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i16 zeroext %8, i32 %9)
ret void
}