#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*/ ft_putchar_fd_unsigned(int, int);
void ft_putchar_fd(char c, int fd) {
  unsigned short ch;
  ch = 0xff;
  ch &= (unsigned short)(c);
  if (ch < 0x80) {
    ft_putchar_fd_unsigned(ch, fd);
  } else {
    ft_putchar_fd_unsigned(0xC0 | (ch >> 6), fd);
    ft_putchar_fd_unsigned(0x80 | (ch & 0x3F), fd);
  }
}


x86 assembly (clang, -O0):
<ft_putchar_fd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %esi,-0x8(%rbp)
movw   $0xff,-0xa(%rbp)
movsbl -0x1(%rbp),%eax
movzwl %ax,%ecx
movzwl -0xa(%rbp),%eax
and    %ecx,%eax
mov    %ax,-0xa(%rbp)
movzwl -0xa(%rbp),%eax
cmp    $0x80,%eax
jge    1158 <ft_putchar_fd+0x48>
movzwl -0xa(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <ft_putchar_fd_unsigned@plt>
jmp    1182 <ft_putchar_fd+0x72>
movzwl -0xa(%rbp),%edi
sar    $0x6,%edi
or     $0xc0,%edi
mov    -0x8(%rbp),%esi
call   1030 <ft_putchar_fd_unsigned@plt>
movzwl -0xa(%rbp),%edi
and    $0x3f,%edi
or     $0x80,%edi
mov    -0x8(%rbp),%esi
call   1030 <ft_putchar_fd_unsigned@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_putchar_fd>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
movzbl %dil,%ebp
test   %bpl,%bpl
jns    1139 <ft_putchar_fd+0x29>
mov    %ebp,%edi
shr    $0x6,%edi
or     $0xc0,%edi
mov    %ebx,%esi
call   1030 <ft_putchar_fd_unsigned@plt>
and    $0x3f,%ebp
or     $0x80,%ebp
mov    %ebp,%edi
mov    %ebx,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <ft_putchar_fd_unsigned@plt>

LLVM IR (-O0):
define void @ft_putchar_fd(i8 signext %0, i32 %1) {
%3 = alloca i8
%4 = alloca i32
%5 = alloca i16
store i8 %0, i8* %3
store i32 %1, i32* %4
store i16 255, i16* %5
%6 = load i8, i8* %3
%7 = sext i8 %6 to i16
%8 = zext i16 %7 to i32
%9 = load i16, i16* %5
%10 = zext i16 %9 to i32
%11 = and i32 %10, %8
%12 = trunc i32 %11 to i16
store i16 %12, i16* %5
%13 = load i16, i16* %5
%14 = zext i16 %13 to i32
%15 = icmp slt i32 %14, 128
br i1 %15, label %16, label %21
16: ; preds = %2
%17 = load i16, i16* %5
%18 = zext i16 %17 to i32
%19 = load i32, i32* %4
%20 = call i32 @ft_putchar_fd_unsigned(i32 %18, i32 %19)
br label %34
21: ; preds = %2
%22 = load i16, i16* %5
%23 = zext i16 %22 to i32
%24 = ashr i32 %23, 6
%25 = or i32 192, %24
%26 = load i32, i32* %4
%27 = call i32 @ft_putchar_fd_unsigned(i32 %25, i32 %26)
%28 = load i16, i16* %5
%29 = zext i16 %28 to i32
%30 = and i32 %29, 63
%31 = or i32 128, %30
%32 = load i32, i32* %4
%33 = call i32 @ft_putchar_fd_unsigned(i32 %31, i32 %32)
br label %34
34: ; preds = %21, %16
ret void
}

LLVM IR (-O2):
define void @ft_putchar_fd(i8 signext %0, i32 %1) {
%3 = zext i8 %0 to i32
%4 = icmp sgt i8 %0, -1
br i1 %4, label %11, label %5
5: ; preds = %2
%6 = lshr i32 %3, 6
%7 = or i32 %6, 192
%8 = tail call i32 @ft_putchar_fd_unsigned(i32 %7, i32 %1)
%9 = and i32 %3, 63
%10 = or i32 %9, 128
br label %11
11: ; preds = %2, %5
%12 = phi i32 [ %10, %5 ], [ %3, %2 ]
%13 = tail call i32 @ft_putchar_fd_unsigned(i32 %12, i32 %1)
ret void
}