#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*/ mgetstring();
void *mgetuleb128();
int /*<<< orphan*/ mputstring(int /*<<< orphan*/);
int /*<<< orphan*/ mputuleb128(long);
scalar_t__ msynch();
long section_name(long len) {
  unsigned long off0, off1;
  unsigned long count;
  long delta = 0;
  long lcount = 0;
  if (len) {
    mputuleb128(count = mgetuleb128());
    delta += msynch();
    while (count--) {
      mputstring(mgetstring());
      mputuleb128(lcount = mgetuleb128());
      while (lcount--)
        mputstring(mgetstring());
      delta += msynch();
    }
  } else {
    delta += msynch();
  }
  return delta;
}


x86 assembly (clang, -O0):
<section_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1218 <section_name+0xc8>
mov    $0x0,%al
call   1040 <mgetuleb128@plt>
mov    %rax,%rdi
mov    %rdi,-0x20(%rbp)
call   1050 <mputuleb128@plt>
mov    $0x0,%al
call   1060 <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     1213 <section_name+0xc3>
mov    $0x0,%al
call   1070 <mgetstring@plt>
mov    %eax,%edi
call   1030 <mputstring@plt>
mov    $0x0,%al
call   1040 <mgetuleb128@plt>
mov    %rax,%rdi
mov    %rdi,-0x30(%rbp)
call   1050 <mputuleb128@plt>
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x30(%rbp)
cmp    $0x0,%rax
je     11ff <section_name+0xaf>
mov    $0x0,%al
call   1070 <mgetstring@plt>
mov    %eax,%edi
call   1030 <mputstring@plt>
jmp    11d3 <section_name+0x83>
mov    $0x0,%al
call   1060 <msynch@plt>
add    -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    1199 <section_name+0x49>
jmp    1227 <section_name+0xd7>
mov    $0x0,%al
call   1060 <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_name>:
test   %rdi,%rdi
je     11df <section_name+0x8f>
push   %r15
push   %r14
push   %rbx
xor    %eax,%eax
call   1040 <mgetuleb128@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1050 <mputuleb128@plt>
xor    %eax,%eax
call   1060 <msynch@plt>
mov    %rax,%r15
jmp    118a <section_name+0x3a>
nopl   0x0(%rax)
xor    %eax,%eax
call   1060 <msynch@plt>
add    %rax,%r15
test   %r14,%r14
je     11d6 <section_name+0x86>
add    $0xffffffffffffffff,%r14
xor    %eax,%eax
call   1070 <mgetstring@plt>
mov    %eax,%edi
call   1030 <mputstring@plt>
xor    %eax,%eax
call   1040 <mgetuleb128@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <mputuleb128@plt>
test   %rbx,%rbx
je     1180 <section_name+0x30>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <mgetstring@plt>
mov    %eax,%edi
call   1030 <mputstring@plt>
add    $0xffffffffffffffff,%rbx
jne    11c0 <section_name+0x70>
jmp    1180 <section_name+0x30>
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret
xor    %eax,%eax
jmp    1060 <msynch@plt>

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

LLVM IR (-O2):
define i64 @section_name(i64 %0) {
%2 = icmp eq i64 %0, 0
br i1 %2, label %29, label %3
3: ; preds = %1
%4 = tail call i8* (...) @mgetuleb128()
%5 = ptrtoint i8* %4 to i64
%6 = tail call i32 @mputuleb128(i64 %5)
%7 = tail call i64 (...) @msynch()
%8 = icmp eq i8* %4, null
br i1 %8, label %31, label %9
9: ; preds = %3, %25
%10 = phi i64 [ %12, %25 ], [ %5, %3 ]
%11 = phi i64 [ %27, %25 ], [ %7, %3 ]
%12 = add i64 %10, -1
%13 = tail call i32 (...) @mgetstring()
%14 = tail call i32 @mputstring(i32 %13)
%15 = tail call i8* (...) @mgetuleb128()
%16 = ptrtoint i8* %15 to i64
%17 = tail call i32 @mputuleb128(i64 %16)
%18 = icmp eq i8* %15, null
br i1 %18, label %25, label %19
19: ; preds = %9, %19
%20 = phi i64 [ %21, %19 ], [ %16, %9 ]
%21 = add nsw i64 %20, -1
%22 = tail call i32 (...) @mgetstring()
%23 = tail call i32 @mputstring(i32 %22)
%24 = icmp eq i64 %21, 0
br i1 %24, label %25, label %19
25: ; preds = %19, %9
%26 = tail call i64 (...) @msynch()
%27 = add nsw i64 %26, %11
%28 = icmp eq i64 %12, 0
br i1 %28, label %31, label %9
29: ; preds = %1
%30 = tail call i64 (...) @msynch()
br label %31
31: ; preds = %25, %3, %29
%32 = phi i64 [ %30, %29 ], [ %7, %3 ], [ %27, %25 ]
ret i64 %32
}