#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
main() {
  int bin[8] = {0, 0, 0, 0, 0, 0, 0, 0}, i, j;
  const int valor[10] = {256, 128, 64, 32, 16, 8, 4, 2, 1, 0};
  char n;
  printf("ingresa el digito:");
  scanf("%c", &n);
  for (i = 0; i <= 8; ++i) {
    if (n <= valor[i] && n >= valor[i + 1]) {
      bin[i] = 1;
      n = n - (valor[i + 1]);
    }
  }
  printf("el valor es: ");
  for (i = 0; i < 8; ++i) {
    printf("%d", bin[i]);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1040 <memset@plt>
lea    -0x60(%rbp),%rdi
lea    0xe96(%rip),%rsi
mov    $0x28,%edx
call   1050 <memcpy@plt>
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb2(%rip),%rdi
lea    -0x61(%rbp),%rsi
call   1060 <scanf@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0x8,-0x34(%rbp)
jg     11ff <main+0xbf>
movsbl -0x61(%rbp),%eax
movslq -0x34(%rbp),%rcx
cmp    -0x60(%rbp,%rcx,4),%eax
jg     11ec <main+0xac>
movsbl -0x61(%rbp),%eax
mov    -0x34(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
cmp    -0x60(%rbp,%rcx,4),%eax
jl     11ec <main+0xac>
movslq -0x34(%rbp),%rax
movl   $0x1,-0x30(%rbp,%rax,4)
movsbl -0x61(%rbp),%eax
mov    -0x34(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
sub    -0x60(%rbp,%rcx,4),%eax
mov    %al,-0x61(%rbp)
jmp    11f1 <main+0xb1>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1199 <main+0x59>
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0x8,-0x34(%rbp)
jge    1242 <main+0x102>
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%esi
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1214 <main+0xd4>
lea    0xe06(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x70,%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    0xebb(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec0(%rip),%rdi
lea    0xf(%rsp),%rsi
call   1050 <scanf@plt>
movzbl 0xf(%rsp),%eax
lea    -0x40(%rax),%ecx
cmp    $0x40,%al
movzbl %cl,%ecx
cmovl  %eax,%ecx
lea    -0x20(%rcx),%edx
cmp    $0x20,%cl
movzbl %dl,%edx
cmovl  %ecx,%edx
lea    -0x10(%rdx),%esi
cmp    $0x10,%dl
movzbl %sil,%esi
cmovl  %edx,%esi
lea    -0x8(%rsi),%edi
cmp    $0x8,%sil
movzbl %dil,%edi
cmovl  %esi,%edi
lea    -0x4(%rdi),%ebp
cmp    $0x4,%dil
movzbl %bpl,%ebp
cmovl  %edi,%ebp
lea    -0x2(%rbp),%ebx
cmp    $0x2,%bpl
movzbl %bl,%ebx
cmovl  %ebp,%ebx
cmp    $0x3f,%al
jg     11cf <main+0x9f>
cmp    $0x1f,%cl
jg     11cf <main+0x9f>
cmp    $0xf,%dl
jg     11cf <main+0x9f>
cmp    $0x7,%sil
jg     11cf <main+0x9f>
cmp    $0x3,%dil
jg     11cf <main+0x9f>
cmp    $0x2,%bpl
jl     11d3 <main+0xa3>
mov    %bl,0xf(%rsp)
mov    $0x1,%r8d
test   %bl,%bl
jg     11e4 <main+0xb4>
xor    %r8d,%r8d
test   %bl,%bl
js     11e9 <main+0xb9>
movb   $0x0,0xf(%rsp)
mov    %r8d,0x10(%rsp)
xor    %ebx,%ebx
cmp    $0x2,%bpl
setge  %bl
mov    %ebx,0x14(%rsp)
xor    %r12d,%r12d
cmp    $0x4,%dil
setge  %r12b
xor    %r13d,%r13d
cmp    $0x8,%sil
setge  %r13b
xor    %ebx,%ebx
cmp    $0x10,%dl
setge  %bl
xor    %r14d,%r14d
cmp    $0x20,%cl
setge  %r14b
xor    %r15d,%r15d
cmp    $0x40,%al
setge  %r15b
lea    0xde3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xde3(%rip),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    0x14(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    0x10(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.valor = [10 x i32] [i32 256, i32 128, i32 64, i32 32, i32 16, i32 8, i32 4, i32 2, i32 1, i32 0]
@.str = [19 x i8] c"ingresa el digito:\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [14 x i8] c"el valor es: \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [8 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca [10 x i32]
%6 = alloca i8
store i32 0, i32* %1
%7 = bitcast [8 x i32]* %2 to i8*
%8 = bitcast [10 x i32]* %5 to i8*
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %6)
store i32 0, i32* %3
br label %11
11: ; preds = %45, %0
%12 = load i32, i32* %3
%13 = icmp sle i32 %12, 8
br i1 %13, label %14, label %48
14: ; preds = %11
%15 = load i8, i8* %6
%16 = sext i8 %15 to i32
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 %18
%20 = load i32, i32* %19
%21 = icmp sle i32 %16, %20
br i1 %21, label %22, label %44
22: ; preds = %14
%23 = load i8, i8* %6
%24 = sext i8 %23 to i32
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 %27
%29 = load i32, i32* %28
%30 = icmp sge i32 %24, %29
br i1 %30, label %31, label %44
31: ; preds = %22
%32 = load i32, i32* %3
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 %33
store i32 1, i32* %34
%35 = load i8, i8* %6
%36 = sext i8 %35 to i32
%37 = load i32, i32* %3
%38 = add nsw i32 %37, 1
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 %39
%41 = load i32, i32* %40
%42 = sub nsw i32 %36, %41
%43 = trunc i32 %42 to i8
store i8 %43, i8* %6
br label %44
44: ; preds = %31, %22, %14
br label %45
45: ; preds = %44
%46 = load i32, i32* %3
%47 = add nsw i32 %46, 1
store i32 %47, i32* %3
br label %11
48: ; preds = %11
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %50
50: ; preds = %59, %48
%51 = load i32, i32* %3
%52 = icmp slt i32 %51, 8
br i1 %52, label %53, label %62
53: ; preds = %50
%54 = load i32, i32* %3
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 %55
%57 = load i32, i32* %56
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %57)
br label %59
59: ; preds = %53
%60 = load i32, i32* %3
%61 = add nsw i32 %60, 1
store i32 %61, i32* %3
br label %50
62: ; preds = %50
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%64 = load i32, i32* %1
ret i32 %64
}

LLVM IR (-O2):
@.str = [19 x i8] c"ingresa el digito:\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [14 x i8] c"el valor es: \00"
@.str.3 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i8
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%4 = load i8, i8* %1
%5 = icmp slt i8 %4, 64
%6 = add nsw i8 %4, -64
%7 = select i1 %5, i8 %4, i8 %6
%8 = icmp slt i8 %7, 32
%9 = add nsw i8 %7, -32
%10 = select i1 %8, i8 %7, i8 %9
%11 = and i1 %5, %8
%12 = icmp slt i8 %10, 16
%13 = add nsw i8 %10, -16
%14 = select i1 %12, i8 %10, i8 %13
%15 = and i1 %11, %12
%16 = icmp slt i8 %14, 8
%17 = add nsw i8 %14, -8
%18 = select i1 %16, i8 %14, i8 %17
%19 = and i1 %15, %16
%20 = icmp slt i8 %18, 4
%21 = add nsw i8 %18, -4
%22 = select i1 %20, i8 %18, i8 %21
%23 = and i1 %19, %20
%24 = icmp slt i8 %22, 2
%25 = add nsw i8 %22, -2
%26 = select i1 %24, i8 %22, i8 %25
%27 = and i1 %23, %24
br i1 %27, label %29, label %28
28: ; preds = %0
store i8 %26, i8* %1
br label %29
29: ; preds = %0, %28
%30 = icmp slt i8 %26, 1
br i1 %30, label %31, label %33
31: ; preds = %29
%32 = icmp slt i8 %26, 0
br i1 %32, label %35, label %33
33: ; preds = %29, %31
%34 = phi i32 [ 0, %31 ], [ 1, %29 ]
store i8 0, i8* %1
br label %35
35: ; preds = %33, %31
%36 = phi i32 [ %34, %33 ], [ 0, %31 ]
%37 = xor i1 %24, true
%38 = zext i1 %37 to i32
%39 = xor i1 %20, true
%40 = zext i1 %39 to i32
%41 = xor i1 %16, true
%42 = zext i1 %41 to i32
%43 = xor i1 %12, true
%44 = zext i1 %43 to i32
%45 = xor i1 %8, true
%46 = zext i1 %45 to i32
%47 = xor i1 %5, true
%48 = zext i1 %47 to i32
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 0)
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %48)
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %46)
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %44)
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %42)
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %40)
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %38)
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %36)
%58 = call i32 @putchar(i32 10)
ret i32 0
}