#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_printwchar_norm(int, unsigned char);
int /*<<< orphan*/ write(int, ...);
void ft_printwchar(wchar_t c) {
  unsigned char bit;
  bit = '\0';
  if (c < 128) {
    write(1, &c, 1);
  } else if (c < 2048) {
    bit = (c >> 6) | 192;
    write(1, &bit, 1);
    bit = 128 | (c & 63);
    write(1, &bit, 1);
  } else if (c < 65536) {
    bit = 224 | (c >> 12 & 15);
    write(1, &bit, 1);
    bit = (128 | (c >> 6 & 63));
    write(1, &bit, 1);
    bit = (128 | (c & 63));
    write(1, &bit, 1);
  } else if (c < 1114112)
    ft_printwchar_norm(c, bit);
}


x86 assembly (clang, -O0):
<ft_printwchar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movb   $0x0,-0x5(%rbp)
cmpl   $0x80,-0x4(%rbp)
jge    1153 <ft_printwchar+0x33>
mov    $0x1,%edx
lea    -0x4(%rbp),%rsi
mov    %edx,%edi
mov    $0x0,%al
call   1030 <write@plt>
jmp    1245 <ft_printwchar+0x125>
cmpl   $0x800,-0x4(%rbp)
jge    11a5 <ft_printwchar+0x85>
mov    -0x4(%rbp),%eax
sar    $0x6,%eax
or     $0xc0,%eax
mov    %al,-0x5(%rbp)
mov    $0x1,%edx
lea    -0x5(%rbp),%rsi
mov    %edx,%edi
mov    $0x0,%al
call   1030 <write@plt>
mov    -0x4(%rbp),%eax
and    $0x3f,%eax
or     $0x80,%eax
mov    %al,-0x5(%rbp)
mov    $0x1,%edx
lea    -0x5(%rbp),%rsi
mov    %edx,%edi
mov    $0x0,%al
call   1030 <write@plt>
jmp    1240 <ft_printwchar+0x120>
cmpl   $0x10000,-0x4(%rbp)
jge    121d <ft_printwchar+0xfd>
mov    -0x4(%rbp),%eax
sar    $0xc,%eax
and    $0xf,%eax
or     $0xe0,%eax
mov    %al,-0x5(%rbp)
mov    $0x1,%edx
lea    -0x5(%rbp),%rsi
mov    %edx,%edi
mov    $0x0,%al
call   1030 <write@plt>
mov    -0x4(%rbp),%eax
sar    $0x6,%eax
and    $0x3f,%eax
or     $0x80,%eax
mov    %al,-0x5(%rbp)
mov    $0x1,%edx
lea    -0x5(%rbp),%rsi
mov    %edx,%edi
mov    $0x0,%al
call   1030 <write@plt>
mov    -0x4(%rbp),%eax
and    $0x3f,%eax
or     $0x80,%eax
mov    %al,-0x5(%rbp)
mov    $0x1,%edx
lea    -0x5(%rbp),%rsi
mov    %edx,%edi
mov    $0x0,%al
call   1030 <write@plt>
jmp    123b <ft_printwchar+0x11b>
cmpl   $0x110000,-0x4(%rbp)
jge    1236 <ft_printwchar+0x116>
mov    -0x4(%rbp),%edi
movzbl -0x5(%rbp),%esi
call   1040 <ft_printwchar_norm@plt>
jmp    123b <ft_printwchar+0x11b>
jmp    1240 <ft_printwchar+0x120>
jmp    1245 <ft_printwchar+0x125>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_printwchar>:
push   %r14
push   %rbx
push   %rax
mov    %edi,0x4(%rsp)
cmp    $0x7f,%edi
jg     1139 <ft_printwchar+0x19>
lea    0x4(%rsp),%rsi
mov    $0x1,%edi
jmp    11b4 <ft_printwchar+0x94>
mov    %edi,%ebx
cmp    $0x7ff,%edi
ja     1155 <ft_printwchar+0x35>
mov    %ebx,%eax
shr    $0x6,%eax
or     $0xc0,%al
mov    %al,0x3(%rsp)
lea    0x3(%rsp),%r14
jmp    118e <ft_printwchar+0x6e>
cmp    $0xffff,%ebx
ja     11c8 <ft_printwchar+0xa8>
mov    %ebx,%eax
shr    $0xc,%eax
or     $0xe0,%al
mov    %al,0x3(%rsp)
lea    0x3(%rsp),%r14
mov    $0x1,%edi
mov    %r14,%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <write@plt>
mov    %ebx,%eax
shr    $0x6,%eax
and    $0x3f,%al
or     $0x80,%al
mov    %al,0x3(%rsp)
mov    $0x1,%edi
mov    %r14,%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <write@plt>
and    $0x3f,%bl
or     $0x80,%bl
mov    %bl,0x3(%rsp)
mov    $0x1,%edi
mov    %r14,%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <write@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
cmp    $0x10ffff,%ebx
ja     11c0 <ft_printwchar+0xa0>
mov    %ebx,%edi
xor    %esi,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <ft_printwchar_norm@plt>

LLVM IR (-O0):
define void @ft_printwchar(i32 %0) {
%2 = alloca i32
%3 = alloca i8
store i32 %0, i32* %2
store i8 0, i8* %3
%4 = load i32, i32* %2
%5 = icmp slt i32 %4, 128
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = call i32 (i32, ...) @write(i32 1, i32* %2, i32 1)
br label %53
8: ; preds = %1
%9 = load i32, i32* %2
%10 = icmp slt i32 %9, 2048
br i1 %10, label %11, label %22
11: ; preds = %8
%12 = load i32, i32* %2
%13 = ashr i32 %12, 6
%14 = or i32 %13, 192
%15 = trunc i32 %14 to i8
store i8 %15, i8* %3
%16 = call i32 (i32, ...) @write(i32 1, i8* %3, i32 1)
%17 = load i32, i32* %2
%18 = and i32 %17, 63
%19 = or i32 128, %18
%20 = trunc i32 %19 to i8
store i8 %20, i8* %3
%21 = call i32 (i32, ...) @write(i32 1, i8* %3, i32 1)
br label %52
22: ; preds = %8
%23 = load i32, i32* %2
%24 = icmp slt i32 %23, 65536
br i1 %24, label %25, label %43
25: ; preds = %22
%26 = load i32, i32* %2
%27 = ashr i32 %26, 12
%28 = and i32 %27, 15
%29 = or i32 224, %28
%30 = trunc i32 %29 to i8
store i8 %30, i8* %3
%31 = call i32 (i32, ...) @write(i32 1, i8* %3, i32 1)
%32 = load i32, i32* %2
%33 = ashr i32 %32, 6
%34 = and i32 %33, 63
%35 = or i32 128, %34
%36 = trunc i32 %35 to i8
store i8 %36, i8* %3
%37 = call i32 (i32, ...) @write(i32 1, i8* %3, i32 1)
%38 = load i32, i32* %2
%39 = and i32 %38, 63
%40 = or i32 128, %39
%41 = trunc i32 %40 to i8
store i8 %41, i8* %3
%42 = call i32 (i32, ...) @write(i32 1, i8* %3, i32 1)
br label %51
43: ; preds = %22
%44 = load i32, i32* %2
%45 = icmp slt i32 %44, 1114112
br i1 %45, label %46, label %50
46: ; preds = %43
%47 = load i32, i32* %2
%48 = load i8, i8* %3
%49 = call i32 @ft_printwchar_norm(i32 %47, i8 zeroext %48)
br label %50
50: ; preds = %46, %43
br label %51
51: ; preds = %50, %25
br label %52
52: ; preds = %51, %11
br label %53
53: ; preds = %52, %6
ret void
}

LLVM IR (-O2):
define void @ft_printwchar(i32 %0) {
%2 = alloca i32
%3 = alloca i8
store i32 %0, i32* %2
%4 = icmp slt i32 %0, 128
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = call i32 (i32, ...) @write(i32 1, i32* %2, i32 1)
br label %38
7: ; preds = %1
%8 = icmp ult i32 %0, 2048
br i1 %8, label %9, label %18
9: ; preds = %7
%10 = lshr i32 %0, 6
%11 = trunc i32 %10 to i8
%12 = or i8 %11, -64
store i8 %12, i8* %3
%13 = call i32 (i32, ...) @write(i32 1, i8* %3, i32 1)
%14 = trunc i32 %0 to i8
%15 = and i8 %14, 63
%16 = or i8 %15, -128
store i8 %16, i8* %3
%17 = call i32 (i32, ...) @write(i32 1, i8* %3, i32 1)
br label %38
18: ; preds = %7
%19 = icmp ult i32 %0, 65536
br i1 %19, label %20, label %34
20: ; preds = %18
%21 = lshr i32 %0, 12
%22 = trunc i32 %21 to i8
%23 = or i8 %22, -32
store i8 %23, i8* %3
%24 = call i32 (i32, ...) @write(i32 1, i8* %3, i32 1)
%25 = lshr i32 %0, 6
%26 = trunc i32 %25 to i8
%27 = and i8 %26, 63
%28 = or i8 %27, -128
store i8 %28, i8* %3
%29 = call i32 (i32, ...) @write(i32 1, i8* %3, i32 1)
%30 = trunc i32 %0 to i8
%31 = and i8 %30, 63
%32 = or i8 %31, -128
store i8 %32, i8* %3
%33 = call i32 (i32, ...) @write(i32 1, i8* %3, i32 1)
br label %38
34: ; preds = %18
%35 = icmp ult i32 %0, 1114112
br i1 %35, label %36, label %38
36: ; preds = %34
%37 = tail call i32 @ft_printwchar_norm(i32 %0, i8 zeroext 0)
br label %38
38: ; preds = %9, %34, %36, %20, %5
ret void
}