#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();
int /*<<< orphan*/ mputuleb128(long);
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();
long section_start();
long section_table();
long section_type();
long section(void) {
  long id = mgetuleb128();
  long delta = 0;
  mputuleb128(id);
  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();
    break;
  }
  return delta;
}


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

x86 assembly (clang, -O2):
<section>:
push   %rbx
xor    %eax,%eax
call   1080 <mgetuleb128@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   10d0 <mputuleb128@plt>
cmp    $0xb,%rbx
ja     1269 <section+0x89>
lea    0xe00(%rip),%rax
movslq (%rax,%rbx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
xor    %eax,%eax
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    1100 <section_export@plt>
xor    %eax,%eax
pop    %rbx
jmp    10f0 <section_start@plt>
xor    %eax,%eax
pop    %rbx
jmp    1060 <section_element@plt>
xor    %eax,%eax
pop    %rbx
jmp    10e0 <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() {
%1 = alloca i64
%2 = alloca i64
%3 = call i64 (...) @mgetuleb128()
store i64 %3, i64* %1
store i64 0, i64* %2
%4 = load i64, i64* %1
%5 = call i32 @mputuleb128(i64 %4)
%6 = load i64, i64* %1
switch i64 %6, label %55 [
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 = %0
%8 = call i64 (...) @section_type()
%9 = load i64, i64* %2
%10 = add nsw i64 %9, %8
store i64 %10, i64* %2
br label %55
11: ; preds = %0
%12 = call i64 (...) @section_import()
%13 = load i64, i64* %2
%14 = add nsw i64 %13, %12
store i64 %14, i64* %2
br label %55
15: ; preds = %0
%16 = call i64 (...) @section_function()
%17 = load i64, i64* %2
%18 = add nsw i64 %17, %16
store i64 %18, i64* %2
br label %55
19: ; preds = %0
%20 = call i64 (...) @section_table()
%21 = load i64, i64* %2
%22 = add nsw i64 %21, %20
store i64 %22, i64* %2
br label %55
23: ; preds = %0
%24 = call i64 (...) @section_memory()
%25 = load i64, i64* %2
%26 = add nsw i64 %25, %24
store i64 %26, i64* %2
br label %55
27: ; preds = %0
%28 = call i64 (...) @section_global()
%29 = load i64, i64* %2
%30 = add nsw i64 %29, %28
store i64 %30, i64* %2
br label %55
31: ; preds = %0
%32 = call i64 (...) @section_export()
%33 = load i64, i64* %2
%34 = add nsw i64 %33, %32
store i64 %34, i64* %2
br label %55
35: ; preds = %0
%36 = call i64 (...) @section_start()
%37 = load i64, i64* %2
%38 = add nsw i64 %37, %36
store i64 %38, i64* %2
br label %55
39: ; preds = %0
%40 = call i64 (...) @section_element()
%41 = load i64, i64* %2
%42 = add nsw i64 %41, %40
store i64 %42, i64* %2
br label %55
43: ; preds = %0
%44 = call i64 (...) @section_code()
%45 = load i64, i64* %2
%46 = add nsw i64 %45, %44
store i64 %46, i64* %2
br label %55
47: ; preds = %0
%48 = call i64 (...) @section_data()
%49 = load i64, i64* %2
%50 = add nsw i64 %49, %48
store i64 %50, i64* %2
br label %55
51: ; preds = %0
%52 = call i64 (...) @section_named()
%53 = load i64, i64* %2
%54 = add nsw i64 %53, %52
store i64 %54, i64* %2
br label %55
55: ; preds = %0, %51, %47, %43, %39, %35, %31, %27, %23, %19, %15, %11, %7
%56 = load i64, i64* %2
ret i64 %56
}

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