#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*/ puts(char *);
void printVarInFormats(size_t const size, void const *const ptr) {
  unsigned char *b = (unsigned char *)ptr;
  unsigned char byte;
  int i, j;
  unsigned short int *myInt = (unsigned short int *)ptr;
  printf("DEC:\t%d\n", *myInt);
  printf("sint DEC:\t%hu\n", *myInt);
  printf("char DEC:\t%hu\n", *b);
  printf("Binary:\t");
  for (i = size - 1; i >= 0; i--) {
    for (j = 7; j >= 0; j--) {
      byte = (b[i] >> j) & 1;
      printf("%u", byte);
    }
    printf(" ");
    if ((i > 0) && ((size - i) % 4 == 0)) {
      printf("\n\t");
    }
  }
  printf("\nHEX:\t");
  for (i = size - 1; i >= 0; i--) {
    printf("%02x ", (unsigned int)*b++);
    if ((i > 0) && ((size - i) % 4 == 0)) {
      printf("\n\t");
    }
  }
  puts("\n");
}


x86 assembly (clang, -O0):
<printVarInFormats>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movzwl (%rax),%esi
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%rax
movzwl (%rax),%esi
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
movzbl (%rax),%esi
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
sub    $0x1,%rax
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jl     123c <printVarInFormats+0x11c>
movl   $0x7,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jl     11ea <printVarInFormats+0xca>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
mov    -0x24(%rbp),%ecx
sar    %cl,%eax
and    $0x1,%eax
mov    %al,-0x19(%rbp)
movzbl -0x19(%rbp),%esi
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
jmp    11a9 <printVarInFormats+0x89>
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x20(%rbp)
jle    1229 <printVarInFormats+0x109>
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
sub    %rcx,%rax
and    $0x3,%rax
cmp    $0x0,%rax
jne    1229 <printVarInFormats+0x109>
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    122e <printVarInFormats+0x10e>
mov    -0x20(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
jmp    1198 <printVarInFormats+0x78>
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
sub    $0x1,%rax
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jl     12c3 <printVarInFormats+0x1a3>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movzbl (%rax),%esi
lea    0xdc5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x20(%rbp)
jle    12b0 <printVarInFormats+0x190>
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
sub    %rcx,%rax
and    $0x3,%rax
cmp    $0x0,%rax
jne    12b0 <printVarInFormats+0x190>
lea    0xd8a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12b5 <printVarInFormats+0x195>
mov    -0x20(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
jmp    1255 <printVarInFormats+0x135>
lea    0xd3d(%rip),%rdi
call   1030 <puts@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printVarInFormats>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
movzwl (%rsi),%esi
lea    0xeb2(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzwl (%rbx),%esi
lea    0xeaa(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl (%rbx),%esi
lea    0xea8(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xea9(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14d,%eax
add    $0xffffffff,%eax
js     130c <printVarInFormats+0x1dc>
mov    %eax,0x4(%rsp)
mov    %eax,%r13d
mov    %r14,0x10(%rsp)
sub    %r13,%r14
lea    0xe89(%rip),%r15
lea    0xe85(%rip),%r12
mov    %r13,0x8(%rsp)
jmp    11c4 <printVarInFormats+0x94>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%r14
movzbl (%rbx,%r13,1),%esi
shr    $0x7,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl (%rbx,%r13,1),%esi
shr    $0x6,%esi
and    $0x1,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl (%rbx,%r13,1),%esi
shr    $0x5,%esi
and    $0x1,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl (%rbx,%r13,1),%esi
shr    $0x4,%esi
and    $0x1,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl (%rbx,%r13,1),%esi
shr    $0x3,%esi
and    $0x1,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl (%rbx,%r13,1),%esi
shr    $0x2,%esi
and    $0x1,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl (%rbx,%r13,1),%esi
shr    %esi
and    $0x1,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl (%rbx,%r13,1),%esi
and    $0x1,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
sub    $0x1,%r13
jb     128e <printVarInFormats+0x15e>
test   $0x3,%r14b
jne    11c0 <printVarInFormats+0x90>
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11c0 <printVarInFormats+0x90>
lea    0xda1(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%ebp
test   %ebp,%ebp
mov    0x10(%rsp),%r14
mov    0x8(%rsp),%r13
js     131a <printVarInFormats+0x1ea>
movzbl (%rbx),%esi
lea    0xd85(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
test   %ebp,%ebp
je     131a <printVarInFormats+0x1ea>
sub    %r13,%r14
lea    0xd66(%rip),%r15
lea    0xd69(%rip),%r12
xor    %ebp,%ebp
jmp    12f8 <printVarInFormats+0x1c8>
nopl   0x0(%rax,%rax,1)
movzbl 0x1(%rbx,%rbp,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r13
je     131a <printVarInFormats+0x1ea>
lea    (%r14,%rbp,1),%eax
test   $0x3,%al
jne    12e0 <printVarInFormats+0x1b0>
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    12e0 <printVarInFormats+0x1b0>
lea    0xd23(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xce6(%rip),%rdi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"DEC:\09%d\0A\00"
@.str.1 = [15 x i8] c"sint DEC:\09%hu\0A\00"
@.str.2 = [15 x i8] c"char DEC:\09%hu\0A\00"
@.str.3 = [9 x i8] c"Binary:\09\00"
@.str.4 = [3 x i8] c"%u\00"
@.str.5 = [2 x i8] c" \00"
@.str.6 = [3 x i8] c"\0A\09\00"
@.str.7 = [7 x i8] c"\0AHEX:\09\00"
@.str.8 = [6 x i8] c"%02x \00"
@.str.9 = [2 x i8] c"\0A\00"
define void @printVarInFormats(i64 %0, i8* %1) {
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8
%7 = alloca i32
%8 = alloca i32
%9 = alloca i16*
store i64 %0, i64* %3
store i8* %1, i8** %4
%10 = load i8*, i8** %4
store i8* %10, i8** %5
%11 = load i8*, i8** %4
%12 = bitcast i8* %11 to i16*
store i16* %12, i16** %9
%13 = load i16*, i16** %9
%14 = load i16, i16* %13
%15 = zext i16 %14 to i32
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = load i16*, i16** %9
%18 = load i16, i16* %17
%19 = zext i16 %18 to i32
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = load i8*, i8** %5
%22 = load i8, i8* %21
%23 = zext i8 %22 to i32
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %23)
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%26 = load i64, i64* %3
%27 = sub i64 %26, 1
%28 = trunc i64 %27 to i32
store i32 %28, i32* %7
br label %29
29: ; preds = %67, %2
%30 = load i32, i32* %7
%31 = icmp sge i32 %30, 0
br i1 %31, label %32, label %70
32: ; preds = %29
store i32 7, i32* %8
br label %33
33: ; preds = %50, %32
%34 = load i32, i32* %8
%35 = icmp sge i32 %34, 0
br i1 %35, label %36, label %53
36: ; preds = %33
%37 = load i8*, i8** %5
%38 = load i32, i32* %7
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %37, i64 %39
%41 = load i8, i8* %40
%42 = zext i8 %41 to i32
%43 = load i32, i32* %8
%44 = ashr i32 %42, %43
%45 = and i32 %44, 1
%46 = trunc i32 %45 to i8
store i8 %46, i8* %6
%47 = load i8, i8* %6
%48 = zext i8 %47 to i32
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %48)
br label %50
50: ; preds = %36
%51 = load i32, i32* %8
%52 = add nsw i32 %51, -1
store i32 %52, i32* %8
br label %33
53: ; preds = %33
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%55 = load i32, i32* %7
%56 = icmp sgt i32 %55, 0
br i1 %56, label %57, label %66
57: ; preds = %53
%58 = load i64, i64* %3
%59 = load i32, i32* %7
%60 = sext i32 %59 to i64
%61 = sub i64 %58, %60
%62 = urem i64 %61, 4
%63 = icmp eq i64 %62, 0
br i1 %63, label %64, label %66
64: ; preds = %57
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
br label %66
66: ; preds = %64, %57, %53
br label %67
67: ; preds = %66
%68 = load i32, i32* %7
%69 = add nsw i32 %68, -1
store i32 %69, i32* %7
br label %29
70: ; preds = %29
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%72 = load i64, i64* %3
%73 = sub i64 %72, 1
%74 = trunc i64 %73 to i32
store i32 %74, i32* %7
br label %75
75: ; preds = %96, %70
%76 = load i32, i32* %7
%77 = icmp sge i32 %76, 0
br i1 %77, label %78, label %99
78: ; preds = %75
%79 = load i8*, i8** %5
%80 = getelementptr inbounds i8, i8* %79, i32 1
store i8* %80, i8** %5
%81 = load i8, i8* %79
%82 = zext i8 %81 to i32
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i32 %82)
%84 = load i32, i32* %7
%85 = icmp sgt i32 %84, 0
br i1 %85, label %86, label %95
86: ; preds = %78
%87 = load i64, i64* %3
%88 = load i32, i32* %7
%89 = sext i32 %88 to i64
%90 = sub i64 %87, %89
%91 = urem i64 %90, 4
%92 = icmp eq i64 %91, 0
br i1 %92, label %93, label %95
93: ; preds = %86
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
br label %95
95: ; preds = %93, %86, %78
br label %96
96: ; preds = %95
%97 = load i32, i32* %7
%98 = add nsw i32 %97, -1
store i32 %98, i32* %7
br label %75
99: ; preds = %75
%100 = call i32 @puts(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"DEC:\09%d\0A\00"
@.str.1 = [15 x i8] c"sint DEC:\09%hu\0A\00"
@.str.2 = [15 x i8] c"char DEC:\09%hu\0A\00"
@.str.3 = [9 x i8] c"Binary:\09\00"
@.str.4 = [3 x i8] c"%u\00"
@.str.6 = [3 x i8] c"\0A\09\00"
@.str.7 = [7 x i8] c"\0AHEX:\09\00"
@.str.8 = [6 x i8] c"%02x \00"
@.str.9 = [2 x i8] c"\0A\00"
define void @printVarInFormats(i64 %0, i8* nocapture %1) {
%3 = bitcast i8* %1 to i16*
%4 = load i16, i16* %3
%5 = zext i16 %4 to i32
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = load i16, i16* %3
%8 = zext i16 %7 to i32
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = load i8, i8* %1
%11 = zext i8 %10 to i32
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%14 = trunc i64 %0 to i32
%15 = add i32 %14, -1
%16 = icmp sgt i32 %15, -1
br i1 %16, label %19, label %17
17: ; preds = %2
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
br label %96
19: ; preds = %2
%20 = zext i32 %15 to i64
br label %21
21: ; preds = %70, %19
%22 = phi i64 [ %20, %19 ], [ %71, %70 ]
%23 = getelementptr inbounds i8, i8* %1, i64 %22
%24 = load i8, i8* %23
%25 = lshr i8 %24, 7
%26 = zext i8 %25 to i32
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %26)
%28 = load i8, i8* %23
%29 = lshr i8 %28, 6
%30 = and i8 %29, 1
%31 = zext i8 %30 to i32
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %31)
%33 = load i8, i8* %23
%34 = lshr i8 %33, 5
%35 = and i8 %34, 1
%36 = zext i8 %35 to i32
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %36)
%38 = load i8, i8* %23
%39 = lshr i8 %38, 4
%40 = and i8 %39, 1
%41 = zext i8 %40 to i32
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %41)
%43 = load i8, i8* %23
%44 = lshr i8 %43, 3
%45 = and i8 %44, 1
%46 = zext i8 %45 to i32
%47 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %46)
%48 = load i8, i8* %23
%49 = lshr i8 %48, 2
%50 = and i8 %49, 1
%51 = zext i8 %50 to i32
%52 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %51)
%53 = load i8, i8* %23
%54 = lshr i8 %53, 1
%55 = and i8 %54, 1
%56 = zext i8 %55 to i32
%57 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %56)
%58 = load i8, i8* %23
%59 = and i8 %58, 1
%60 = zext i8 %59 to i32
%61 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %60)
%62 = tail call i32 @putchar(i32 32)
%63 = icmp eq i64 %22, 0
br i1 %63, label %72, label %64
64: ; preds = %21
%65 = sub i64 %0, %22
%66 = and i64 %65, 3
%67 = icmp eq i64 %66, 0
br i1 %67, label %68, label %70
68: ; preds = %64
%69 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
br label %70
70: ; preds = %64, %68
%71 = add nsw i64 %22, -1
br label %21
72: ; preds = %21
%73 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
br i1 %16, label %74, label %96
74: ; preds = %72
%75 = load i8, i8* %1
%76 = zext i8 %75 to i32
%77 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i32 %76)
%78 = icmp eq i32 %15, 0
br i1 %78, label %96, label %79
79: ; preds = %74
%80 = zext i32 %15 to i64
br label %81
81: ; preds = %79, %90
%82 = phi i8* [ %1, %79 ], [ %84, %90 ]
%83 = phi i64 [ %80, %79 ], [ %91, %90 ]
%84 = getelementptr inbounds i8, i8* %82, i64 1
%85 = sub i64 %0, %83
%86 = and i64 %85, 3
%87 = icmp eq i64 %86, 0
br i1 %87, label %88, label %90
88: ; preds = %81
%89 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
br label %90
90: ; preds = %81, %88
%91 = add nsw i64 %83, -1
%92 = load i8, i8* %84
%93 = zext i8 %92 to i32
%94 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i32 %93)
%95 = icmp eq i64 %91, 0
br i1 %95, label %96, label %81
96: ; preds = %90, %74, %17, %72
%97 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
ret void
}