#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 prs_comp_cxt {
  int dummy;
};

/* Variables and functions */
int set_bit(struct prs_comp_cxt *, int);
int write_final_flags(struct prs_comp_cxt *);
int write_literal(struct prs_comp_cxt *, int /*<<< orphan*/);
int write_eof(struct prs_comp_cxt *cxt) {
  int rv;
  if ((rv = set_bit(cxt, 0)))
    return rv;
  if ((rv = set_bit(cxt, 1)))
    return rv;
  if ((rv = write_final_flags(cxt)))
    return rv;
  if ((rv = write_literal(cxt, 0)))
    return rv;
  if ((rv = write_literal(cxt, 0)))
    return rv;
  return 0;
}


x86 assembly (clang, -O0):
<write_eof>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
call   1030 <set_bit@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
je     115e <write_eof+0x2e>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11ee <write_eof+0xbe>
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1030 <set_bit@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
je     1183 <write_eof+0x53>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11ee <write_eof+0xbe>
mov    -0x10(%rbp),%rdi
call   1050 <write_final_flags@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
je     11a3 <write_eof+0x73>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11ee <write_eof+0xbe>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
call   1040 <write_literal@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
je     11c5 <write_eof+0x95>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11ee <write_eof+0xbe>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
call   1040 <write_literal@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
je     11e7 <write_eof+0xb7>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11ee <write_eof+0xbe>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_eof>:
push   %rbx
mov    %rdi,%rbx
xor    %esi,%esi
call   1030 <set_bit@plt>
test   %eax,%eax
jne    116a <write_eof+0x3a>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1030 <set_bit@plt>
test   %eax,%eax
jne    116a <write_eof+0x3a>
mov    %rbx,%rdi
call   1050 <write_final_flags@plt>
test   %eax,%eax
jne    116a <write_eof+0x3a>
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <write_literal@plt>
test   %eax,%eax
je     116c <write_eof+0x3c>
pop    %rbx
ret
mov    %rbx,%rdi
xor    %esi,%esi
pop    %rbx
jmp    1040 <write_literal@plt>

LLVM IR (-O0):
%struct.prs_comp_cxt = type { i32 }
define i32 @write_eof(%struct.prs_comp_cxt* %0) {
%2 = alloca i32
%3 = alloca %struct.prs_comp_cxt*
%4 = alloca i32
store %struct.prs_comp_cxt* %0, %struct.prs_comp_cxt** %3
%5 = load %struct.prs_comp_cxt*, %struct.prs_comp_cxt** %3
%6 = call i32 @set_bit(%struct.prs_comp_cxt* %5, i32 0)
store i32 %6, i32* %4
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = load i32, i32* %4
store i32 %9, i32* %2
br label %35
10: ; preds = %1
%11 = load %struct.prs_comp_cxt*, %struct.prs_comp_cxt** %3
%12 = call i32 @set_bit(%struct.prs_comp_cxt* %11, i32 1)
store i32 %12, i32* %4
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = load i32, i32* %4
store i32 %15, i32* %2
br label %35
16: ; preds = %10
%17 = load %struct.prs_comp_cxt*, %struct.prs_comp_cxt** %3
%18 = call i32 @write_final_flags(%struct.prs_comp_cxt* %17)
store i32 %18, i32* %4
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = load i32, i32* %4
store i32 %21, i32* %2
br label %35
22: ; preds = %16
%23 = load %struct.prs_comp_cxt*, %struct.prs_comp_cxt** %3
%24 = call i32 @write_literal(%struct.prs_comp_cxt* %23, i32 0)
store i32 %24, i32* %4
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = load i32, i32* %4
store i32 %27, i32* %2
br label %35
28: ; preds = %22
%29 = load %struct.prs_comp_cxt*, %struct.prs_comp_cxt** %3
%30 = call i32 @write_literal(%struct.prs_comp_cxt* %29, i32 0)
store i32 %30, i32* %4
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = load i32, i32* %4
store i32 %33, i32* %2
br label %35
34: ; preds = %28
store i32 0, i32* %2
br label %35
35: ; preds = %34, %32, %26, %20, %14, %8
%36 = load i32, i32* %2
ret i32 %36
}

LLVM IR (-O2):
%struct.prs_comp_cxt = type { i32 }
define i32 @write_eof(%struct.prs_comp_cxt* %0) {
%2 = tail call i32 @set_bit(%struct.prs_comp_cxt* %0, i32 0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %15
4: ; preds = %1
%5 = tail call i32 @set_bit(%struct.prs_comp_cxt* %0, i32 1)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %15
7: ; preds = %4
%8 = tail call i32 @write_final_flags(%struct.prs_comp_cxt* %0)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %7
%11 = tail call i32 @write_literal(%struct.prs_comp_cxt* %0, i32 0)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = tail call i32 @write_literal(%struct.prs_comp_cxt* %0, i32 0)
br label %15
15: ; preds = %13, %10, %7, %4, %1
%16 = phi i32 [ %2, %1 ], [ %5, %4 ], [ %8, %7 ], [ %11, %10 ], [ %14, %13 ]
ret i32 %16
}