#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*/ affiche_bin(unsigned short);
int /*<<< orphan*/ printf(char *, unsigned short, unsigned short);
int main() {
  unsigned short x = 0b0000111000101100, masque1 = 0b1111111100000000,
                 masque2 = 0b0000000011111111, poidsfort = x & masque1,
                 poidsfaible = x & masque2;
  printf("masque 1 : %d => %x\n", masque1, masque1);
  printf("masque 2 : %d => %x\n", masque2, masque2);
  printf("Poids fort de x : %d => %x\n", poidsfort, poidsfort);
  printf("Poids faible de x : %d => %x\n", poidsfaible, poidsfaible);
  affiche_bin(x);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movw   $0xe2c,-0x6(%rbp)
movw   $0xff00,-0x8(%rbp)
movw   $0xff,-0xa(%rbp)
movzwl -0x6(%rbp),%eax
movzwl -0x8(%rbp),%ecx
and    %ecx,%eax
mov    %ax,-0xc(%rbp)
movzwl -0x6(%rbp),%eax
movzwl -0xa(%rbp),%ecx
and    %ecx,%eax
mov    %ax,-0xe(%rbp)
mov    -0x8(%rbp),%ax
lea    0xe98(%rip),%rdi
movzwl %ax,%esi
movzwl -0x8(%rbp),%edx
call   1030 <printf@plt>
mov    -0xa(%rbp),%ax
lea    0xe96(%rip),%rdi
movzwl %ax,%esi
movzwl -0xa(%rbp),%edx
call   1030 <printf@plt>
mov    -0xc(%rbp),%ax
lea    0xe94(%rip),%rdi
movzwl %ax,%esi
movzwl -0xc(%rbp),%edx
call   1030 <printf@plt>
mov    -0xe(%rbp),%ax
lea    0xe99(%rip),%rdi
movzwl %ax,%esi
movzwl -0xe(%rbp),%edx
call   1030 <printf@plt>
movzwl -0x6(%rbp),%edi
call   1040 <affiche_bin@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
mov    $0xff00,%esi
mov    $0xff00,%edx
call   1030 <printf@plt>
lea    0xed7(%rip),%rdi
mov    $0xff,%esi
mov    $0xff,%edx
call   1030 <printf@plt>
lea    0xed6(%rip),%rdi
mov    $0xe00,%esi
mov    $0xe00,%edx
call   1030 <printf@plt>
lea    0xedc(%rip),%rdi
mov    $0x2c,%esi
mov    $0x2c,%edx
call   1030 <printf@plt>
mov    $0xe2c,%edi
call   1040 <affiche_bin@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [21 x i8] c"masque 1 : %d => %x\0A\00"
@.str.1 = [21 x i8] c"masque 2 : %d => %x\0A\00"
@.str.2 = [28 x i8] c"Poids fort de x : %d => %x\0A\00"
@.str.3 = [30 x i8] c"Poids faible de x : %d => %x\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i16
%3 = alloca i16
%4 = alloca i16
%5 = alloca i16
%6 = alloca i16
store i32 0, i32* %1
store i16 3628, i16* %2
store i16 -256, i16* %3
store i16 255, i16* %4
%7 = load i16, i16* %2
%8 = zext i16 %7 to i32
%9 = load i16, i16* %3
%10 = zext i16 %9 to i32
%11 = and i32 %8, %10
%12 = trunc i32 %11 to i16
store i16 %12, i16* %5
%13 = load i16, i16* %2
%14 = zext i16 %13 to i32
%15 = load i16, i16* %4
%16 = zext i16 %15 to i32
%17 = and i32 %14, %16
%18 = trunc i32 %17 to i16
store i16 %18, i16* %6
%19 = load i16, i16* %3
%20 = load i16, i16* %3
%21 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i16 zeroext %19, i16 zeroext %20)
%22 = load i16, i16* %4
%23 = load i16, i16* %4
%24 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i16 zeroext %22, i16 zeroext %23)
%25 = load i16, i16* %5
%26 = load i16, i16* %5
%27 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i16 zeroext %25, i16 zeroext %26)
%28 = load i16, i16* %6
%29 = load i16, i16* %6
%30 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i16 zeroext %28, i16 zeroext %29)
%31 = load i16, i16* %2
%32 = call i32 @affiche_bin(i16 zeroext %31)
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c"masque 1 : %d => %x\0A\00"
@.str.1 = [21 x i8] c"masque 2 : %d => %x\0A\00"
@.str.2 = [28 x i8] c"Poids fort de x : %d => %x\0A\00"
@.str.3 = [30 x i8] c"Poids faible de x : %d => %x\0A\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i16 zeroext -256, i16 zeroext -256)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i16 zeroext 255, i16 zeroext 255)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i16 zeroext 3584, i16 zeroext 3584)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i16 zeroext 44, i16 zeroext 44)
%5 = tail call i32 @affiche_bin(i16 zeroext 3628)
ret i32 0
}