#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 */
unsigned long mgetsize(unsigned long *, unsigned long *);
int /*<<< orphan*/ mgetuleb128();
int /*<<< orphan*/ mputuleb128(int /*<<< orphan*/);
scalar_t__ msetsize(unsigned long, unsigned long, long);
scalar_t__ msynch();
long section_start() {
  unsigned long off0, off1;
  unsigned long len;
  long delta = 0;
  len = mgetsize(&off0, &off1);
  if (len) {
    msynch();
    mputuleb128(mgetuleb128());
    delta += msynch();
    delta += msetsize(off0, off1, delta);
  } else {
    delta += msynch();
  }
  return delta;
}


x86 assembly (clang, -O0):
<section_start>:
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     11be <section_start+0x6e>
mov    $0x0,%al
call   1070 <msynch@plt>
mov    $0x0,%al
call   1050 <mgetuleb128@plt>
mov    %eax,%edi
call   1060 <mputuleb128@plt>
mov    $0x0,%al
call   1070 <msynch@plt>
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
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    11cd <section_start+0x7d>
mov    $0x0,%al
call   1070 <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_start>:
push   %rbx
sub    $0x10,%rsp
lea    0x8(%rsp),%rdi
mov    %rsp,%rsi
call   1030 <mgetsize@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1070 <msynch@plt>
test   %rbx,%rbx
je     119d <section_start+0x4d>
xor    %eax,%eax
call   1050 <mgetuleb128@plt>
mov    %eax,%edi
call   1060 <mputuleb128@plt>
xor    %eax,%eax
call   1070 <msynch@plt>
mov    %rax,%rbx
mov    0x8(%rsp),%rdi
mov    (%rsp),%rsi
mov    %rax,%rdx
call   1040 <msetsize@plt>
add    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i64 @section_start() {
%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 %21
8: ; preds = %0
%9 = call i64 (...) @msynch()
%10 = call i32 (...) @mgetuleb128()
%11 = call i32 @mputuleb128(i32 %10)
%12 = call i64 (...) @msynch()
%13 = load i64, i64* %4
%14 = add nsw i64 %13, %12
store i64 %14, i64* %4
%15 = load i64, i64* %1
%16 = load i64, i64* %2
%17 = load i64, i64* %4
%18 = call i64 @msetsize(i64 %15, i64 %16, i64 %17)
%19 = load i64, i64* %4
%20 = add nsw i64 %19, %18
store i64 %20, i64* %4
br label %25
21: ; preds = %0
%22 = call i64 (...) @msynch()
%23 = load i64, i64* %4
%24 = add nsw i64 %23, %22
store i64 %24, i64* %4
br label %25
25: ; preds = %21, %8
%26 = load i64, i64* %4
ret i64 %26
}

LLVM IR (-O2):
define i64 @section_start() {
%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 %16, label %8
8: ; preds = %0
%9 = call i32 (...) @mgetuleb128()
%10 = call i32 @mputuleb128(i32 %9)
%11 = call i64 (...) @msynch()
%12 = load i64, i64* %1
%13 = load i64, i64* %2
%14 = call i64 @msetsize(i64 %12, i64 %13, i64 %11)
%15 = add nsw i64 %14, %11
br label %16
16: ; preds = %0, %8
%17 = phi i64 [ %15, %8 ], [ %7, %0 ]
ret i64 %17
}