#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*/ VI_active(int);
int /*<<< orphan*/ printi(char *);
int /*<<< orphan*/ printk(char *);
int callback(int n, int type) {
  if (type == 2) {
    switch (n) {
    case 0:
      printi("A muti-task, Graphical Operating System with window support.");
      break;
    case 1:
      printi("A mysterious Operating System.");
      break;
    case 2:
      printi("Another mysterious Operating System.");
      break;
    }
  } else {
    switch (n) {
    case 0:
      printk("Select Ghost Bird OS 0.02(Explorer kernel).\n");
      break;
    case 1:
      printk("Select Dragon 0.40 Beta.\n");
      break;
    case 2:
      printk("Select DolphinOS.\n");
      break;
    }
    VI_active(1);
  }
}


x86 assembly (clang, -O0):
<callback>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x2,-0xc(%rbp)
jne    11b0 <callback+0x80>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
test   %eax,%eax
je     117d <callback+0x4d>
jmp    115b <callback+0x2b>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
je     118e <callback+0x5e>
jmp    116c <callback+0x3c>
mov    -0x10(%rbp),%eax
sub    $0x2,%eax
je     119f <callback+0x6f>
jmp    11ab <callback+0x7b>
lea    0xe7c(%rip),%rdi
call   1030 <printi@plt>
jmp    11ab <callback+0x7b>
lea    0xea8(%rip),%rdi
call   1030 <printi@plt>
jmp    11ab <callback+0x7b>
lea    0xeb6(%rip),%rdi
call   1030 <printi@plt>
jmp    121d <callback+0xed>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
test   %eax,%eax
je     11e5 <callback+0xb5>
jmp    11c3 <callback+0x93>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
je     11f6 <callback+0xc6>
jmp    11d4 <callback+0xa4>
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
je     1207 <callback+0xd7>
jmp    1213 <callback+0xe3>
lea    0xe95(%rip),%rdi
call   1040 <printk@plt>
jmp    1213 <callback+0xe3>
lea    0xeb1(%rip),%rdi
call   1040 <printk@plt>
jmp    1213 <callback+0xe3>
lea    0xeba(%rip),%rdi
call   1040 <printk@plt>
mov    $0x1,%edi
call   1050 <VI_active@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<callback>:
push   %rax
cmp    $0x2,%esi
jne    114d <callback+0x1d>
cmp    $0x2,%edi
je     1174 <callback+0x44>
cmp    $0x1,%edi
je     117d <callback+0x4d>
test   %edi,%edi
jne    1172 <callback+0x42>
lea    0xeb5(%rip),%rdi
jmp    1184 <callback+0x54>
cmp    $0x2,%edi
ja     1168 <callback+0x38>
movslq %edi,%rax
lea    0xf80(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
call   1040 <printk@plt>
mov    $0x1,%edi
call   1050 <VI_active@plt>
pop    %rcx
ret
lea    0xee1(%rip),%rdi
jmp    1184 <callback+0x54>
lea    0xeb9(%rip),%rdi
call   1030 <printi@plt>
pop    %rcx
ret

LLVM IR (-O0):
@.str = [61 x i8] c"A muti-task, Graphical Operating System with window support.\00"
@.str.1 = [31 x i8] c"A mysterious Operating System.\00"
@.str.2 = [37 x i8] c"Another mysterious Operating System.\00"
@.str.3 = [45 x i8] c"Select Ghost Bird OS 0.02(Explorer kernel).\0A\00"
@.str.4 = [26 x i8] c"Select Dragon 0.40 Beta.\0A\00"
@.str.5 = [19 x i8] c"Select DolphinOS.\0A\00"
define i32 @callback(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* %5
%7 = icmp eq i32 %6, 2
br i1 %7, label %8, label %17
8: ; preds = %2
%9 = load i32, i32* %4
switch i32 %9, label %16 [
i32 0, label %10
i32 1, label %12
i32 2, label %14
]
10: ; preds = %8
%11 = call i32 @printi(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0))
br label %16
12: ; preds = %8
%13 = call i32 @printi(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
br label %16
14: ; preds = %8
%15 = call i32 @printi(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
br label %16
16: ; preds = %8, %14, %12, %10
br label %27
17: ; preds = %2
%18 = load i32, i32* %4
switch i32 %18, label %25 [
i32 0, label %19
i32 1, label %21
i32 2, label %23
]
19: ; preds = %17
%20 = call i32 @printk(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0))
br label %25
21: ; preds = %17
%22 = call i32 @printk(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
br label %25
23: ; preds = %17
%24 = call i32 @printk(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
br label %25
25: ; preds = %17, %23, %21, %19
%26 = call i32 @VI_active(i32 1)
br label %27
27: ; preds = %25, %16
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
@.str = [61 x i8] c"A muti-task, Graphical Operating System with window support.\00"
@.str.1 = [31 x i8] c"A mysterious Operating System.\00"
@.str.2 = [37 x i8] c"Another mysterious Operating System.\00"
@.str.3 = [45 x i8] c"Select Ghost Bird OS 0.02(Explorer kernel).\0A\00"
@.str.4 = [26 x i8] c"Select Dragon 0.40 Beta.\0A\00"
@.str.5 = [19 x i8] c"Select DolphinOS.\0A\00"
@reltable.callback = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([45 x i8]* @.str.3 to i64), i64 ptrtoint ([3 x i32]* @reltable.callback to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([26 x i8]* @.str.4 to i64), i64 ptrtoint ([3 x i32]* @reltable.callback to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @.str.5 to i64), i64 ptrtoint ([3 x i32]* @reltable.callback to i64)) to i32)]
define i32 @callback(i32 %0, i32 %1) {
%3 = icmp eq i32 %1, 2
br i1 %3, label %4, label %11
4: ; preds = %2
switch i32 %0, label %20 [
i32 0, label %5
i32 1, label %7
i32 2, label %9
]
5: ; preds = %4
%6 = tail call i32 @printi(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0))
br label %20
7: ; preds = %4
%8 = tail call i32 @printi(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
br label %20
9: ; preds = %4
%10 = tail call i32 @printi(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
br label %20
11: ; preds = %2
%12 = icmp ult i32 %0, 3
br i1 %12, label %13, label %18
13: ; preds = %11
%14 = sext i32 %0 to i64
%15 = shl i64 %14, 2
%16 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.callback to i8*), i64 %15)
%17 = tail call i32 @printk(i8* %16)
br label %18
18: ; preds = %11, %13
%19 = tail call i32 @VI_active(i32 1)
br label %20
20: ; preds = %5, %7, %9, %4, %18
ret i32 undef
}