#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*/ putchar(int);
void print_utf8(int code) {
  if (code <= 0x7f) {
    putchar(code);
  } else if (code <= 0x7ff) {
    putchar(0xc0 | code >> 6);
    putchar(0x80 | (code & 0x3f));
  } else {
    putchar(0xe0 | code >> 12);
    putchar(0x80 | (code >> 6 & 0x3f));
    putchar(0x80 | (code & 0x3f));
  }
}


x86 assembly (clang, -O0):
<print_utf8>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x7f,-0x4(%rbp)
jg     1132 <print_utf8+0x22>
mov    -0x4(%rbp),%edi
call   1030 <putchar@plt>
jmp    11a1 <print_utf8+0x91>
cmpl   $0x7ff,-0x4(%rbp)
jg     1166 <print_utf8+0x56>
mov    -0x4(%rbp),%edi
sar    $0x6,%edi
or     $0xc0,%edi
call   1030 <putchar@plt>
mov    -0x4(%rbp),%edi
and    $0x3f,%edi
or     $0x80,%edi
call   1030 <putchar@plt>
jmp    119c <print_utf8+0x8c>
mov    -0x4(%rbp),%edi
sar    $0xc,%edi
or     $0xe0,%edi
call   1030 <putchar@plt>
mov    -0x4(%rbp),%edi
sar    $0x6,%edi
and    $0x3f,%edi
or     $0x80,%edi
call   1030 <putchar@plt>
mov    -0x4(%rbp),%edi
and    $0x3f,%edi
or     $0x80,%edi
call   1030 <putchar@plt>
jmp    11a1 <print_utf8+0x91>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_utf8>:
push   %rbx
mov    %edi,%ebx
cmp    $0x80,%edi
jl     115a <print_utf8+0x4a>
mov    %ebx,%edi
cmp    $0x7ff,%ebx
ja     1130 <print_utf8+0x20>
shr    $0x6,%edi
or     $0xc0,%edi
jmp    114c <print_utf8+0x3c>
shr    $0xc,%edi
or     $0xe0,%edi
call   1030 <putchar@plt>
mov    %ebx,%edi
shr    $0x6,%edi
and    $0x3f,%edi
or     $0x80,%edi
call   1030 <putchar@plt>
and    $0x3f,%ebx
or     $0x80,%ebx
mov    %ebx,%edi
pop    %rbx
jmp    1030 <putchar@plt>

LLVM IR (-O0):
define void @print_utf8(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp sle i32 %3, 127
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = load i32, i32* %2
%7 = call i32 @putchar(i32 %6)
br label %35
8: ; preds = %1
%9 = load i32, i32* %2
%10 = icmp sle i32 %9, 2047
br i1 %10, label %11, label %20
11: ; preds = %8
%12 = load i32, i32* %2
%13 = ashr i32 %12, 6
%14 = or i32 192, %13
%15 = call i32 @putchar(i32 %14)
%16 = load i32, i32* %2
%17 = and i32 %16, 63
%18 = or i32 128, %17
%19 = call i32 @putchar(i32 %18)
br label %34
20: ; preds = %8
%21 = load i32, i32* %2
%22 = ashr i32 %21, 12
%23 = or i32 224, %22
%24 = call i32 @putchar(i32 %23)
%25 = load i32, i32* %2
%26 = ashr i32 %25, 6
%27 = and i32 %26, 63
%28 = or i32 128, %27
%29 = call i32 @putchar(i32 %28)
%30 = load i32, i32* %2
%31 = and i32 %30, 63
%32 = or i32 128, %31
%33 = call i32 @putchar(i32 %32)
br label %34
34: ; preds = %20, %11
br label %35
35: ; preds = %34, %5
ret void
}

LLVM IR (-O2):
define void @print_utf8(i32 %0) {
%2 = icmp slt i32 %0, 128
br i1 %2, label %20, label %3
3: ; preds = %1
%4 = icmp ult i32 %0, 2048
br i1 %4, label %5, label %8
5: ; preds = %3
%6 = lshr i32 %0, 6
%7 = or i32 %6, 192
br label %15
8: ; preds = %3
%9 = lshr i32 %0, 12
%10 = or i32 %9, 224
%11 = tail call i32 @putchar(i32 %10)
%12 = lshr i32 %0, 6
%13 = and i32 %12, 63
%14 = or i32 %13, 128
br label %15
15: ; preds = %8, %5
%16 = phi i32 [ %7, %5 ], [ %14, %8 ]
%17 = tail call i32 @putchar(i32 %16)
%18 = and i32 %0, 63
%19 = or i32 %18, 128
br label %20
20: ; preds = %15, %1
%21 = phi i32 [ %0, %1 ], [ %19, %15 ]
%22 = tail call i32 @putchar(i32 %21)
ret void
}