#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 */
struct feed_buf {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ feed_buf_write_character(struct feed_buf *const, char);
char feed_buf_write_number(struct feed_buf *const, long);
char feed_esc_write_prefix(struct feed_buf *const);
char feed_esc_write_ed(struct feed_buf *const p_buf,
                       unsigned int const i_count) {
  char b_result;
  b_result = feed_esc_write_prefix(p_buf);
  if (b_result) {
    if (0 != i_count) {
      b_result = feed_buf_write_number(p_buf, (signed long int)(i_count));
    }
    if (b_result) {
      feed_buf_write_character(p_buf, 'J');
    }
  }
  return b_result;
}


x86 assembly (clang, -O0):
<feed_esc_write_ed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <feed_esc_write_prefix@plt>
mov    %al,-0xd(%rbp)
cmpb   $0x0,-0xd(%rbp)
je     118e <feed_esc_write_ed+0x5e>
xor    %eax,%eax
cmp    -0xc(%rbp),%eax
je     1171 <feed_esc_write_ed+0x41>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%eax
mov    %eax,%esi
call   1050 <feed_buf_write_number@plt>
mov    %al,-0xd(%rbp)
cmpb   $0x0,-0xd(%rbp)
je     1189 <feed_esc_write_ed+0x59>
mov    -0x8(%rbp),%rdi
mov    $0x4a,%esi
call   1040 <feed_buf_write_character@plt>
jmp    118e <feed_esc_write_ed+0x5e>
movsbl -0xd(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<feed_esc_write_ed>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %rdi,%r14
call   1030 <feed_esc_write_prefix@plt>
test   %al,%al
je     1156 <feed_esc_write_ed+0x26>
test   %ebp,%ebp
je     115a <feed_esc_write_ed+0x2a>
mov    %ebp,%esi
mov    %r14,%rdi
call   1050 <feed_buf_write_number@plt>
mov    %eax,%ebx
test   %al,%al
jne    115c <feed_esc_write_ed+0x2c>
xor    %ebx,%ebx
jmp    1169 <feed_esc_write_ed+0x39>
mov    %eax,%ebx
mov    %r14,%rdi
mov    $0x4a,%esi
call   1040 <feed_buf_write_character@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.feed_buf = type { i32 }
define signext i8 @feed_esc_write_ed(%struct.feed_buf* %0, i32 %1) {
%3 = alloca %struct.feed_buf*
%4 = alloca i32
%5 = alloca i8
store %struct.feed_buf* %0, %struct.feed_buf** %3
store i32 %1, i32* %4
%6 = load %struct.feed_buf*, %struct.feed_buf** %3
%7 = call signext i8 @feed_esc_write_prefix(%struct.feed_buf* %6)
store i8 %7, i8* %5
%8 = load i8, i8* %5
%9 = icmp ne i8 %8, 0
br i1 %9, label %10, label %25
10: ; preds = %2
%11 = load i32, i32* %4
%12 = icmp ne i32 0, %11
br i1 %12, label %13, label %18
13: ; preds = %10
%14 = load %struct.feed_buf*, %struct.feed_buf** %3
%15 = load i32, i32* %4
%16 = zext i32 %15 to i64
%17 = call signext i8 @feed_buf_write_number(%struct.feed_buf* %14, i64 %16)
store i8 %17, i8* %5
br label %18
18: ; preds = %13, %10
%19 = load i8, i8* %5
%20 = icmp ne i8 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = load %struct.feed_buf*, %struct.feed_buf** %3
%23 = call i32 @feed_buf_write_character(%struct.feed_buf* %22, i8 signext 74)
br label %24
24: ; preds = %21, %18
br label %25
25: ; preds = %24, %2
%26 = load i8, i8* %5
ret i8 %26
}

LLVM IR (-O2):
%struct.feed_buf = type { i32 }
define signext i8 @feed_esc_write_ed(%struct.feed_buf* %0, i32 %1) {
%3 = tail call signext i8 @feed_esc_write_prefix(%struct.feed_buf* %0)
%4 = icmp eq i8 %3, 0
br i1 %4, label %14, label %5
5: ; preds = %2
%6 = icmp eq i32 %1, 0
br i1 %6, label %11, label %7
7: ; preds = %5
%8 = zext i32 %1 to i64
%9 = tail call signext i8 @feed_buf_write_number(%struct.feed_buf* %0, i64 %8)
%10 = icmp eq i8 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %5, %7
%12 = phi i8 [ %9, %7 ], [ %3, %5 ]
%13 = tail call i32 @feed_buf_write_character(%struct.feed_buf* %0, i8 signext 74)
br label %14
14: ; preds = %7, %11, %2
%15 = phi i8 [ %12, %11 ], [ 0, %7 ], [ 0, %2 ]
ret i8 %15
}