#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 */
char *binString(unsigned short);
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, unsigned short *);
int main(void) {
  unsigned short int value;
  printf("Please a number 0-65.535 %c ", 16);
  scanf("%d", &value);
  printf("%d is 0x%X in decimal and ", value, value);
  printf("%s in binary.", binString(value));
  while (getchar() != '\n')
    continue;
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x10,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb4(%rip),%rdi
lea    -0x6(%rbp),%rsi
call   1060 <scanf@plt>
movzwl -0x6(%rbp),%esi
movzwl -0x6(%rbp),%edx
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movzwl -0x6(%rbp),%edi
call   1040 <binString@plt>
mov    %rax,%rsi
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     11ba <main+0x7a>
jmp    11a2 <main+0x62>
mov    $0x0,%al
call   1050 <getchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xeb8(%rip),%rdi
mov    $0x10,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xec2(%rip),%rdi
lea    0x6(%rsp),%rsi
call   1060 <scanf@plt>
movzwl 0x6(%rsp),%edx
lea    0xeaf(%rip),%rdi
mov    %edx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
movzwl 0x6(%rsp),%edi
call   1040 <binString@plt>
lea    0xeb0(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
jne    11a0 <main+0x60>
xor    %eax,%eax
call   1050 <getchar@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [29 x i8] c"Please a number 0-65.535 %c \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [27 x i8] c"%d is 0x%X in decimal and \00"
@.str.3 = [14 x i8] c"%s in binary.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i16
store i32 0, i32* %1
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 16)
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i16* %2)
%5 = load i16, i16* %2
%6 = zext i16 %5 to i32
%7 = load i16, i16* %2
%8 = zext i16 %7 to i32
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %6, i32 %8)
%10 = load i16, i16* %2
%11 = call i8* @binString(i16 zeroext %10)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %11)
br label %13
13: ; preds = %17, %0
%14 = call signext i8 (...) @getchar()
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 10
br i1 %16, label %17, label %18
17: ; preds = %13
br label %13
18: ; preds = %13
%19 = call signext i8 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@.str = [29 x i8] c"Please a number 0-65.535 %c \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [27 x i8] c"%d is 0x%X in decimal and \00"
@.str.3 = [14 x i8] c"%s in binary.\00"
define i32 @main() {
%1 = alloca i16
%2 = bitcast i16* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 16)
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i16* %1)
%5 = load i16, i16* %1
%6 = zext i16 %5 to i32
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %6, i32 %6)
%8 = load i16, i16* %1
%9 = call i8* @binString(i16 zeroext %8)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %9)
br label %11
11: ; preds = %11, %0
%12 = call signext i8 (...) @getchar()
%13 = icmp eq i8 %12, 10
br i1 %13, label %14, label %11
14: ; preds = %11
%15 = call signext i8 (...) @getchar()
ret i32 0
}