#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 /*<<< orphan*/ echo_1(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fputc(int, int /*<<< orphan*/ *);
void echo_upto(FILE *in, FILE *out, int chr) {
  int c;
  while ((c = fgetc(in)) != EOF) {
    fputc(c, out);
    if (c == '\\') {
      echo_1(in, out);
      continue;
    }
    if (c == chr)
      return;
  }
}


x86 assembly (clang, -O0):
<echo_upto>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %eax,-0x18(%rbp)
mov    0x2e92(%rip),%rcx
cmp    (%rcx),%eax
je     119c <echo_upto+0x6c>
mov    -0x18(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1040 <fputc@plt>
cmpl   $0x5c,-0x18(%rbp)
jne    1186 <echo_upto+0x56>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <echo_1@plt>
jmp    1143 <echo_upto+0x13>
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jne    1197 <echo_upto+0x67>
jmp    119c <echo_upto+0x6c>
jmp    1143 <echo_upto+0x13>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<echo_upto>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r14d
mov    %rsi,%r15
mov    %rdi,%rbp
call   1030 <fgetc@plt>
mov    0x2e9b(%rip),%r12
cmp    (%r12),%eax
je     118f <echo_upto+0x5f>
mov    %eax,%ebx
jmp    117b <echo_upto+0x4b>
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    %r15,%rsi
call   1050 <echo_1@plt>
mov    %rbp,%rdi
call   1030 <fgetc@plt>
mov    %eax,%ebx
cmp    (%r12),%eax
je     118f <echo_upto+0x5f>
mov    %ebx,%edi
mov    %r15,%rsi
call   1040 <fputc@plt>
cmp    $0x5c,%ebx
je     1160 <echo_upto+0x30>
cmp    %r14d,%ebx
jne    116b <echo_upto+0x3b>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
define void @echo_upto(i32* %0, i32* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
br label %8
8: ; preds = %28, %19, %3
%9 = load i32*, i32** %4
%10 = call i32 @fgetc(i32* %9)
store i32 %10, i32* %7
%11 = load i32, i32* @EOF
%12 = icmp ne i32 %10, %11
br i1 %12, label %13, label %29
13: ; preds = %8
%14 = load i32, i32* %7
%15 = load i32*, i32** %5
%16 = call i32 @fputc(i32 %14, i32* %15)
%17 = load i32, i32* %7
%18 = icmp eq i32 %17, 92
br i1 %18, label %19, label %23
19: ; preds = %13
%20 = load i32*, i32** %4
%21 = load i32*, i32** %5
%22 = call i32 @echo_1(i32* %20, i32* %21)
br label %8
23: ; preds = %13
%24 = load i32, i32* %7
%25 = load i32, i32* %6
%26 = icmp eq i32 %24, %25
br i1 %26, label %27, label %28
27: ; preds = %23
br label %29
28: ; preds = %23
br label %8
29: ; preds = %27, %8
ret void
}

LLVM IR (-O2):
@EOF = global i32 0
define void @echo_upto(i32* %0, i32* %1, i32 %2) {
%4 = tail call i32 @fgetc(i32* %0)
%5 = load i32, i32* @EOF
%6 = icmp eq i32 %4, %5
br i1 %6, label %19, label %7
7: ; preds = %3, %13
%8 = phi i32 [ %14, %13 ], [ %4, %3 ]
%9 = tail call i32 @fputc(i32 %8, i32* %1)
%10 = icmp eq i32 %8, 92
br i1 %10, label %11, label %17
11: ; preds = %7
%12 = tail call i32 @echo_1(i32* %0, i32* %1)
br label %13
13: ; preds = %11, %17
%14 = tail call i32 @fgetc(i32* %0)
%15 = load i32, i32* @EOF
%16 = icmp eq i32 %14, %15
br i1 %16, label %19, label %7
17: ; preds = %7
%18 = icmp eq i32 %8, %2
br i1 %18, label %19, label %13
19: ; preds = %17, %13, %3
ret void
}