#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 /*<<< orphan*/ FILE;

/* Variables and functions */
int EOF;
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ putc(int, int /*<<< orphan*/ *);
void latin1_utf8(FILE *in, FILE *out) {
  int c;
  while ((c = getc(in)) != EOF) {
    if (c <= 0x7F) {
      putc(c, out);
    } else {
      putc(0xC0 | (c >> 6), out);
      putc(0x80 | (c & 0x3F), out);
    }
  }
}


x86 assembly (clang, -O0):
<latin1_utf8>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <getc@plt>
mov    %eax,-0x14(%rbp)
mov    0x2ea5(%rip),%rcx
cmp    (%rcx),%eax
je     1195 <latin1_utf8+0x75>
cmpl   $0x7f,-0x14(%rbp)
jg     1166 <latin1_utf8+0x46>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <putc@plt>
jmp    1190 <latin1_utf8+0x70>
mov    -0x14(%rbp),%edi
sar    $0x6,%edi
or     $0xc0,%edi
mov    -0x10(%rbp),%rsi
call   1030 <putc@plt>
mov    -0x14(%rbp),%edi
and    $0x3f,%edi
or     $0x80,%edi
mov    -0x10(%rbp),%rsi
call   1030 <putc@plt>
jmp    1130 <latin1_utf8+0x10>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<latin1_utf8>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
call   1040 <getc@plt>
mov    0x2eaf(%rip),%r15
cmp    (%r15),%eax
jne    1149 <latin1_utf8+0x29>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebp
jmp    1169 <latin1_utf8+0x49>
nopl   (%rax)
mov    %ebp,%edi
mov    %rbx,%rsi
call   1030 <putc@plt>
mov    %r14,%rdi
call   1040 <getc@plt>
mov    %eax,%ebp
cmp    (%r15),%eax
je     113e <latin1_utf8+0x1e>
cmp    $0x80,%ebp
jl     1150 <latin1_utf8+0x30>
mov    %ebp,%edi
shr    $0x6,%edi
or     $0xc0,%edi
mov    %rbx,%rsi
call   1030 <putc@plt>
and    $0x3f,%ebp
or     $0x80,%ebp
jmp    1150 <latin1_utf8+0x30>

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

LLVM IR (-O2):
@EOF = global i32 0
define void @latin1_utf8(i32* nocapture %0, i32* nocapture %1) {
%3 = tail call i32 @getc(i32* %0)
%4 = load i32, i32* @EOF
%5 = icmp eq i32 %3, %4
br i1 %5, label %21, label %6
6: ; preds = %2, %15
%7 = phi i32 [ %18, %15 ], [ %3, %2 ]
%8 = icmp slt i32 %7, 128
br i1 %8, label %15, label %9
9: ; preds = %6
%10 = lshr i32 %7, 6
%11 = or i32 %10, 192
%12 = tail call i32 @putc(i32 %11, i32* %1)
%13 = and i32 %7, 63
%14 = or i32 %13, 128
br label %15
15: ; preds = %6, %9
%16 = phi i32 [ %14, %9 ], [ %7, %6 ]
%17 = tail call i32 @putc(i32 %16, i32* %1)
%18 = tail call i32 @getc(i32* %0)
%19 = load i32, i32* @EOF
%20 = icmp eq i32 %18, %19
br i1 %20, label %21, label %6
21: ; preds = %15, %2
ret void
}