#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*/ write(int, int *, int);
void ft_putchar(int c) {
  int result;
  if (c < 0x80)
    write(1, &c, 1);
  else if (c < 0x800) {
    result = ((c >> 6) | 0xC0) + (((c & 0x3F) | 0x80) << 8);
    write(1, &result, 2);
  } else if (c < 0x10000) {
    result = ((c >> 12) | 0xE0) + ((((c >> 6) & 0x3F) | 0x80) << 8);
    result += ((c & 0x3F) | 0x80) << 16;
    write(1, &result, 3);
  } else if (c < 0x110000) {
    result = ((c >> 18) | 0xF0) + ((((c >> 12) & 0x3F) | 0x80) << 8);
    result += (((c >> 6) & 0x3F) | 0x80) << 16;
    result += ((c & 0x3F) | 0x80) << 24;
    write(1, &result, 4);
  }
  return;
}


x86 assembly (clang, -O0):
<ft_putchar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x80,-0x4(%rbp)
jge    113d <ft_putchar+0x2d>
mov    $0x1,%edx
lea    -0x4(%rbp),%rsi
mov    %edx,%edi
call   1030 <write@plt>
jmp    1258 <ft_putchar+0x148>
cmpl   $0x800,-0x4(%rbp)
jge    1181 <ft_putchar+0x71>
mov    -0x4(%rbp),%eax
sar    $0x6,%eax
or     $0xc0,%eax
mov    -0x4(%rbp),%ecx
and    $0x3f,%ecx
or     $0x80,%ecx
shl    $0x8,%ecx
add    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    $0x1,%edi
lea    -0x8(%rbp),%rsi
mov    $0x2,%edx
call   1030 <write@plt>
jmp    1253 <ft_putchar+0x143>
cmpl   $0x10000,-0x4(%rbp)
jge    11dc <ft_putchar+0xcc>
mov    -0x4(%rbp),%eax
sar    $0xc,%eax
or     $0xe0,%eax
mov    -0x4(%rbp),%ecx
sar    $0x6,%ecx
and    $0x3f,%ecx
or     $0x80,%ecx
shl    $0x8,%ecx
add    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x3f,%eax
or     $0x80,%eax
shl    $0x10,%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    $0x1,%edi
lea    -0x8(%rbp),%rsi
mov    $0x3,%edx
call   1030 <write@plt>
jmp    124e <ft_putchar+0x13e>
cmpl   $0x110000,-0x4(%rbp)
jge    1249 <ft_putchar+0x139>
mov    -0x4(%rbp),%eax
sar    $0x12,%eax
or     $0xf0,%eax
mov    -0x4(%rbp),%ecx
sar    $0xc,%ecx
and    $0x3f,%ecx
or     $0x80,%ecx
shl    $0x8,%ecx
add    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x6,%eax
and    $0x3f,%eax
or     $0x80,%eax
shl    $0x10,%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x3f,%eax
or     $0x80,%eax
shl    $0x18,%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    $0x1,%edi
lea    -0x8(%rbp),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
jmp    124e <ft_putchar+0x13e>
jmp    1253 <ft_putchar+0x143>
jmp    1258 <ft_putchar+0x148>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_putchar>:
push   %rax
mov    %edi,0x4(%rsp)
cmp    $0x7f,%edi
jg     112e <ft_putchar+0x1e>
lea    0x4(%rsp),%rsi
mov    $0x1,%edi
mov    $0x1,%edx
jmp    11e6 <ft_putchar+0xd6>
cmp    $0x7ff,%edi
ja     1162 <ft_putchar+0x52>
mov    %edi,%eax
shr    $0x6,%eax
or     $0xc0,%eax
and    $0x3f,%edi
shl    $0x8,%edi
add    %edi,%eax
add    $0x8000,%eax
mov    %eax,(%rsp)
mov    %rsp,%rsi
mov    $0x1,%edi
mov    $0x2,%edx
jmp    11e6 <ft_putchar+0xd6>
cmp    $0xffff,%edi
ja     119e <ft_putchar+0x8e>
mov    %edi,%eax
shr    $0xc,%eax
or     $0xe0,%eax
mov    %edi,%ecx
and    $0xfc0,%ecx
and    $0x3f,%edi
shl    $0x10,%edi
lea    (%rdi,%rcx,4),%ecx
add    %ecx,%eax
add    $0x808000,%eax
mov    %eax,(%rsp)
mov    %rsp,%rsi
mov    $0x1,%edi
mov    $0x3,%edx
jmp    11e6 <ft_putchar+0xd6>
cmp    $0x10ffff,%edi
ja     11eb <ft_putchar+0xdb>
mov    %edi,%eax
shr    $0x12,%eax
or     $0xf0,%eax
mov    %edi,%ecx
shr    $0x4,%ecx
and    $0x3f00,%ecx
add    %eax,%ecx
mov    %edi,%eax
shl    $0xa,%eax
and    $0x3f0000,%eax
or     %ecx,%eax
and    $0x3f,%edi
shl    $0x18,%edi
add    %edi,%eax
add    $0x80808000,%eax
mov    %eax,(%rsp)
mov    %rsp,%rsi
mov    $0x1,%edi
mov    $0x4,%edx
call   1030 <write@plt>
pop    %rax
ret

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

LLVM IR (-O2):
define void @ft_putchar(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = bitcast i32* %3 to i8*
%5 = icmp slt i32 %0, 128
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = call i32 @write(i32 1, i32* %2, i32 1)
br label %49
8: ; preds = %1
%9 = icmp ult i32 %0, 2048
br i1 %9, label %10, label %18
10: ; preds = %8
%11 = lshr i32 %0, 6
%12 = or i32 %11, 192
%13 = shl nuw nsw i32 %0, 8
%14 = and i32 %13, 16128
%15 = or i32 %14, 32768
%16 = add nuw nsw i32 %15, %12
store i32 %16, i32* %3
%17 = call i32 @write(i32 1, i32* %3, i32 2)
br label %49
18: ; preds = %8
%19 = icmp ult i32 %0, 65536
br i1 %19, label %20, label %31
20: ; preds = %18
%21 = lshr i32 %0, 12
%22 = or i32 %21, 224
%23 = shl nuw nsw i32 %0, 2
%24 = and i32 %23, 16128
%25 = shl nuw i32 %0, 16
%26 = and i32 %25, 4128768
%27 = or i32 %26, %24
%28 = or i32 %27, 8421376
%29 = add nuw nsw i32 %28, %22
store i32 %29, i32* %3
%30 = call i32 @write(i32 1, i32* %3, i32 3)
br label %49
31: ; preds = %18
%32 = icmp ult i32 %0, 1114112
br i1 %32, label %33, label %49
33: ; preds = %31
%34 = lshr i32 %0, 18
%35 = or i32 %34, 240
%36 = lshr i32 %0, 4
%37 = and i32 %36, 16128
%38 = or i32 %37, 32768
%39 = add nuw nsw i32 %38, %35
%40 = shl nuw nsw i32 %0, 10
%41 = and i32 %40, 4128768
%42 = or i32 %41, 8388608
%43 = or i32 %39, %42
%44 = shl i32 %0, 24
%45 = and i32 %44, 1056964608
%46 = or i32 %45, -2147483648
%47 = or i32 %43, %46
store i32 %47, i32* %3
%48 = call i32 @write(i32 1, i32* %3, i32 4)
br label %49
49: ; preds = %10, %31, %33, %20, %6
ret void
}