#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 /*<<< orphan*/ PError(char *);
int /*<<< orphan*/ exit(int);
int putc(int, int /*<<< orphan*/ *);
void RLEcode_to_file(int c, int repeat, FILE *fd) {
  if ((repeat == 1) && ((c & 0xC0) != 0xC0)) {
    if (putc(c, fd) == (-1)) {
      PError("RLEcode_to_file (1)");
      exit((-1));
    }
  } else {
    if (putc(repeat | 0xC0, fd) == (-1)) {
      PError("RLEcode_to_file (2)");
      exit((-1));
    }
    if (putc(c, fd) == (-1)) {
      PError("RLEcode_to_file (3)");
      exit((-1));
    }
  }
}


x86 assembly (clang, -O0):
<RLEcode_to_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    118f <RLEcode_to_file+0x5f>
mov    -0x4(%rbp),%eax
and    $0xc0,%eax
cmp    $0xc0,%eax
je     118f <RLEcode_to_file+0x5f>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <putc@plt>
cmp    $0xffffffff,%eax
jne    118a <RLEcode_to_file+0x5a>
lea    0xe85(%rip),%rdi
call   1040 <PError@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
jmp    11f0 <RLEcode_to_file+0xc0>
mov    -0x8(%rbp),%edi
or     $0xc0,%edi
mov    -0x10(%rbp),%rsi
call   1030 <putc@plt>
cmp    $0xffffffff,%eax
jne    11c0 <RLEcode_to_file+0x90>
lea    0xe63(%rip),%rdi
call   1040 <PError@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <putc@plt>
cmp    $0xffffffff,%eax
jne    11eb <RLEcode_to_file+0xbb>
lea    0xe4c(%rip),%rdi
call   1040 <PError@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
jmp    11f0 <RLEcode_to_file+0xc0>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RLEcode_to_file>:
push   %rbp
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %edi,%ebp
cmp    $0x1,%esi
jne    1163 <RLEcode_to_file+0x33>
mov    %ebp,%eax
and    $0xc0,%eax
cmp    $0xc0,%eax
je     1163 <RLEcode_to_file+0x33>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1030 <putc@plt>
cmp    $0xffffffff,%eax
jne    1187 <RLEcode_to_file+0x57>
lea    0xe9f(%rip),%rdi
jmp    119e <RLEcode_to_file+0x6e>
or     $0xc0,%esi
mov    %esi,%edi
mov    %rbx,%rsi
call   1030 <putc@plt>
cmp    $0xffffffff,%eax
je     118e <RLEcode_to_file+0x5e>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1030 <putc@plt>
cmp    $0xffffffff,%eax
je     1197 <RLEcode_to_file+0x67>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe7f(%rip),%rdi
jmp    119e <RLEcode_to_file+0x6e>
lea    0xe8a(%rip),%rdi
call   1040 <PError@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [20 x i8] c"RLEcode_to_file (1)\00"
@.str.1 = [20 x i8] c"RLEcode_to_file (2)\00"
@.str.2 = [20 x i8] c"RLEcode_to_file (3)\00"
define void @RLEcode_to_file(i32 %0, i32 %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32* %2, i32** %6
%7 = load i32, i32* %5
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %22
9: ; preds = %3
%10 = load i32, i32* %4
%11 = and i32 %10, 192
%12 = icmp ne i32 %11, 192
br i1 %12, label %13, label %22
13: ; preds = %9
%14 = load i32, i32* %4
%15 = load i32*, i32** %6
%16 = call i32 @putc(i32 %14, i32* %15)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %21
18: ; preds = %13
%19 = call i32 @PError(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%20 = call i32 @exit(i32 -1)
unreachable
21: ; preds = %13
br label %40
22: ; preds = %9, %3
%23 = load i32, i32* %5
%24 = or i32 %23, 192
%25 = load i32*, i32** %6
%26 = call i32 @putc(i32 %24, i32* %25)
%27 = icmp eq i32 %26, -1
br i1 %27, label %28, label %31
28: ; preds = %22
%29 = call i32 @PError(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%30 = call i32 @exit(i32 -1)
unreachable
31: ; preds = %22
%32 = load i32, i32* %4
%33 = load i32*, i32** %6
%34 = call i32 @putc(i32 %32, i32* %33)
%35 = icmp eq i32 %34, -1
br i1 %35, label %36, label %39
36: ; preds = %31
%37 = call i32 @PError(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%38 = call i32 @exit(i32 -1)
unreachable
39: ; preds = %31
br label %40
40: ; preds = %39, %21
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"RLEcode_to_file (1)\00"
@.str.1 = [20 x i8] c"RLEcode_to_file (2)\00"
@.str.2 = [20 x i8] c"RLEcode_to_file (3)\00"
define void @RLEcode_to_file(i32 %0, i32 %1, i32* nocapture %2) {
%4 = icmp ne i32 %1, 1
%5 = and i32 %0, 192
%6 = icmp eq i32 %5, 192
%7 = or i1 %4, %6
br i1 %7, label %14, label %8
8: ; preds = %3
%9 = tail call i32 @putc(i32 %0, i32* %2)
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %27
11: ; preds = %8
%12 = tail call i32 @PError(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%13 = tail call i32 @exit(i32 -1)
unreachable
14: ; preds = %3
%15 = or i32 %1, 192
%16 = tail call i32 @putc(i32 %15, i32* %2)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %21
18: ; preds = %14
%19 = tail call i32 @PError(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%20 = tail call i32 @exit(i32 -1)
unreachable
21: ; preds = %14
%22 = tail call i32 @putc(i32 %0, i32* %2)
%23 = icmp eq i32 %22, -1
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = tail call i32 @PError(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%26 = tail call i32 @exit(i32 -1)
unreachable
27: ; preds = %21, %8
ret void
}