#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 */
long mgetuleb128();
long section_code();
long section_data();
long section_element();
long section_export();
long section_function();
long section_global();
long section_import();
long section_memory();
long section_named(char const *);
long section_start();
long section_table();
long section_type();
long section(const char *name) {
  long id = mgetuleb128();
  long delta = 0;
  switch (id) {
  case 1:
    delta += section_type();
    break;
  case 2:
    delta += section_import();
    break;
  case 3:
    delta += section_function();
    break;
  case 4:
    delta += section_table();
    break;
  case 5:
    delta += section_memory();
    break;
  case 6:
    delta += section_global();
    break;
  case 7:
    delta += section_export();
    break;
  case 8:
    delta += section_start();
    break;
  case 9:
    delta += section_element();
    break;
  case 10:
    delta += section_code();
    break;
  case 11:
    delta += section_data();
    break;
  case 0:
    delta += section_named(name);
    break;
  }
  return delta;
}


x86 assembly (clang, -O0):
<section>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
xor    %eax,%eax
call   1080 <mgetuleb128@plt>
mov    %rax,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
sub    $0xb,%rax
ja     1302 <section+0x132>
mov    -0x20(%rbp),%rax
lea    0xdf4(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   10a0 <section_type@plt>
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    1302 <section+0x132>
mov    $0x0,%al
call   1050 <section_import@plt>
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    1302 <section+0x132>
mov    $0x0,%al
call   1040 <section_function@plt>
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    1302 <section+0x132>
mov    $0x0,%al
call   1030 <section_table@plt>
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    1302 <section+0x132>
mov    $0x0,%al
call   10c0 <section_memory@plt>
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    1302 <section+0x132>
mov    $0x0,%al
call   10b0 <section_global@plt>
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    1302 <section+0x132>
mov    $0x0,%al
call   10f0 <section_export@plt>
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    1302 <section+0x132>
mov    $0x0,%al
call   10e0 <section_start@plt>
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    1302 <section+0x132>
mov    $0x0,%al
call   1060 <section_element@plt>
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    1302 <section+0x132>
mov    $0x0,%al
call   10d0 <section_code@plt>
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    1302 <section+0x132>
mov    $0x0,%al
call   1070 <section_data@plt>
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    1302 <section+0x132>
mov    -0x8(%rbp),%rdi
call   1090 <section_named@plt>
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<section>:
push   %rbx
mov    %rdi,%rbx
xor    %eax,%eax
call   1080 <mgetuleb128@plt>
cmp    $0xb,%rax
ja     1252 <section+0x82>
lea    0xe18(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    %rbx,%rdi
pop    %rbx
jmp    1090 <section_named@plt>
xor    %eax,%eax
pop    %rbx
jmp    10a0 <section_type@plt>
xor    %eax,%eax
pop    %rbx
jmp    1050 <section_import@plt>
xor    %eax,%eax
pop    %rbx
jmp    1040 <section_function@plt>
xor    %eax,%eax
pop    %rbx
jmp    1030 <section_table@plt>
xor    %eax,%eax
pop    %rbx
jmp    10c0 <section_memory@plt>
xor    %eax,%eax
pop    %rbx
jmp    10b0 <section_global@plt>
xor    %eax,%eax
pop    %rbx
jmp    10f0 <section_export@plt>
xor    %eax,%eax
pop    %rbx
jmp    10e0 <section_start@plt>
xor    %eax,%eax
pop    %rbx
jmp    1060 <section_element@plt>
xor    %eax,%eax
pop    %rbx
jmp    10d0 <section_code@plt>
xor    %eax,%eax
pop    %rbx
jmp    1070 <section_data@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i64 @section(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i64
store i8* %0, i8** %2
%5 = call i64 (...) @mgetuleb128()
store i64 %5, i64* %3
store i64 0, i64* %4
%6 = load i64, i64* %3
switch i64 %6, label %56 [
i64 1, label %7
i64 2, label %11
i64 3, label %15
i64 4, label %19
i64 5, label %23
i64 6, label %27
i64 7, label %31
i64 8, label %35
i64 9, label %39
i64 10, label %43
i64 11, label %47
i64 0, label %51
]
7: ; preds = %1
%8 = call i64 (...) @section_type()
%9 = load i64, i64* %4
%10 = add nsw i64 %9, %8
store i64 %10, i64* %4
br label %56
11: ; preds = %1
%12 = call i64 (...) @section_import()
%13 = load i64, i64* %4
%14 = add nsw i64 %13, %12
store i64 %14, i64* %4
br label %56
15: ; preds = %1
%16 = call i64 (...) @section_function()
%17 = load i64, i64* %4
%18 = add nsw i64 %17, %16
store i64 %18, i64* %4
br label %56
19: ; preds = %1
%20 = call i64 (...) @section_table()
%21 = load i64, i64* %4
%22 = add nsw i64 %21, %20
store i64 %22, i64* %4
br label %56
23: ; preds = %1
%24 = call i64 (...) @section_memory()
%25 = load i64, i64* %4
%26 = add nsw i64 %25, %24
store i64 %26, i64* %4
br label %56
27: ; preds = %1
%28 = call i64 (...) @section_global()
%29 = load i64, i64* %4
%30 = add nsw i64 %29, %28
store i64 %30, i64* %4
br label %56
31: ; preds = %1
%32 = call i64 (...) @section_export()
%33 = load i64, i64* %4
%34 = add nsw i64 %33, %32
store i64 %34, i64* %4
br label %56
35: ; preds = %1
%36 = call i64 (...) @section_start()
%37 = load i64, i64* %4
%38 = add nsw i64 %37, %36
store i64 %38, i64* %4
br label %56
39: ; preds = %1
%40 = call i64 (...) @section_element()
%41 = load i64, i64* %4
%42 = add nsw i64 %41, %40
store i64 %42, i64* %4
br label %56
43: ; preds = %1
%44 = call i64 (...) @section_code()
%45 = load i64, i64* %4
%46 = add nsw i64 %45, %44
store i64 %46, i64* %4
br label %56
47: ; preds = %1
%48 = call i64 (...) @section_data()
%49 = load i64, i64* %4
%50 = add nsw i64 %49, %48
store i64 %50, i64* %4
br label %56
51: ; preds = %1
%52 = load i8*, i8** %2
%53 = call i64 @section_named(i8* %52)
%54 = load i64, i64* %4
%55 = add nsw i64 %54, %53
store i64 %55, i64* %4
br label %56
56: ; preds = %1, %51, %47, %43, %39, %35, %31, %27, %23, %19, %15, %11, %7
%57 = load i64, i64* %4
ret i64 %57
}

LLVM IR (-O2):
define i64 @section(i8* %0) {
%2 = tail call i64 (...) @mgetuleb128()
switch i64 %2, label %27 [
i64 1, label %3
i64 2, label %5
i64 3, label %7
i64 4, label %9
i64 5, label %11
i64 6, label %13
i64 7, label %15
i64 8, label %17
i64 9, label %19
i64 10, label %21
i64 11, label %23
i64 0, label %25
]
3: ; preds = %1
%4 = tail call i64 (...) @section_type()
br label %27
5: ; preds = %1
%6 = tail call i64 (...) @section_import()
br label %27
7: ; preds = %1
%8 = tail call i64 (...) @section_function()
br label %27
9: ; preds = %1
%10 = tail call i64 (...) @section_table()
br label %27
11: ; preds = %1
%12 = tail call i64 (...) @section_memory()
br label %27
13: ; preds = %1
%14 = tail call i64 (...) @section_global()
br label %27
15: ; preds = %1
%16 = tail call i64 (...) @section_export()
br label %27
17: ; preds = %1
%18 = tail call i64 (...) @section_start()
br label %27
19: ; preds = %1
%20 = tail call i64 (...) @section_element()
br label %27
21: ; preds = %1
%22 = tail call i64 (...) @section_code()
br label %27
23: ; preds = %1
%24 = tail call i64 (...) @section_data()
br label %27
25: ; preds = %1
%26 = tail call i64 @section_named(i8* %0)
br label %27
27: ; preds = %1, %25, %23, %21, %19, %17, %15, %13, %11, %9, %7, %5, %3
%28 = phi i64 [ 0, %1 ], [ %26, %25 ], [ %24, %23 ], [ %22, %21 ], [ %20, %19 ], [ %18, %17 ], [ %16, %15 ], [ %14, %13 ], [ %12, %11 ], [ %10, %9 ], [ %8, %7 ], [ %6, %5 ], [ %4, %3 ]
ret i64 %28
}