#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 */

/* Variables and functions */
int /*<<< orphan*/ mgetbytes(unsigned long);
unsigned long mgetsize(unsigned long *, unsigned long *);
int /*<<< orphan*/ mputbytes(int /*<<< orphan*/, unsigned long);
scalar_t__ msetsize(unsigned long, unsigned long, long);
scalar_t__ msynch();
long section_simple() {
  unsigned long off0, off1;
  unsigned long len;
  long delta = 0;
  len = mgetsize(&off0, &off1);
  if (len) {
    msynch();
    mputbytes(mgetbytes(len), len);
    delta += msetsize(off0, off1, delta);
  } else {
    delta += msynch();
  }
  return delta;
}


x86 assembly (clang, -O0):
<section_simple>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movq   $0x0,-0x20(%rbp)
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1030 <mgetsize@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11b5 <section_simple+0x65>
mov    $0x0,%al
call   1060 <msynch@plt>
mov    -0x18(%rbp),%rdi
call   1070 <mgetbytes@plt>
mov    %eax,%edi
mov    -0x18(%rbp),%rsi
call   1050 <mputbytes@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <msetsize@plt>
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    11c4 <section_simple+0x74>
mov    $0x0,%al
call   1060 <msynch@plt>
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<section_simple>:
push   %rbx
sub    $0x10,%rsp
lea    0x8(%rsp),%rdi
mov    %rsp,%rsi
call   1030 <mgetsize@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1060 <msynch@plt>
test   %rbx,%rbx
je     1193 <section_simple+0x43>
mov    %rbx,%rdi
call   1070 <mgetbytes@plt>
mov    %eax,%edi
mov    %rbx,%rsi
call   1050 <mputbytes@plt>
mov    0x8(%rsp),%rdi
mov    (%rsp),%rsi
xor    %edx,%edx
call   1040 <msetsize@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i64 @section_simple() {
%1 = alloca i64
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
store i64 0, i64* %4
%5 = call i64 @mgetsize(i64* %1, i64* %2)
store i64 %5, i64* %3
%6 = load i64, i64* %3
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %20
8: ; preds = %0
%9 = call i64 (...) @msynch()
%10 = load i64, i64* %3
%11 = call i32 @mgetbytes(i64 %10)
%12 = load i64, i64* %3
%13 = call i32 @mputbytes(i32 %11, i64 %12)
%14 = load i64, i64* %1
%15 = load i64, i64* %2
%16 = load i64, i64* %4
%17 = call i64 @msetsize(i64 %14, i64 %15, i64 %16)
%18 = load i64, i64* %4
%19 = add nsw i64 %18, %17
store i64 %19, i64* %4
br label %24
20: ; preds = %0
%21 = call i64 (...) @msynch()
%22 = load i64, i64* %4
%23 = add nsw i64 %22, %21
store i64 %23, i64* %4
br label %24
24: ; preds = %20, %8
%25 = load i64, i64* %4
ret i64 %25
}

LLVM IR (-O2):
define i64 @section_simple() {
%1 = alloca i64
%2 = alloca i64
%3 = bitcast i64* %1 to i8*
%4 = bitcast i64* %2 to i8*
%5 = call i64 @mgetsize(i64* %1, i64* %2)
%6 = icmp eq i64 %5, 0
%7 = call i64 (...) @msynch()
br i1 %6, label %14, label %8
8: ; preds = %0
%9 = call i32 @mgetbytes(i64 %5)
%10 = call i32 @mputbytes(i32 %9, i64 %5)
%11 = load i64, i64* %1
%12 = load i64, i64* %2
%13 = call i64 @msetsize(i64 %11, i64 %12, i64 0)
br label %14
14: ; preds = %0, %8
%15 = phi i64 [ %13, %8 ], [ %7, %0 ]
ret i64 %15
}