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


x86 assembly (clang, -O0):
<section_global>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movq   $0x0,-0x28(%rbp)
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1030 <mgetsize@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     121e <section_global+0xbe>
mov    $0x0,%al
call   1080 <msynch@plt>
mov    $0x0,%al
call   1050 <mgetuleb128@plt>
mov    %rax,%rdi
mov    %rdi,-0x20(%rbp)
call   1060 <mputuleb128@plt>
mov    $0x0,%al
call   1080 <msynch@plt>
add    -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x20(%rbp)
cmp    $0x0,%rax
je     1200 <section_global+0xa0>
mov    $0x0,%al
call   1050 <mgetuleb128@plt>
mov    %rax,%rdi
call   1060 <mputuleb128@plt>
mov    $0x0,%al
call   1080 <msynch@plt>
add    -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   1070 <init_expr@plt>
add    -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    11b5 <section_global+0x55>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1040 <msetsize@plt>
add    -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    122d <section_global+0xcd>
mov    $0x0,%al
call   1080 <msynch@plt>
add    -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<section_global>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0x8(%rsp),%rdi
mov    %rsp,%rsi
call   1030 <mgetsize@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1080 <msynch@plt>
test   %rbx,%rbx
je     11f3 <section_global+0x93>
xor    %eax,%eax
call   1050 <mgetuleb128@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1060 <mputuleb128@plt>
xor    %eax,%eax
call   1080 <msynch@plt>
mov    %rax,%rbx
test   %r14,%r14
je     11df <section_global+0x7f>
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <mgetuleb128@plt>
mov    %rax,%rdi
call   1060 <mputuleb128@plt>
xor    %eax,%eax
call   1080 <msynch@plt>
mov    %rax,%r15
add    %rbx,%r15
xor    %eax,%eax
call   1070 <init_expr@plt>
mov    %rax,%rbx
add    %r15,%rbx
add    $0xffffffffffffffff,%r14
jne    11b0 <section_global+0x50>
mov    0x8(%rsp),%rdi
mov    (%rsp),%rsi
mov    %rbx,%rdx
call   1040 <msetsize@plt>
add    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @section_global() {
%1 = alloca i64
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
store i64 0, i64* %5
%6 = call i64 @mgetsize(i64* %1, i64* %2)
store i64 %6, i64* %3
%7 = load i64, i64* %3
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %36
9: ; preds = %0
%10 = call i64 (...) @msynch()
%11 = call i64 (...) @mgetuleb128()
store i64 %11, i64* %4
%12 = call i32 @mputuleb128(i64 %11)
%13 = call i64 (...) @msynch()
%14 = load i64, i64* %5
%15 = add nsw i64 %14, %13
store i64 %15, i64* %5
br label %16
16: ; preds = %20, %9
%17 = load i64, i64* %4
%18 = add i64 %17, -1
store i64 %18, i64* %4
%19 = icmp ne i64 %17, 0
br i1 %19, label %20, label %29
20: ; preds = %16
%21 = call i64 (...) @mgetuleb128()
%22 = call i32 @mputuleb128(i64 %21)
%23 = call i64 (...) @msynch()
%24 = load i64, i64* %5
%25 = add nsw i64 %24, %23
store i64 %25, i64* %5
%26 = call i64 (...) @init_expr()
%27 = load i64, i64* %5
%28 = add nsw i64 %27, %26
store i64 %28, i64* %5
br label %16
29: ; preds = %16
%30 = load i64, i64* %1
%31 = load i64, i64* %2
%32 = load i64, i64* %5
%33 = call i64 @msetsize(i64 %30, i64 %31, i64 %32)
%34 = load i64, i64* %5
%35 = add nsw i64 %34, %33
store i64 %35, i64* %5
br label %40
36: ; preds = %0
%37 = call i64 (...) @msynch()
%38 = load i64, i64* %5
%39 = add nsw i64 %38, %37
store i64 %39, i64* %5
br label %40
40: ; preds = %36, %29
%41 = load i64, i64* %5
ret i64 %41
}

LLVM IR (-O2):
define i64 @section_global() {
%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 %30, label %8
8: ; preds = %0
%9 = call i64 (...) @mgetuleb128()
%10 = call i32 @mputuleb128(i64 %9)
%11 = call i64 (...) @msynch()
%12 = icmp eq i64 %9, 0
br i1 %12, label %24, label %13
13: ; preds = %8, %13
%14 = phi i64 [ %22, %13 ], [ %11, %8 ]
%15 = phi i64 [ %16, %13 ], [ %9, %8 ]
%16 = add i64 %15, -1
%17 = call i64 (...) @mgetuleb128()
%18 = call i32 @mputuleb128(i64 %17)
%19 = call i64 (...) @msynch()
%20 = add nsw i64 %19, %14
%21 = call i64 (...) @init_expr()
%22 = add nsw i64 %20, %21
%23 = icmp eq i64 %16, 0
br i1 %23, label %24, label %13
24: ; preds = %13, %8
%25 = phi i64 [ %11, %8 ], [ %22, %13 ]
%26 = load i64, i64* %1
%27 = load i64, i64* %2
%28 = call i64 @msetsize(i64 %26, i64 %27, i64 %25)
%29 = add nsw i64 %28, %25
br label %30
30: ; preds = %0, %24
%31 = phi i64 [ %29, %24 ], [ %7, %0 ]
ret i64 %31
}