#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*/ UART_put(char *);
void UART_putbin(unsigned char num) {
  unsigned char c[9];
  unsigned char waarde = 128;
  unsigned int i = 0;
  while (i < 8) {
    if (num >= waarde) {
      num = num - waarde;
      c[i] = '1';
    } else
      c[i] = '0';
    waarde >>= 1;
    i++;
  }
  c[8] = '\0';
  UART_put((char *)c);
}


x86 assembly (clang, -O0):
<UART_putbin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movb   $0x80,-0xb(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x8,-0x10(%rbp)
jae    117d <UART_putbin+0x6d>
movzbl -0x1(%rbp),%eax
movzbl -0xb(%rbp),%ecx
cmp    %ecx,%eax
jl     115d <UART_putbin+0x4d>
movzbl -0x1(%rbp),%eax
movzbl -0xb(%rbp),%ecx
sub    %ecx,%eax
mov    %al,-0x1(%rbp)
mov    -0x10(%rbp),%eax
movb   $0x31,-0xa(%rbp,%rax,1)
jmp    1165 <UART_putbin+0x55>
mov    -0x10(%rbp),%eax
movb   $0x30,-0xa(%rbp,%rax,1)
movzbl -0xb(%rbp),%eax
sar    $0x1,%eax
mov    %al,-0xb(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1129 <UART_putbin+0x19>
movb   $0x0,-0x2(%rbp)
lea    -0xa(%rbp),%rdi
call   1030 <UART_put@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<UART_putbin>:
sub    $0x18,%rsp
mov    %edi,%eax
and    $0x7f,%al
shr    $0x7,%dil
or     $0x30,%dil
mov    %dil,0xf(%rsp)
movzbl %al,%ecx
sub    $0x40,%al
movzbl %al,%edx
cmovb  %ecx,%edx
mov    $0x31,%al
mov    $0x31,%cl
sbb    $0x0,%cl
mov    %cl,0x10(%rsp)
mov    %edx,%ecx
sub    $0x20,%cl
movzbl %cl,%ecx
cmovb  %edx,%ecx
mov    $0x31,%dl
sbb    $0x0,%dl
mov    %dl,0x11(%rsp)
mov    %ecx,%edx
sub    $0x10,%dl
movzbl %dl,%edx
cmovb  %ecx,%edx
mov    $0x31,%cl
sbb    $0x0,%cl
mov    %cl,0x12(%rsp)
mov    %edx,%ecx
sub    $0x8,%cl
movzbl %cl,%ecx
cmovb  %edx,%ecx
mov    $0x31,%dl
sbb    $0x0,%dl
mov    %dl,0x13(%rsp)
mov    %ecx,%edx
sub    $0x4,%dl
movzbl %dl,%edx
cmovb  %ecx,%edx
mov    $0x31,%cl
sbb    $0x0,%cl
mov    %cl,0x14(%rsp)
mov    %edx,%ecx
sub    $0x2,%cl
movzbl %cl,%ecx
cmovb  %edx,%ecx
mov    $0x31,%dl
sbb    $0x0,%dl
mov    %dl,0x15(%rsp)
cmp    $0x1,%cl
sbb    $0x0,%al
mov    %al,0x16(%rsp)
movb   $0x0,0x17(%rsp)
lea    0xf(%rsp),%rdi
call   1030 <UART_put@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
define void @UART_putbin(i8 zeroext %0) {
%2 = alloca i8
%3 = alloca [9 x i8]
%4 = alloca i8
%5 = alloca i32
store i8 %0, i8* %2
store i8 -128, i8* %4
store i32 0, i32* %5
br label %6
6: ; preds = %29, %1
%7 = load i32, i32* %5
%8 = icmp ult i32 %7, 8
br i1 %8, label %9, label %36
9: ; preds = %6
%10 = load i8, i8* %2
%11 = zext i8 %10 to i32
%12 = load i8, i8* %4
%13 = zext i8 %12 to i32
%14 = icmp sge i32 %11, %13
br i1 %14, label %15, label %25
15: ; preds = %9
%16 = load i8, i8* %2
%17 = zext i8 %16 to i32
%18 = load i8, i8* %4
%19 = zext i8 %18 to i32
%20 = sub nsw i32 %17, %19
%21 = trunc i32 %20 to i8
store i8 %21, i8* %2
%22 = load i32, i32* %5
%23 = zext i32 %22 to i64
%24 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 %23
store i8 49, i8* %24
br label %29
25: ; preds = %9
%26 = load i32, i32* %5
%27 = zext i32 %26 to i64
%28 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 %27
store i8 48, i8* %28
br label %29
29: ; preds = %25, %15
%30 = load i8, i8* %4
%31 = zext i8 %30 to i32
%32 = ashr i32 %31, 1
%33 = trunc i32 %32 to i8
store i8 %33, i8* %4
%34 = load i32, i32* %5
%35 = add i32 %34, 1
store i32 %35, i32* %5
br label %6
36: ; preds = %6
%37 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 8
store i8 0, i8* %37
%38 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 0
%39 = call i32 @UART_put(i8* %38)
ret void
}

LLVM IR (-O2):
define void @UART_putbin(i8 zeroext %0) {
%2 = alloca [9 x i8]
%3 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
%4 = icmp sgt i8 %0, -1
%5 = and i8 %0, 127
%6 = select i1 %4, i8 48, i8 49
store i8 %6, i8* %3
%7 = icmp ult i8 %5, 64
%8 = add nsw i8 %5, -64
%9 = select i1 %7, i8 %5, i8 %8
%10 = select i1 %7, i8 48, i8 49
%11 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 1
store i8 %10, i8* %11
%12 = icmp ult i8 %9, 32
%13 = add i8 %9, -32
%14 = select i1 %12, i8 %9, i8 %13
%15 = select i1 %12, i8 48, i8 49
%16 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 2
store i8 %15, i8* %16
%17 = icmp ult i8 %14, 16
%18 = add i8 %14, -16
%19 = select i1 %17, i8 %14, i8 %18
%20 = select i1 %17, i8 48, i8 49
%21 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 3
store i8 %20, i8* %21
%22 = icmp ult i8 %19, 8
%23 = add i8 %19, -8
%24 = select i1 %22, i8 %19, i8 %23
%25 = select i1 %22, i8 48, i8 49
%26 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 4
store i8 %25, i8* %26
%27 = icmp ult i8 %24, 4
%28 = add i8 %24, -4
%29 = select i1 %27, i8 %24, i8 %28
%30 = select i1 %27, i8 48, i8 49
%31 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 5
store i8 %30, i8* %31
%32 = icmp ult i8 %29, 2
%33 = add i8 %29, -2
%34 = select i1 %32, i8 %29, i8 %33
%35 = select i1 %32, i8 48, i8 49
%36 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 6
store i8 %35, i8* %36
%37 = icmp eq i8 %34, 0
%38 = select i1 %37, i8 48, i8 49
%39 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 7
store i8 %38, i8* %39
%40 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 8
store i8 0, i8* %40
%41 = call i32 @UART_put(i8* %3)
ret void
}