#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*/ putchar(char);
void binaryPrint(int printVar, int byteSize) {
  char i;
  unsigned int mask;
  if (byteSize > 4 || byteSize < 1) {
    printf("error: binaryPrint function does not support given byte size.\n");
  } else {
    if (byteSize == 1) {
      mask = 0x00000080;
    } else if (byteSize == 2) {
      mask = 0x00008000;
    } else if (byteSize == 3) {
      mask = 0x00800000;
    } else {
      mask = 0x80000000;
    }
    for (i = 0; i < (byteSize * 8); i++) {
      if (0 != (printVar & mask)) {
        putchar('1');
      } else {
        putchar('0');
      }
      mask = mask >> 1;
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<binaryPrint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x4,-0x8(%rbp)
jg     1142 <binaryPrint+0x22>
cmpl   $0x1,-0x8(%rbp)
jge    1153 <binaryPrint+0x33>
lea    0xeb7(%rip),%rdi
call   1040 <printf@plt>
jmp    1207 <binaryPrint+0xe7>
cmpl   $0x1,-0x8(%rbp)
jne    1169 <binaryPrint+0x49>
movl   $0x80,-0x10(%rbp)
jmp    11a6 <binaryPrint+0x86>
cmpl   $0x2,-0x8(%rbp)
jne    117f <binaryPrint+0x5f>
movl   $0x8000,-0x10(%rbp)
jmp    11a1 <binaryPrint+0x81>
cmpl   $0x3,-0x8(%rbp)
jne    1195 <binaryPrint+0x75>
movl   $0x800000,-0x10(%rbp)
jmp    119c <binaryPrint+0x7c>
movl   $0x80000000,-0x10(%rbp)
jmp    11a1 <binaryPrint+0x81>
jmp    11a6 <binaryPrint+0x86>
movb   $0x0,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
mov    -0x8(%rbp),%ecx
shl    $0x3,%ecx
cmp    %ecx,%eax
jge    11fb <binaryPrint+0xdb>
mov    -0x4(%rbp),%ecx
and    -0x10(%rbp),%ecx
xor    %eax,%eax
cmp    %ecx,%eax
je     11db <binaryPrint+0xbb>
mov    $0x31,%edi
call   1030 <putchar@plt>
jmp    11e5 <binaryPrint+0xc5>
mov    $0x30,%edi
call   1030 <putchar@plt>
mov    -0x10(%rbp),%eax
shr    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x9(%rbp),%al
add    $0x1,%al
mov    %al,-0x9(%rbp)
jmp    11aa <binaryPrint+0x8a>
lea    0xe3b(%rip),%rdi
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<binaryPrint>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r15d
lea    -0x5(%r15),%eax
cmp    $0xfffffffb,%eax
ja     1149 <binaryPrint+0x29>
lea    0xec6(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>
mov    %edi,%r14d
lea    -0x1(%r15),%eax
mov    $0x80000000,%ebp
cmp    $0x2,%eax
ja     1166 <binaryPrint+0x46>
cltq
lea    0xedd(%rip),%rcx
mov    (%rcx,%rax,4),%ebp
shl    $0x3,%r15d
mov    $0x1,%bl
nopl   0x0(%rax)
mov    %ebp,%eax
and    %r14d,%eax
cmp    $0x1,%eax
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <putchar@plt>
shr    %ebp
movsbl %bl,%eax
lea    0x1(%rax),%ebx
cmp    %eax,%r15d
jg     1170 <binaryPrint+0x50>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [63 x i8] c"error: binaryPrint function does not support given byte size.\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
define void @binaryPrint(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
%8 = icmp sgt i32 %7, 4
br i1 %8, label %12, label %9
9: ; preds = %2
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 1
br i1 %11, label %12, label %14
12: ; preds = %9, %2
%13 = call i32 @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str, i64 0, i64 0))
br label %53
14: ; preds = %9
%15 = load i32, i32* %4
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %18
17: ; preds = %14
store i32 128, i32* %6
br label %29
18: ; preds = %14
%19 = load i32, i32* %4
%20 = icmp eq i32 %19, 2
br i1 %20, label %21, label %22
21: ; preds = %18
store i32 32768, i32* %6
br label %28
22: ; preds = %18
%23 = load i32, i32* %4
%24 = icmp eq i32 %23, 3
br i1 %24, label %25, label %26
25: ; preds = %22
store i32 8388608, i32* %6
br label %27
26: ; preds = %22
store i32 -2147483648, i32* %6
br label %27
27: ; preds = %26, %25
br label %28
28: ; preds = %27, %21
br label %29
29: ; preds = %28, %17
store i8 0, i8* %5
br label %30
30: ; preds = %48, %29
%31 = load i8, i8* %5
%32 = sext i8 %31 to i32
%33 = load i32, i32* %4
%34 = mul nsw i32 %33, 8
%35 = icmp slt i32 %32, %34
br i1 %35, label %36, label %51
36: ; preds = %30
%37 = load i32, i32* %3
%38 = load i32, i32* %6
%39 = and i32 %37, %38
%40 = icmp ne i32 0, %39
br i1 %40, label %41, label %43
41: ; preds = %36
%42 = call i32 @putchar(i8 signext 49)
br label %45
43: ; preds = %36
%44 = call i32 @putchar(i8 signext 48)
br label %45
45: ; preds = %43, %41
%46 = load i32, i32* %6
%47 = lshr i32 %46, 1
store i32 %47, i32* %6
br label %48
48: ; preds = %45
%49 = load i8, i8* %5
%50 = add i8 %49, 1
store i8 %50, i8* %5
br label %30
51: ; preds = %30
%52 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %53
53: ; preds = %51, %12
ret void
}

LLVM IR (-O2):
@str = [62 x i8] c"error: binaryPrint function does not support given byte size.\00"
@switch.table.binaryPrint = [3 x i32] [i32 128, i32 32768, i32 8388608]
define void @binaryPrint(i32 %0, i32 %1) {
%3 = add i32 %1, -5
%4 = icmp ult i32 %3, -4
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @str, i64 0, i64 0))
br label %30
7: ; preds = %2
%8 = add i32 %1, -1
%9 = icmp ult i32 %8, 3
br i1 %9, label %10, label %14
10: ; preds = %7
%11 = sext i32 %8 to i64
%12 = getelementptr inbounds [3 x i32], [3 x i32]* @switch.table.binaryPrint, i64 0, i64 %11
%13 = load i32, i32* %12
br label %14
14: ; preds = %7, %10
%15 = phi i32 [ %13, %10 ], [ -2147483648, %7 ]
%16 = shl nuw nsw i32 %1, 3
br label %17
17: ; preds = %14, %17
%18 = phi i32 [ %24, %17 ], [ %15, %14 ]
%19 = phi i8 [ %25, %17 ], [ 0, %14 ]
%20 = and i32 %18, %0
%21 = icmp eq i32 %20, 0
%22 = select i1 %21, i8 48, i8 49
%23 = tail call i32 @putchar(i8 signext %22)
%24 = lshr i32 %18, 1
%25 = add i8 %19, 1
%26 = sext i8 %25 to i32
%27 = icmp sgt i32 %16, %26
br i1 %27, label %17, label %28
28: ; preds = %17
%29 = tail call i32 bitcast (i32 (i8)* @putchar to i32 (i32)*)(i32 10)
br label %30
30: ; preds = %28, %5
ret void
}