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

/* Variables and functions */
int rn_compress_last(int);
int /*<<< orphan*/ rnc_close(struct rnc_source *);
int /*<<< orphan*/ rnc_errors(struct rnc_source *);
int rnc_parse(struct rnc_source *);
int rnd_fixup(int);
int load(struct rnc_source *sp) {
  int start = -1;
  if (!rnc_errors(sp))
    start = rnc_parse(sp);
  rnc_close(sp);
  if (!rnc_errors(sp) && (start = rnd_fixup(start))) {
    start = rn_compress_last(start);
  } else
    start = 0;
  return start;
}


x86 assembly (clang, -O0):
<load>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0xffffffff,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <rnc_errors@plt>
cmp    $0x0,%eax
jne    1181 <load+0x31>
mov    -0x8(%rbp),%rdi
call   1050 <rnc_parse@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <rnc_close@plt>
mov    -0x8(%rbp),%rdi
call   1040 <rnc_errors@plt>
cmp    $0x0,%eax
jne    11c0 <load+0x70>
mov    -0xc(%rbp),%edi
call   1060 <rnd_fixup@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
je     11c0 <load+0x70>
mov    -0xc(%rbp),%edi
call   1070 <rn_compress_last@plt>
mov    %eax,-0xc(%rbp)
jmp    11c7 <load+0x77>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1040 <rnc_errors@plt>
mov    $0xffffffff,%ebp
test   %eax,%eax
jne    116e <load+0x1e>
mov    %rbx,%rdi
call   1050 <rnc_parse@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <rnc_close@plt>
mov    %rbx,%rdi
call   1040 <rnc_errors@plt>
test   %eax,%eax
je     118b <load+0x3b>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    %ebp,%edi
call   1060 <rnd_fixup@plt>
test   %eax,%eax
je     1182 <load+0x32>
mov    %eax,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1070 <rn_compress_last@plt>

LLVM IR (-O0):
%struct.rnc_source = type { i32 }
define i32 @load(%struct.rnc_source* %0) {
%2 = alloca %struct.rnc_source*
%3 = alloca i32
store %struct.rnc_source* %0, %struct.rnc_source** %2
store i32 -1, i32* %3
%4 = load %struct.rnc_source*, %struct.rnc_source** %2
%5 = call i32 @rnc_errors(%struct.rnc_source* %4)
%6 = icmp ne i32 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %1
%8 = load %struct.rnc_source*, %struct.rnc_source** %2
%9 = call i32 @rnc_parse(%struct.rnc_source* %8)
store i32 %9, i32* %3
br label %10
10: ; preds = %7, %1
%11 = load %struct.rnc_source*, %struct.rnc_source** %2
%12 = call i32 @rnc_close(%struct.rnc_source* %11)
%13 = load %struct.rnc_source*, %struct.rnc_source** %2
%14 = call i32 @rnc_errors(%struct.rnc_source* %13)
%15 = icmp ne i32 %14, 0
br i1 %15, label %23, label %16
16: ; preds = %10
%17 = load i32, i32* %3
%18 = call i32 @rnd_fixup(i32 %17)
store i32 %18, i32* %3
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %16
%21 = load i32, i32* %3
%22 = call i32 @rn_compress_last(i32 %21)
store i32 %22, i32* %3
br label %24
23: ; preds = %16, %10
store i32 0, i32* %3
br label %24
24: ; preds = %23, %20
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
%struct.rnc_source = type { i32 }
define i32 @load(%struct.rnc_source* %0) {
%2 = tail call i32 @rnc_errors(%struct.rnc_source* %0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @rnc_parse(%struct.rnc_source* %0)
br label %6
6: ; preds = %4, %1
%7 = phi i32 [ -1, %1 ], [ %5, %4 ]
%8 = tail call i32 @rnc_close(%struct.rnc_source* %0)
%9 = tail call i32 @rnc_errors(%struct.rnc_source* %0)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %6
%12 = tail call i32 @rnd_fixup(i32 %7)
%13 = icmp eq i32 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %11
%15 = tail call i32 @rn_compress_last(i32 %12)
br label %16
16: ; preds = %6, %11, %14
%17 = phi i32 [ %15, %14 ], [ 0, %11 ], [ 0, %6 ]
ret i32 %17
}