#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*/ extension_version(unsigned char const *);
int parse_cta(unsigned char const *);
int /*<<< orphan*/ parse_displayid(unsigned char const *);
int parse_extension(const unsigned char *x) {
  int conformant_extension;
  (void)("\n");
  switch (x[0]) {
  case 0x02:
    (void)("CTA extension block\n");
    extension_version(x);
    conformant_extension = parse_cta(x);
    break;
  case 0x10:
    (void)("VTB extension block\n");
    break;
  case 0x40:
    (void)("DI extension block\n");
    break;
  case 0x50:
    (void)("LS extension block\n");
    break;
  case 0x60:
    (void)("DPVL extension block\n");
    break;
  case 0x70:
    (void)("DisplayID extension block\n");
    extension_version(x);
    parse_displayid(x);
    break;
  case 0xF0:
    (void)("Block map\n");
    break;
  case 0xFF:
    (void)("Manufacturer-specific extension block\n");
  default:
    (void)("Unknown extension block\n");
    break;
  }
  (void)("\n");
  return conformant_extension;
}


x86 assembly (clang, -O0):
<parse_extension>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
mov    %eax,-0x10(%rbp)
sub    $0x2,%eax
je     11cf <parse_extension+0x9f>
jmp    1154 <parse_extension+0x24>
mov    -0x10(%rbp),%eax
sub    $0x10,%eax
je     11e9 <parse_extension+0xb9>
jmp    1165 <parse_extension+0x35>
mov    -0x10(%rbp),%eax
sub    $0x40,%eax
je     11ee <parse_extension+0xbe>
jmp    1176 <parse_extension+0x46>
mov    -0x10(%rbp),%eax
sub    $0x50,%eax
je     11f3 <parse_extension+0xc3>
jmp    1187 <parse_extension+0x57>
mov    -0x10(%rbp),%eax
sub    $0x60,%eax
je     11f8 <parse_extension+0xc8>
jmp    1198 <parse_extension+0x68>
mov    -0x10(%rbp),%eax
sub    $0x70,%eax
je     11fd <parse_extension+0xcd>
jmp    11a9 <parse_extension+0x79>
mov    -0x10(%rbp),%eax
sub    $0xf0,%eax
je     1214 <parse_extension+0xe4>
jmp    11bc <parse_extension+0x8c>
mov    -0x10(%rbp),%eax
sub    $0xff,%eax
je     1219 <parse_extension+0xe9>
jmp    121e <parse_extension+0xee>
mov    -0x8(%rbp),%rdi
call   1040 <extension_version@plt>
mov    -0x8(%rbp),%rdi
call   1050 <parse_cta@plt>
mov    %eax,-0xc(%rbp)
jmp    1223 <parse_extension+0xf3>
jmp    1223 <parse_extension+0xf3>
jmp    1223 <parse_extension+0xf3>
jmp    1223 <parse_extension+0xf3>
jmp    1223 <parse_extension+0xf3>
mov    -0x8(%rbp),%rdi
call   1040 <extension_version@plt>
mov    -0x8(%rbp),%rdi
call   1030 <parse_displayid@plt>
jmp    1223 <parse_extension+0xf3>
jmp    1223 <parse_extension+0xf3>
jmp    121e <parse_extension+0xee>
jmp    1223 <parse_extension+0xf3>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_extension>:
push   %rbx
mov    %rdi,%rbx
mov    (%rdi),%al
cmp    $0x70,%al
je     114f <parse_extension+0x1f>
cmp    $0x2,%al
jne    115f <parse_extension+0x2f>
mov    %rbx,%rdi
call   1040 <extension_version@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1050 <parse_cta@plt>
mov    %rbx,%rdi
call   1040 <extension_version@plt>
mov    %rbx,%rdi
call   1030 <parse_displayid@plt>
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [21 x i8] c"CTA extension block\0A\00"
@.str.2 = [21 x i8] c"VTB extension block\0A\00"
@.str.3 = [20 x i8] c"DI extension block\0A\00"
@.str.4 = [20 x i8] c"LS extension block\0A\00"
@.str.5 = [22 x i8] c"DPVL extension block\0A\00"
@.str.6 = [27 x i8] c"DisplayID extension block\0A\00"
@.str.7 = [11 x i8] c"Block map\0A\00"
@.str.8 = [39 x i8] c"Manufacturer-specific extension block\0A\00"
@.str.9 = [25 x i8] c"Unknown extension block\0A\00"
define i32 @parse_extension(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = getelementptr inbounds i8, i8* %4, i64 0
%6 = load i8, i8* %5
%7 = zext i8 %6 to i32
switch i32 %7, label %24 [
i32 2, label %8
i32 16, label %13
i32 64, label %14
i32 80, label %15
i32 96, label %16
i32 112, label %17
i32 240, label %22
i32 255, label %23
]
8: ; preds = %1
%9 = load i8*, i8** %2
%10 = call i32 @extension_version(i8* %9)
%11 = load i8*, i8** %2
%12 = call i32 @parse_cta(i8* %11)
store i32 %12, i32* %3
br label %25
13: ; preds = %1
br label %25
14: ; preds = %1
br label %25
15: ; preds = %1
br label %25
16: ; preds = %1
br label %25
17: ; preds = %1
%18 = load i8*, i8** %2
%19 = call i32 @extension_version(i8* %18)
%20 = load i8*, i8** %2
%21 = call i32 @parse_displayid(i8* %20)
br label %25
22: ; preds = %1
br label %25
23: ; preds = %1
br label %24
24: ; preds = %1, %23
br label %25
25: ; preds = %24, %22, %17, %16, %15, %14, %13, %8
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
define i32 @parse_extension(i8* %0) {
%2 = load i8, i8* %0
switch i8 %2, label %9 [
i8 2, label %3
i8 112, label %6
]
3: ; preds = %1
%4 = tail call i32 @extension_version(i8* %0)
%5 = tail call i32 @parse_cta(i8* %0)
br label %9
6: ; preds = %1
%7 = tail call i32 @extension_version(i8* %0)
%8 = tail call i32 @parse_displayid(i8* %0)
br label %9
9: ; preds = %1, %6, %3
%10 = phi i32 [ undef, %1 ], [ undef, %6 ], [ %5, %3 ]
ret i32 %10
}