int ej11() {
  int num, i, j, comp = 1, and;
  int binario[16];
  int cp[] = {1,   2,   4,    8,    16,   32,   64,    128,
              256, 512, 1024, 2048, 4096, 8192, 16384, 32768};
  printf("Escriba el numero entero que desea conocer en binario: \n");
  scanf("%d", &num);
  for (i = 1; i <= 16; i++) {
    and = num & comp;
    if (and == cp[i - 1]) {
      binario[(i - 1)] = 1;
    } else {
      binario[(i - 1)] = 0;
    }
    comp = comp << 1;
  }
  printf("El numero %d en binario es: \n", num);
  for (j = 1; j <= 16; j++) {
    printf("%d", binario[15 - (j - 1)]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<ej11>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x1,-0x10(%rbp)
lea    -0xa0(%rbp),%rdi
lea    0xeb0(%rip),%rsi
mov    $0x40,%edx
call   1040 <memcpy@plt>
lea    0xedf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf0a(%rip),%rdi
lea    -0x4(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movl   $0x1,-0x8(%rbp)
cmpl   $0x10,-0x8(%rbp)
jg     11e9 <ej11+0xb9>
mov    -0x4(%rbp),%eax
and    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
cmp    -0xa0(%rbp,%rcx,4),%eax
jne    11c2 <ej11+0x92>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cltq
movl   $0x1,-0x60(%rbp,%rax,4)
jmp    11d2 <ej11+0xa2>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cltq
movl   $0x0,-0x60(%rbp,%rax,4)
mov    -0x10(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1181 <ej11+0x51>
mov    -0x4(%rbp),%esi
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0xc(%rbp)
cmpl   $0x10,-0xc(%rbp)
jg     123a <ej11+0x10a>
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
mov    $0xf,%eax
sub    %ecx,%eax
cltq
mov    -0x60(%rbp,%rax,4),%esi
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1201 <ej11+0xd1>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ej11>:
push   %rbx
sub    $0x50,%rsp
lea    0xf25(%rip),%rdi
call   1030 <puts@plt>
lea    0xef8(%rip),%rdi
xor    %ebx,%ebx
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    $0x1,%eax
mov    0xc(%rsp),%esi
lea    0xe9a(%rip),%rcx
cs nopw 0x0(%rax,%rax,1)
mov    %esi,%edx
and    %eax,%edx
xor    %edi,%edi
cmp    (%rcx,%rbx,4),%edx
sete   %dil
mov    %edi,0x10(%rsp,%rbx,4)
lea    (%rax,%rax,1),%edx
and    %esi,%edx
xor    %edi,%edi
cmp    0x4(%rcx,%rbx,4),%edx
sete   %dil
mov    %edi,0x14(%rsp,%rbx,4)
shl    $0x2,%eax
add    $0x2,%rbx
cmp    $0x10,%rbx
jne    1170 <ej11+0x40>
lea    0xe9b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4c(%rsp),%esi
lea    0xe86(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x48(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x44(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x40(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x3c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x38(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x34(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x30(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x28(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x24(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x20(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x1c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.ej11.cp = [16 x i32] [i32 1, i32 2, i32 4, i32 8, i32 16, i32 32, i32 64, i32 128, i32 256, i32 512, i32 1024, i32 2048, i32 4096, i32 8192, i32 16384, i32 32768]
@.str = [57 x i8] c"Escriba el numero entero que desea conocer en binario: \0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [30 x i8] c"El numero %d en binario es: \0A\00"
define i32 @ej11() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [16 x i32]
%7 = alloca [16 x i32]
store i32 1, i32* %4
%8 = bitcast [16 x i32]* %7 to i8*
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
store i32 1, i32* %2
br label %11
11: ; preds = %38, %0
%12 = load i32, i32* %2
%13 = icmp sle i32 %12, 16
br i1 %13, label %14, label %41
14: ; preds = %11
%15 = load i32, i32* %1
%16 = load i32, i32* %4
%17 = and i32 %15, %16
store i32 %17, i32* %5
%18 = load i32, i32* %5
%19 = load i32, i32* %2
%20 = sub nsw i32 %19, 1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [16 x i32], [16 x i32]* %7, i64 0, i64 %21
%23 = load i32, i32* %22
%24 = icmp eq i32 %18, %23
br i1 %24, label %25, label %30
25: ; preds = %14
%26 = load i32, i32* %2
%27 = sub nsw i32 %26, 1
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [16 x i32], [16 x i32]* %6, i64 0, i64 %28
store i32 1, i32* %29
br label %35
30: ; preds = %14
%31 = load i32, i32* %2
%32 = sub nsw i32 %31, 1
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [16 x i32], [16 x i32]* %6, i64 0, i64 %33
store i32 0, i32* %34
br label %35
35: ; preds = %30, %25
%36 = load i32, i32* %4
%37 = shl i32 %36, 1
store i32 %37, i32* %4
br label %38
38: ; preds = %35
%39 = load i32, i32* %2
%40 = add nsw i32 %39, 1
store i32 %40, i32* %2
br label %11
41: ; preds = %11
%42 = load i32, i32* %1
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i32 %42)
store i32 1, i32* %3
br label %44
44: ; preds = %55, %41
%45 = load i32, i32* %3
%46 = icmp sle i32 %45, 16
br i1 %46, label %47, label %58
47: ; preds = %44
%48 = load i32, i32* %3
%49 = sub nsw i32 %48, 1
%50 = sub nsw i32 15, %49
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [16 x i32], [16 x i32]* %6, i64 0, i64 %51
%53 = load i32, i32* %52
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %53)
br label %55
55: ; preds = %47
%56 = load i32, i32* %3
%57 = add nsw i32 %56, 1
store i32 %57, i32* %3
br label %44
58: ; preds = %44
ret i32 0
}

LLVM IR (-O2):
@__const.ej11.cp = [16 x i32] [i32 1, i32 2, i32 4, i32 8, i32 16, i32 32, i32 64, i32 128, i32 256, i32 512, i32 1024, i32 2048, i32 4096, i32 8192, i32 16384, i32 32768]
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [30 x i8] c"El numero %d en binario es: \0A\00"
@str = [56 x i8] c"Escriba el numero entero que desea conocer en binario: \00"
define i32 @ej11() {
%1 = alloca i32
%2 = alloca [16 x i32]
%3 = bitcast i32* %1 to i8*
%4 = bitcast [16 x i32]* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
br label %8
8: ; preds = %8, %0
%9 = phi i64 [ 1, %0 ], [ %26, %8 ]
%10 = phi i32 [ 1, %0 ], [ %25, %8 ]
%11 = and i32 %7, %10
%12 = add nsw i64 %9, -1
%13 = getelementptr inbounds [16 x i32], [16 x i32]* @__const.ej11.cp, i64 0, i64 %12
%14 = load i32, i32* %13
%15 = icmp eq i32 %11, %14
%16 = zext i1 %15 to i32
%17 = getelementptr inbounds [16 x i32], [16 x i32]* %2, i64 0, i64 %12
store i32 %16, i32* %17
%18 = shl i32 %10, 1
%19 = and i32 %7, %18
%20 = getelementptr inbounds [16 x i32], [16 x i32]* @__const.ej11.cp, i64 0, i64 %9
%21 = load i32, i32* %20
%22 = icmp eq i32 %19, %21
%23 = zext i1 %22 to i32
%24 = getelementptr inbounds [16 x i32], [16 x i32]* %2, i64 0, i64 %9
store i32 %23, i32* %24
%25 = shl i32 %10, 2
%26 = add nuw nsw i64 %9, 2
%27 = icmp eq i64 %26, 17
br i1 %27, label %28, label %8
28: ; preds = %8
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%30 = getelementptr inbounds [16 x i32], [16 x i32]* %2, i64 0, i64 15
%31 = load i32, i32* %30
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %31)
%33 = getelementptr inbounds [16 x i32], [16 x i32]* %2, i64 0, i64 14
%34 = load i32, i32* %33
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %34)
%36 = getelementptr inbounds [16 x i32], [16 x i32]* %2, i64 0, i64 13
%37 = load i32, i32* %36
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %37)
%39 = getelementptr inbounds [16 x i32], [16 x i32]* %2, i64 0, i64 12
%40 = load i32, i32* %39
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %40)
%42 = getelementptr inbounds [16 x i32], [16 x i32]* %2, i64 0, i64 11
%43 = load i32, i32* %42
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %43)
%45 = getelementptr inbounds [16 x i32], [16 x i32]* %2, i64 0, i64 10
%46 = load i32, i32* %45
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %46)
%48 = getelementptr inbounds [16 x i32], [16 x i32]* %2, i64 0, i64 9
%49 = load i32, i32* %48
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %49)
%51 = getelementptr inbounds [16 x i32], [16 x i32]* %2, i64 0, i64 8
%52 = load i32, i32* %51
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %52)
%54 = getelementptr inbounds [16 x i32], [16 x i32]* %2, i64 0, i64 7
%55 = load i32, i32* %54
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %55)
%57 = getelementptr inbounds [16 x i32], [16 x i32]* %2, i64 0, i64 6
%58 = load i32, i32* %57
%59 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %58)
%60 = getelementptr inbounds [16 x i32], [16 x i32]* %2, i64 0, i64 5
%61 = load i32, i32* %60
%62 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %61)
%63 = getelementptr inbounds [16 x i32], [16 x i32]* %2, i64 0, i64 4
%64 = load i32, i32* %63
%65 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %64)
%66 = getelementptr inbounds [16 x i32], [16 x i32]* %2, i64 0, i64 3
%67 = load i32, i32* %66
%68 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %67)
%69 = getelementptr inbounds [16 x i32], [16 x i32]* %2, i64 0, i64 2
%70 = load i32, i32* %69
%71 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %70)
%72 = getelementptr inbounds [16 x i32], [16 x i32]* %2, i64 0, i64 1
%73 = load i32, i32* %72
%74 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %73)
%75 = getelementptr inbounds [16 x i32], [16 x i32]* %2, i64 0, i64 0
%76 = load i32, i32* %75
%77 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %76)
ret i32 0
}