#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);
unsigned short invert(unsigned short, unsigned short, unsigned short);
int /*<<< orphan*/ printf(char *, unsigned short, int, ...);
void main() {
  unsigned short int n = 0;
  unsigned short int p = 0;
  unsigned short int setb = 0;
  unsigned short int inv = 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));
  inv = invert(x, p, n);
  printf("rezult of inv = %d; and in binary = %12d;\n", inv, dec_bin(inv));
}


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   $0x0,-0xc(%rbp)
movw   $0x3,-0x2(%rbp)
movw   $0x7,-0x4(%rbp)
movw   $0x1d2,-0xa(%rbp)
movw   $0xa5,-0xc(%rbp)
mov    -0x2(%rbp),%ax
movzwl -0x4(%rbp),%edx
movzwl -0xa(%rbp),%ecx
movzwl -0xc(%rbp),%r8d
lea    0xe74(%rip),%rdi
movzwl %ax,%esi
mov    $0x0,%al
call   1040 <printf@plt>
movzwl -0x2(%rbp),%edi
call   1050 <dec_bin@plt>
mov    %ax,-0x10(%rbp)
movzwl -0x4(%rbp),%edi
call   1050 <dec_bin@plt>
mov    %eax,-0x18(%rbp)
movzwl -0xa(%rbp),%edi
call   1050 <dec_bin@plt>
mov    %eax,-0x14(%rbp)
movzwl -0xc(%rbp),%edi
call   1050 <dec_bin@plt>
mov    -0x18(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    %eax,%r8d
mov    -0x10(%rbp),%ax
lea    0xe49(%rip),%rdi
movzwl %ax,%esi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xa(%rbp),%cx
mov    -0x4(%rbp),%ax
movzwl %cx,%edi
movzwl %ax,%esi
movzwl -0x2(%rbp),%edx
call   1030 <invert@plt>
mov    %ax,-0x8(%rbp)
mov    -0x8(%rbp),%ax
mov    %ax,-0xe(%rbp)
movzwl -0x8(%rbp),%edi
call   1050 <dec_bin@plt>
mov    %eax,%edx
mov    -0xe(%rbp),%ax
lea    0xe58(%rip),%rdi
movzwl %ax,%esi
mov    $0x0,%al
call   1040 <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   1040 <printf@plt>
mov    $0x3,%edi
call   1050 <dec_bin@plt>
mov    %eax,%r14d
mov    $0x7,%edi
call   1050 <dec_bin@plt>
mov    %eax,%ebp
mov    $0x1d2,%edi
call   1050 <dec_bin@plt>
mov    %eax,%ebx
mov    $0xa5,%edi
call   1050 <dec_bin@plt>
movzwl %r14w,%esi
lea    0xe90(%rip),%rdi
mov    %ebp,%edx
mov    %ebx,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1d2,%edi
mov    $0x7,%esi
mov    $0x3,%edx
call   1030 <invert@plt>
movzwl %ax,%ebx
mov    %ebx,%edi
call   1050 <dec_bin@plt>
lea    0xeaf(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <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 = [43 x i8] c"rezult of inv = %d; and in binary = %12d;\0A\00"
define void @main() {
%1 = alloca i16
%2 = alloca i16
%3 = alloca i16
%4 = alloca i16
%5 = alloca i16
%6 = 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 0, i16* %6
store i16 3, i16* %1
store i16 7, i16* %2
store i16 466, i16* %5
store i16 165, i16* %6
%7 = load i16, i16* %1
%8 = load i16, i16* %2
%9 = zext i16 %8 to i32
%10 = load i16, i16* %5
%11 = zext i16 %10 to i32
%12 = load i16, i16* %6
%13 = zext i16 %12 to i32
%14 = call i32 (i8*, i16, i32, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i16 zeroext %7, i32 %9, i32 %11, i32 %13)
%15 = load i16, i16* %1
%16 = call i32 @dec_bin(i16 zeroext %15)
%17 = trunc i32 %16 to i16
%18 = load i16, i16* %2
%19 = call i32 @dec_bin(i16 zeroext %18)
%20 = load i16, i16* %5
%21 = call i32 @dec_bin(i16 zeroext %20)
%22 = load i16, i16* %6
%23 = call i32 @dec_bin(i16 zeroext %22)
%24 = call i32 (i8*, i16, i32, ...) @printf(i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.1, i64 0, i64 0), i16 zeroext %17, i32 %19, i32 %21, i32 %23)
%25 = load i16, i16* %5
%26 = load i16, i16* %2
%27 = load i16, i16* %1
%28 = call zeroext i16 @invert(i16 zeroext %25, i16 zeroext %26, i16 zeroext %27)
store i16 %28, i16* %4
%29 = load i16, i16* %4
%30 = load i16, i16* %4
%31 = call i32 @dec_bin(i16 zeroext %30)
%32 = call i32 (i8*, i16, i32, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 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 = [43 x i8] c"rezult of inv = %d; and in binary = %12d;\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 @invert(i16 zeroext 466, i16 zeroext 7, i16 zeroext 3)
%9 = tail call i32 @dec_bin(i16 zeroext %8)
%10 = tail call i32 (i8*, i16, i32, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i16 zeroext %8, i32 %9)
ret void
}