#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 mgetuleb128();
int /*<<< orphan*/ mputuleb128(unsigned long);
scalar_t__ msynch();
long elem_segment() {
  unsigned long count;
  long delta = 0;
  mputuleb128(mgetuleb128());
  delta += msynch();
  delta += init_expr();
  mputuleb128(count = mgetuleb128());
  delta += msynch();
  while (count--) {
    mputuleb128(mgetuleb128());
    delta += msynch();
  }
  return delta;
}


x86 assembly (clang, -O0):
<elem_segment>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movq   $0x0,-0x10(%rbp)
mov    $0x0,%al
call   1030 <mgetuleb128@plt>
mov    %rax,%rdi
call   1040 <mputuleb128@plt>
mov    $0x0,%al
call   1060 <msynch@plt>
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1050 <init_expr@plt>
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1030 <mgetuleb128@plt>
mov    %rax,%rdi
mov    %rdi,-0x8(%rbp)
call   1040 <mputuleb128@plt>
mov    $0x0,%al
call   1060 <msynch@plt>
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x8(%rbp)
cmp    $0x0,%rax
je     11db <elem_segment+0x9b>
mov    $0x0,%al
call   1030 <mgetuleb128@plt>
mov    %rax,%rdi
call   1040 <mputuleb128@plt>
mov    $0x0,%al
call   1060 <msynch@plt>
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
jmp    119f <elem_segment+0x5f>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<elem_segment>:
push   %r15
push   %r14
push   %rbx
xor    %eax,%eax
call   1030 <mgetuleb128@plt>
mov    %rax,%rdi
call   1040 <mputuleb128@plt>
xor    %eax,%eax
call   1060 <msynch@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1050 <init_expr@plt>
mov    %rax,%r15
add    %rbx,%r15
xor    %eax,%eax
call   1030 <mgetuleb128@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1040 <mputuleb128@plt>
xor    %eax,%eax
call   1060 <msynch@plt>
mov    %rax,%rbx
add    %r15,%rbx
test   %r14,%r14
je     11af <elem_segment+0x6f>
nop
xor    %eax,%eax
call   1030 <mgetuleb128@plt>
mov    %rax,%rdi
call   1040 <mputuleb128@plt>
xor    %eax,%eax
call   1060 <msynch@plt>
add    %rax,%rbx
add    $0xffffffffffffffff,%r14
jne    1190 <elem_segment+0x50>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i64 @elem_segment() {
%1 = tail call i64 (...) @mgetuleb128()
%2 = tail call i32 @mputuleb128(i64 %1)
%3 = tail call i64 (...) @msynch()
%4 = tail call i64 (...) @init_expr()
%5 = add nsw i64 %4, %3
%6 = tail call i64 (...) @mgetuleb128()
%7 = tail call i32 @mputuleb128(i64 %6)
%8 = tail call i64 (...) @msynch()
%9 = add nsw i64 %5, %8
%10 = icmp eq i64 %6, 0
br i1 %10, label %20, label %11
11: ; preds = %0, %11
%12 = phi i64 [ %18, %11 ], [ %9, %0 ]
%13 = phi i64 [ %14, %11 ], [ %6, %0 ]
%14 = add i64 %13, -1
%15 = tail call i64 (...) @mgetuleb128()
%16 = tail call i32 @mputuleb128(i64 %15)
%17 = tail call i64 (...) @msynch()
%18 = add nsw i64 %17, %12
%19 = icmp eq i64 %14, 0
br i1 %19, label %20, label %11
20: ; preds = %11, %0
%21 = phi i64 [ %9, %0 ], [ %18, %11 ]
ret i64 %21
}