#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 */
char *curdir();
int spawn(char *, char const *);
int launch_module(int i, char *path) {
  char *dir;
  const char *module;
  dir = (path == NULL) ? curdir() : path;
  switch (i) {
  case 0:
    module = "datetime";
    break;
  case 1:
    module = "network";
    break;
  case 2:
    module = "transfer";
    break;
  case 3:
    module = "bluetooth";
    break;
  case 4:
    module = "mem";
    break;
  case 5:
    module = "cpu";
    break;
  case 6:
    module = "gpu";
    break;
  case 7:
    module = "packages";
    break;
  case 8:
    module = "runtime";
    break;
  case 9:
    module = "weather";
    break;
  case 10:
    module = "linux";
    break;
  case 11:
    module = "desktop";
    break;
  case 12:
    module = "music";
    break;
  case 13:
    module = "ups";
    break;
  }
  return spawn(dir, module);
}


x86 assembly (clang, -O0):
<launch_module>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    114a <launch_module+0x2a>
mov    $0x0,%al
call   1030 <curdir@plt>
mov    %rax,-0x28(%rbp)
jmp    1152 <launch_module+0x32>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%eax
mov    %rax,-0x30(%rbp)
sub    $0xd,%rax
ja     125a <launch_module+0x13a>
mov    -0x30(%rbp),%rax
lea    0xe8a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xeb2(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    125a <launch_module+0x13a>
lea    0xeab(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    125a <launch_module+0x13a>
lea    0xea3(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    125a <launch_module+0x13a>
lea    0xe9c(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    125a <launch_module+0x13a>
lea    0xe96(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    125a <launch_module+0x13a>
lea    0xe8a(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    125a <launch_module+0x13a>
lea    0xe7e(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    125a <launch_module+0x13a>
lea    0xe72(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    125a <launch_module+0x13a>
lea    0xe6b(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    125a <launch_module+0x13a>
lea    0xe63(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    125a <launch_module+0x13a>
lea    0xe5b(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    125a <launch_module+0x13a>
lea    0xe51(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    125a <launch_module+0x13a>
lea    0xe49(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    125a <launch_module+0x13a>
lea    0xe3f(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <spawn@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<launch_module>:
push   %rbx
mov    %rsi,%rax
mov    %edi,%ebx
test   %rsi,%rsi
jne    1132 <launch_module+0x12>
xor    %eax,%eax
call   1030 <curdir@plt>
add    $0xffffffff,%ebx
cmp    $0xc,%ebx
ja     114d <launch_module+0x2d>
movslq %ebx,%rcx
lea    0xf20(%rip),%rdx
movslq (%rdx,%rcx,4),%rsi
add    %rdx,%rsi
jmp    1154 <launch_module+0x34>
lea    0xeac(%rip),%rsi
mov    %rax,%rdi
pop    %rbx
jmp    1040 <spawn@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"datetime\00"
@.str.1 = [8 x i8] c"network\00"
@.str.2 = [9 x i8] c"transfer\00"
@.str.3 = [10 x i8] c"bluetooth\00"
@.str.4 = [4 x i8] c"mem\00"
@.str.5 = [4 x i8] c"cpu\00"
@.str.6 = [4 x i8] c"gpu\00"
@.str.7 = [9 x i8] c"packages\00"
@.str.8 = [8 x i8] c"runtime\00"
@.str.9 = [8 x i8] c"weather\00"
@.str.10 = [6 x i8] c"linux\00"
@.str.11 = [8 x i8] c"desktop\00"
@.str.12 = [6 x i8] c"music\00"
@.str.13 = [4 x i8] c"ups\00"
define i32 @launch_module(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i32 %0, i32* %3
store i8* %1, i8** %4
%7 = load i8*, i8** %4
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i8* (...) @curdir()
br label %13
11: ; preds = %2
%12 = load i8*, i8** %4
br label %13
13: ; preds = %11, %9
%14 = phi i8* [ %10, %9 ], [ %12, %11 ]
store i8* %14, i8** %5
%15 = load i32, i32* %3
switch i32 %15, label %30 [
i32 0, label %16
i32 1, label %17
i32 2, label %18
i32 3, label %19
i32 4, label %20
i32 5, label %21
i32 6, label %22
i32 7, label %23
i32 8, label %24
i32 9, label %25
i32 10, label %26
i32 11, label %27
i32 12, label %28
i32 13, label %29
]
16: ; preds = %13
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8** %6
br label %30
17: ; preds = %13
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %6
br label %30
18: ; preds = %13
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8** %6
br label %30
19: ; preds = %13
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8** %6
br label %30
20: ; preds = %13
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8** %6
br label %30
21: ; preds = %13
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8** %6
br label %30
22: ; preds = %13
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8** %6
br label %30
23: ; preds = %13
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8** %6
br label %30
24: ; preds = %13
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8** %6
br label %30
25: ; preds = %13
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0), i8** %6
br label %30
26: ; preds = %13
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i8** %6
br label %30
27: ; preds = %13
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0), i8** %6
br label %30
28: ; preds = %13
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0), i8** %6
br label %30
29: ; preds = %13
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0), i8** %6
br label %30
30: ; preds = %13, %29, %28, %27, %26, %25, %24, %23, %22, %21, %20, %19, %18, %17, %16
%31 = load i8*, i8** %5
%32 = load i8*, i8** %6
%33 = call i32 @spawn(i8* %31, i8* %32)
ret i32 %33
}

LLVM IR (-O2):
@.str = [9 x i8] c"datetime\00"
@.str.1 = [8 x i8] c"network\00"
@.str.2 = [9 x i8] c"transfer\00"
@.str.3 = [10 x i8] c"bluetooth\00"
@.str.4 = [4 x i8] c"mem\00"
@.str.5 = [4 x i8] c"cpu\00"
@.str.6 = [4 x i8] c"gpu\00"
@.str.7 = [9 x i8] c"packages\00"
@.str.8 = [8 x i8] c"runtime\00"
@.str.9 = [8 x i8] c"weather\00"
@.str.10 = [6 x i8] c"linux\00"
@.str.11 = [8 x i8] c"desktop\00"
@.str.12 = [6 x i8] c"music\00"
@.str.13 = [4 x i8] c"ups\00"
@reltable.launch_module = [13 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.1 to i64), i64 ptrtoint ([13 x i32]* @reltable.launch_module to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.2 to i64), i64 ptrtoint ([13 x i32]* @reltable.launch_module to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.3 to i64), i64 ptrtoint ([13 x i32]* @reltable.launch_module to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.4 to i64), i64 ptrtoint ([13 x i32]* @reltable.launch_module to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.5 to i64), i64 ptrtoint ([13 x i32]* @reltable.launch_module to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.6 to i64), i64 ptrtoint ([13 x i32]* @reltable.launch_module to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.7 to i64), i64 ptrtoint ([13 x i32]* @reltable.launch_module to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.8 to i64), i64 ptrtoint ([13 x i32]* @reltable.launch_module to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.9 to i64), i64 ptrtoint ([13 x i32]* @reltable.launch_module to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.10 to i64), i64 ptrtoint ([13 x i32]* @reltable.launch_module to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.11 to i64), i64 ptrtoint ([13 x i32]* @reltable.launch_module to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.12 to i64), i64 ptrtoint ([13 x i32]* @reltable.launch_module to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.13 to i64), i64 ptrtoint ([13 x i32]* @reltable.launch_module to i64)) to i32)]
define i32 @launch_module(i32 %0, i8* %1) {
%3 = icmp eq i8* %1, null
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i8* (...) @curdir()
br label %6
6: ; preds = %2, %4
%7 = phi i8* [ %5, %4 ], [ %1, %2 ]
%8 = add i32 %0, -1
%9 = icmp ult i32 %8, 13
br i1 %9, label %10, label %14
10: ; preds = %6
%11 = sext i32 %8 to i64
%12 = shl i64 %11, 2
%13 = call i8* @llvm.load.relative.i64(i8* bitcast ([13 x i32]* @reltable.launch_module to i8*), i64 %12)
br label %14
14: ; preds = %10, %6
%15 = phi i8* [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), %6 ], [ %13, %10 ]
%16 = tail call i32 @spawn(i8* %7, i8* %15)
ret i32 %16
}