#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*/ printf(char *, unsigned char, ...);
void printf_char(int wchar) {
  if (wchar < 128)
    printf("%c", wchar);
  else {
    unsigned char first = (wchar >> 6) | 0xC0;
    unsigned char second = (wchar & 0x3F) | 0x80;
    printf("%c%c", first, second);
  }
}


x86 assembly (clang, -O0):
<printf_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x80,-0x4(%rbp)
jge    1141 <printf_char+0x31>
mov    -0x4(%rbp),%eax
lea    0xed0(%rip),%rdi
movzbl %al,%esi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1175 <printf_char+0x65>
mov    -0x4(%rbp),%eax
sar    $0x6,%eax
or     $0xc0,%eax
mov    %al,-0x5(%rbp)
mov    -0x4(%rbp),%eax
and    $0x3f,%eax
or     $0x80,%eax
mov    %al,-0x6(%rbp)
mov    -0x5(%rbp),%al
movzbl -0x6(%rbp),%edx
lea    0xe95(%rip),%rdi
movzbl %al,%esi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printf_char>:
mov    %edi,%edx
cmp    $0x7f,%edi
jg     1128 <printf_char+0x18>
movzbl %dl,%esi
lea    0xee1(%rip),%rdi
xor    %eax,%eax
jmp    1030 <printf@plt>
mov    %edx,%eax
shr    $0x6,%eax
or     $0xc0,%al
and    $0x3f,%edx
or     $0x80,%edx
movzbl %al,%esi
lea    0xebe(%rip),%rdi
xor    %eax,%eax
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
@.str.1 = [5 x i8] c"%c%c\00"
define void @printf_char(i32 %0) {
%2 = alloca i32
%3 = alloca i8
%4 = alloca i8
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = icmp slt i32 %5, 128
br i1 %6, label %7, label %11
7: ; preds = %1
%8 = load i32, i32* %2
%9 = trunc i32 %8 to i8
%10 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 zeroext %9)
br label %24
11: ; preds = %1
%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 = load i32, i32* %2
%17 = and i32 %16, 63
%18 = or i32 %17, 128
%19 = trunc i32 %18 to i8
store i8 %19, i8* %4
%20 = load i8, i8* %3
%21 = load i8, i8* %4
%22 = zext i8 %21 to i32
%23 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %20, i32 %22)
br label %24
24: ; preds = %11, %7
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
@.str.1 = [5 x i8] c"%c%c\00"
define void @printf_char(i32 %0) {
%2 = icmp slt i32 %0, 128
br i1 %2, label %3, label %6
3: ; preds = %1
%4 = trunc i32 %0 to i8
%5 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 zeroext %4)
br label %13
6: ; preds = %1
%7 = lshr i32 %0, 6
%8 = trunc i32 %7 to i8
%9 = or i8 %8, -64
%10 = and i32 %0, 63
%11 = or i32 %10, 128
%12 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %9, i32 %11)
br label %13
13: ; preds = %6, %3
ret void
}