#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 */
typedef int wchar_t;

/* Variables and functions */
int /*<<< orphan*/ ft_putchar_fd(int, int);
void ft_putwchar_fd(wchar_t chr, int fd) {
  if (chr <= 0x7F)
    ft_putchar_fd(chr, fd);
  else if (chr <= 0x7FF) {
    ft_putchar_fd((chr >> 6) + 0xC0, fd);
    ft_putchar_fd((chr & 0x3F) + 0x80, fd);
  } else if (chr <= 0xFFFF) {
    ft_putchar_fd((chr >> 12) + 0xE0, fd);
    ft_putchar_fd(((chr >> 6) & 0x3F) + 0x80, fd);
    ft_putchar_fd((chr & 0x3F) + 0x80, fd);
  } else if (chr <= 0x10FFFF) {
    ft_putchar_fd((chr >> 18) + 0xF0, fd);
    ft_putchar_fd(((chr >> 12) & 0x3F) + 0x80, fd);
    ft_putchar_fd(((chr >> 6) & 0x3F) + 0x80, fd);
    ft_putchar_fd((chr & 0x3F) + 0x80, fd);
  }
}


x86 assembly (clang, -O0):
<ft_putwchar_fd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x7f,-0x4(%rbp)
jg     1138 <ft_putwchar_fd+0x28>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <ft_putchar_fd@plt>
jmp    1235 <ft_putwchar_fd+0x125>
cmpl   $0x7ff,-0x4(%rbp)
jg     1172 <ft_putwchar_fd+0x62>
mov    -0x4(%rbp),%edi
sar    $0x6,%edi
add    $0xc0,%edi
mov    -0x8(%rbp),%esi
call   1030 <ft_putchar_fd@plt>
mov    -0x4(%rbp),%edi
and    $0x3f,%edi
add    $0x80,%edi
mov    -0x8(%rbp),%esi
call   1030 <ft_putchar_fd@plt>
jmp    1230 <ft_putwchar_fd+0x120>
cmpl   $0xffff,-0x4(%rbp)
jg     11c3 <ft_putwchar_fd+0xb3>
mov    -0x4(%rbp),%edi
sar    $0xc,%edi
add    $0xe0,%edi
mov    -0x8(%rbp),%esi
call   1030 <ft_putchar_fd@plt>
mov    -0x4(%rbp),%edi
sar    $0x6,%edi
and    $0x3f,%edi
add    $0x80,%edi
mov    -0x8(%rbp),%esi
call   1030 <ft_putchar_fd@plt>
mov    -0x4(%rbp),%edi
and    $0x3f,%edi
add    $0x80,%edi
mov    -0x8(%rbp),%esi
call   1030 <ft_putchar_fd@plt>
jmp    122b <ft_putwchar_fd+0x11b>
cmpl   $0x10ffff,-0x4(%rbp)
jg     1226 <ft_putwchar_fd+0x116>
mov    -0x4(%rbp),%edi
sar    $0x12,%edi
add    $0xf0,%edi
mov    -0x8(%rbp),%esi
call   1030 <ft_putchar_fd@plt>
mov    -0x4(%rbp),%edi
sar    $0xc,%edi
and    $0x3f,%edi
add    $0x80,%edi
mov    -0x8(%rbp),%esi
call   1030 <ft_putchar_fd@plt>
mov    -0x4(%rbp),%edi
sar    $0x6,%edi
and    $0x3f,%edi
add    $0x80,%edi
mov    -0x8(%rbp),%esi
call   1030 <ft_putchar_fd@plt>
mov    -0x4(%rbp),%edi
and    $0x3f,%edi
add    $0x80,%edi
mov    -0x8(%rbp),%esi
call   1030 <ft_putchar_fd@plt>
jmp    122b <ft_putwchar_fd+0x11b>
jmp    1230 <ft_putwchar_fd+0x120>
jmp    1235 <ft_putwchar_fd+0x125>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_putwchar_fd>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
cmp    $0x80,%edi
jl     1196 <ft_putwchar_fd+0x86>
cmp    $0x7ff,%ebp
ja     1134 <ft_putwchar_fd+0x24>
mov    %ebp,%edi
shr    $0x6,%edi
add    $0xc0,%edi
jmp    1186 <ft_putwchar_fd+0x76>
cmp    $0xffff,%ebp
ja     1149 <ft_putwchar_fd+0x39>
mov    %ebp,%edi
shr    $0xc,%edi
add    $0xe0,%edi
jmp    1171 <ft_putwchar_fd+0x61>
cmp    $0x10ffff,%ebp
ja     11a5 <ft_putwchar_fd+0x95>
mov    %ebp,%edi
shr    $0x12,%edi
add    $0xf0,%edi
mov    %ebx,%esi
call   1030 <ft_putchar_fd@plt>
mov    %ebp,%edi
shr    $0xc,%edi
and    $0x3f,%edi
or     $0x80,%edi
mov    %ebx,%esi
call   1030 <ft_putchar_fd@plt>
mov    %ebp,%edi
shr    $0x6,%edi
and    $0x3f,%edi
or     $0x80,%edi
mov    %ebx,%esi
call   1030 <ft_putchar_fd@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@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @ft_putwchar_fd(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %3
%6 = icmp sle i32 %5, 127
br i1 %6, label %7, label %11
7: ; preds = %2
%8 = load i32, i32* %3
%9 = load i32, i32* %4
%10 = call i32 @ft_putchar_fd(i32 %8, i32 %9)
br label %74
11: ; preds = %2
%12 = load i32, i32* %3
%13 = icmp sle i32 %12, 2047
br i1 %13, label %14, label %25
14: ; preds = %11
%15 = load i32, i32* %3
%16 = ashr i32 %15, 6
%17 = add nsw i32 %16, 192
%18 = load i32, i32* %4
%19 = call i32 @ft_putchar_fd(i32 %17, i32 %18)
%20 = load i32, i32* %3
%21 = and i32 %20, 63
%22 = add nsw i32 %21, 128
%23 = load i32, i32* %4
%24 = call i32 @ft_putchar_fd(i32 %22, i32 %23)
br label %73
25: ; preds = %11
%26 = load i32, i32* %3
%27 = icmp sle i32 %26, 65535
br i1 %27, label %28, label %45
28: ; preds = %25
%29 = load i32, i32* %3
%30 = ashr i32 %29, 12
%31 = add nsw i32 %30, 224
%32 = load i32, i32* %4
%33 = call i32 @ft_putchar_fd(i32 %31, i32 %32)
%34 = load i32, i32* %3
%35 = ashr i32 %34, 6
%36 = and i32 %35, 63
%37 = add nsw i32 %36, 128
%38 = load i32, i32* %4
%39 = call i32 @ft_putchar_fd(i32 %37, i32 %38)
%40 = load i32, i32* %3
%41 = and i32 %40, 63
%42 = add nsw i32 %41, 128
%43 = load i32, i32* %4
%44 = call i32 @ft_putchar_fd(i32 %42, i32 %43)
br label %72
45: ; preds = %25
%46 = load i32, i32* %3
%47 = icmp sle i32 %46, 1114111
br i1 %47, label %48, label %71
48: ; preds = %45
%49 = load i32, i32* %3
%50 = ashr i32 %49, 18
%51 = add nsw i32 %50, 240
%52 = load i32, i32* %4
%53 = call i32 @ft_putchar_fd(i32 %51, i32 %52)
%54 = load i32, i32* %3
%55 = ashr i32 %54, 12
%56 = and i32 %55, 63
%57 = add nsw i32 %56, 128
%58 = load i32, i32* %4
%59 = call i32 @ft_putchar_fd(i32 %57, i32 %58)
%60 = load i32, i32* %3
%61 = ashr i32 %60, 6
%62 = and i32 %61, 63
%63 = add nsw i32 %62, 128
%64 = load i32, i32* %4
%65 = call i32 @ft_putchar_fd(i32 %63, i32 %64)
%66 = load i32, i32* %3
%67 = and i32 %66, 63
%68 = add nsw i32 %67, 128
%69 = load i32, i32* %4
%70 = call i32 @ft_putchar_fd(i32 %68, i32 %69)
br label %71
71: ; preds = %48, %45
br label %72
72: ; preds = %71, %28
br label %73
73: ; preds = %72, %14
br label %74
74: ; preds = %73, %7
ret void
}

LLVM IR (-O2):
define void @ft_putwchar_fd(i32 %0, i32 %1) {
%3 = icmp slt i32 %0, 128
br i1 %3, label %36, label %4
4: ; preds = %2
%5 = icmp ult i32 %0, 2048
br i1 %5, label %6, label %9
6: ; preds = %4
%7 = lshr i32 %0, 6
%8 = add nuw nsw i32 %7, 192
br label %31
9: ; preds = %4
%10 = icmp ult i32 %0, 65536
br i1 %10, label %11, label %18
11: ; preds = %9
%12 = lshr i32 %0, 12
%13 = add nuw nsw i32 %12, 224
%14 = tail call i32 @ft_putchar_fd(i32 %13, i32 %1)
%15 = lshr i32 %0, 6
%16 = and i32 %15, 63
%17 = or i32 %16, 128
br label %31
18: ; preds = %9
%19 = icmp ult i32 %0, 1114112
br i1 %19, label %20, label %39
20: ; preds = %18
%21 = lshr i32 %0, 18
%22 = add nuw nsw i32 %21, 240
%23 = tail call i32 @ft_putchar_fd(i32 %22, i32 %1)
%24 = lshr i32 %0, 12
%25 = and i32 %24, 63
%26 = or i32 %25, 128
%27 = tail call i32 @ft_putchar_fd(i32 %26, i32 %1)
%28 = lshr i32 %0, 6
%29 = and i32 %28, 63
%30 = or i32 %29, 128
br label %31
31: ; preds = %6, %20, %11
%32 = phi i32 [ %17, %11 ], [ %30, %20 ], [ %8, %6 ]
%33 = tail call i32 @ft_putchar_fd(i32 %32, i32 %1)
%34 = and i32 %0, 63
%35 = or i32 %34, 128
br label %36
36: ; preds = %31, %2
%37 = phi i32 [ %0, %2 ], [ %35, %31 ]
%38 = tail call i32 @ft_putchar_fd(i32 %37, i32 %1)
br label %39
39: ; preds = %36, %18
ret void
}