#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 gob_encode_int(char *, size_t, int);
int gob_encode_unsigned_int(char *, size_t, int);
int gob_start_struct(char *, size_t);
int gob_start_type_definition(char *buf, size_t buf_size, int id, int type) {
  int total_size = 0;
  int num_bytes = 0;
  char *write_ptr = buf;
  num_bytes = gob_start_struct(write_ptr, buf_size);
  write_ptr += num_bytes;
  buf_size -= num_bytes;
  total_size += num_bytes;
  num_bytes = gob_encode_int(write_ptr, buf_size, -1 * id);
  write_ptr += num_bytes;
  buf_size -= num_bytes;
  total_size += num_bytes;
  int type_delta = 0;
  switch (type) {
  case (17):
    type_delta = 1;
    break;
  case (19):
    type_delta = 2;
    break;
  case (20):
  default:
    type_delta = 3;
    break;
  case (23):
    type_delta = 4;
    break;
  }
  num_bytes = gob_encode_unsigned_int(write_ptr, buf_size, type_delta);
  write_ptr += num_bytes;
  buf_size -= num_bytes;
  total_size += num_bytes;
  return total_size;
}


x86 assembly (clang, -O0):
<gob_start_type_definition>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <gob_start_struct@plt>
mov    %eax,-0x20(%rbp)
movslq -0x20(%rbp),%rcx
mov    -0x28(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
movslq -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x20(%rbp),%ecx
mov    -0x1c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
neg    %edx
call   1040 <gob_encode_int@plt>
mov    %eax,-0x20(%rbp)
movslq -0x20(%rbp),%rcx
mov    -0x28(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
movslq -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x20(%rbp),%ecx
mov    -0x1c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x18(%rbp),%eax
add    $0xffffffef,%eax
mov    %eax,%ecx
mov    %rcx,-0x38(%rbp)
sub    $0x6,%eax
ja     1220 <gob_start_type_definition+0xf0>
mov    -0x38(%rbp),%rax
lea    0xe06(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x2c(%rbp)
jmp    1233 <gob_start_type_definition+0x103>
movl   $0x2,-0x2c(%rbp)
jmp    1233 <gob_start_type_definition+0x103>
jmp    1220 <gob_start_type_definition+0xf0>
movl   $0x3,-0x2c(%rbp)
jmp    1233 <gob_start_type_definition+0x103>
movl   $0x4,-0x2c(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x2c(%rbp),%edx
call   1030 <gob_encode_unsigned_int@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
movslq -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x20(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gob_start_type_definition>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %ecx,%r15d
mov    %edx,%r12d
mov    %rsi,%rbx
mov    %rdi,%rbp
call   1050 <gob_start_struct@plt>
mov    %eax,%r14d
cltq
add    %rax,%rbp
sub    %rax,%rbx
neg    %r12d
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r12d,%edx
call   1040 <gob_encode_int@plt>
cltq
add    $0xffffffef,%r15d
mov    $0x3,%edx
cmp    $0x6,%r15d
ja     1183 <gob_start_type_definition+0x53>
movslq %r15d,%rcx
lea    0xe80(%rip),%rdx
mov    (%rdx,%rcx,4),%edx
add    %eax,%r14d
sub    %rax,%rbx
add    %rax,%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1030 <gob_encode_unsigned_int@plt>
add    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @gob_start_type_definition(i8* %0, i64 %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
store i8* %0, i8** %5
store i64 %1, i64* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
%13 = load i8*, i8** %5
store i8* %13, i8** %11
%14 = load i8*, i8** %11
%15 = load i64, i64* %6
%16 = call i32 @gob_start_struct(i8* %14, i64 %15)
store i32 %16, i32* %10
%17 = load i32, i32* %10
%18 = load i8*, i8** %11
%19 = sext i32 %17 to i64
%20 = getelementptr inbounds i8, i8* %18, i64 %19
store i8* %20, i8** %11
%21 = load i32, i32* %10
%22 = sext i32 %21 to i64
%23 = load i64, i64* %6
%24 = sub i64 %23, %22
store i64 %24, i64* %6
%25 = load i32, i32* %10
%26 = load i32, i32* %9
%27 = add nsw i32 %26, %25
store i32 %27, i32* %9
%28 = load i8*, i8** %11
%29 = load i64, i64* %6
%30 = load i32, i32* %7
%31 = mul nsw i32 -1, %30
%32 = call i32 @gob_encode_int(i8* %28, i64 %29, i32 %31)
store i32 %32, i32* %10
%33 = load i32, i32* %10
%34 = load i8*, i8** %11
%35 = sext i32 %33 to i64
%36 = getelementptr inbounds i8, i8* %34, i64 %35
store i8* %36, i8** %11
%37 = load i32, i32* %10
%38 = sext i32 %37 to i64
%39 = load i64, i64* %6
%40 = sub i64 %39, %38
store i64 %40, i64* %6
%41 = load i32, i32* %10
%42 = load i32, i32* %9
%43 = add nsw i32 %42, %41
store i32 %43, i32* %9
store i32 0, i32* %12
%44 = load i32, i32* %8
switch i32 %44, label %48 [
i32 17, label %45
i32 19, label %46
i32 20, label %47
i32 23, label %49
]
45: ; preds = %4
store i32 1, i32* %12
br label %50
46: ; preds = %4
store i32 2, i32* %12
br label %50
47: ; preds = %4
br label %48
48: ; preds = %4, %47
store i32 3, i32* %12
br label %50
49: ; preds = %4
store i32 4, i32* %12
br label %50
50: ; preds = %49, %48, %46, %45
%51 = load i8*, i8** %11
%52 = load i64, i64* %6
%53 = load i32, i32* %12
%54 = call i32 @gob_encode_unsigned_int(i8* %51, i64 %52, i32 %53)
store i32 %54, i32* %10
%55 = load i32, i32* %10
%56 = load i8*, i8** %11
%57 = sext i32 %55 to i64
%58 = getelementptr inbounds i8, i8* %56, i64 %57
store i8* %58, i8** %11
%59 = load i32, i32* %10
%60 = sext i32 %59 to i64
%61 = load i64, i64* %6
%62 = sub i64 %61, %60
store i64 %62, i64* %6
%63 = load i32, i32* %10
%64 = load i32, i32* %9
%65 = add nsw i32 %64, %63
store i32 %65, i32* %9
%66 = load i32, i32* %9
ret i32 %66
}

LLVM IR (-O2):
@switch.table.gob_start_type_definition = [7 x i32] [i32 1, i32 3, i32 2, i32 3, i32 3, i32 3, i32 4]
define i32 @gob_start_type_definition(i8* %0, i64 %1, i32 %2, i32 %3) {
%5 = tail call i32 @gob_start_struct(i8* %0, i64 %1)
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds i8, i8* %0, i64 %6
%8 = sub i64 %1, %6
%9 = sub nsw i32 0, %2
%10 = tail call i32 @gob_encode_int(i8* %7, i64 %8, i32 %9)
%11 = sext i32 %10 to i64
%12 = add i32 %3, -17
%13 = icmp ult i32 %12, 7
br i1 %13, label %14, label %18
14: ; preds = %4
%15 = sext i32 %12 to i64
%16 = getelementptr inbounds [7 x i32], [7 x i32]* @switch.table.gob_start_type_definition, i64 0, i64 %15
%17 = load i32, i32* %16
br label %18
18: ; preds = %4, %14
%19 = phi i32 [ %17, %14 ], [ 3, %4 ]
%20 = add nsw i32 %10, %5
%21 = sub i64 %8, %11
%22 = getelementptr inbounds i8, i8* %7, i64 %11
%23 = tail call i32 @gob_encode_unsigned_int(i8* %22, i64 %21, i32 %19)
%24 = add nsw i32 %20, %23
ret i32 %24
}