#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 initdb();
int /*<<< orphan*/ printf(char *);
void init_task() {
  printf("Initializing Prism...\n");
  switch (initdb()) {
  case -2:
    printf("  ERR: already initialized\n");
    break;
  case -3:
    printf("  ERR: permissions error\n");
    break;
  case -1:
    printf("  ERR: general error\n");
    break;
  default:
    printf("  OK: initialized\n");
  }
}


x86 assembly (clang, -O0):
<init_task>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1030 <initdb@plt>
mov    %eax,%ecx
mov    %ecx,-0x4(%rbp)
sub    $0xfffffffd,%eax
je     1181 <init_task+0x61>
jmp    114e <init_task+0x2e>
mov    -0x4(%rbp),%eax
sub    $0xfffffffe,%eax
je     1170 <init_task+0x50>
jmp    115f <init_task+0x3f>
mov    -0x4(%rbp),%eax
sub    $0xffffffff,%eax
je     1192 <init_task+0x72>
jmp    11a3 <init_task+0x83>
lea    0xea0(%rip),%rdi
call   1040 <printf@plt>
jmp    11af <init_task+0x8f>
lea    0xeab(%rip),%rdi
call   1040 <printf@plt>
jmp    11af <init_task+0x8f>
lea    0xeb4(%rip),%rdi
call   1040 <printf@plt>
jmp    11af <init_task+0x8f>
lea    0xeb9(%rip),%rdi
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_task>:
push   %rax
lea    0xed8(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <initdb@plt>
cmp    $0xfffffffd,%eax
jb     1152 <init_task+0x32>
add    $0x3,%eax
cltq
lea    0xf2f(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
pop    %rax
jmp    1030 <puts@plt>
lea    0xf06(%rip),%rdi
pop    %rax
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"Initializing Prism...\0A\00"
@.str.1 = [28 x i8] c" ERR: already initialized\0A\00"
@.str.2 = [26 x i8] c" ERR: permissions error\0A\00"
@.str.3 = [22 x i8] c" ERR: general error\0A\00"
@.str.4 = [19 x i8] c" OK: initialized\0A\00"
define void @init_task() {
%1 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%2 = call i32 (...) @initdb()
switch i32 %2, label %9 [
i32 -2, label %3
i32 -3, label %5
i32 -1, label %7
]
3: ; preds = %0
%4 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
br label %11
5: ; preds = %0
%6 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %11
7: ; preds = %0
%8 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
br label %11
9: ; preds = %0
%10 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
br label %11
11: ; preds = %9, %7, %5, %3
ret void
}

LLVM IR (-O2):
@str = [22 x i8] c"Initializing Prism...\00"
@str.5 = [21 x i8] c" ERR: general error\00"
@str.6 = [25 x i8] c" ERR: permissions error\00"
@str.7 = [27 x i8] c" ERR: already initialized\00"
@str.8 = [18 x i8] c" OK: initialized\00"
@reltable.init_task = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([25 x i8]* @str.6 to i64), i64 ptrtoint ([3 x i32]* @reltable.init_task to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([27 x i8]* @str.7 to i64), i64 ptrtoint ([3 x i32]* @reltable.init_task to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([21 x i8]* @str.5 to i64), i64 ptrtoint ([3 x i32]* @reltable.init_task to i64)) to i32)]
define void @init_task() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 (...) @initdb()
%3 = icmp ugt i32 %2, -4
br i1 %3, label %4, label %9
4: ; preds = %0
%5 = add i32 %2, 3
%6 = sext i32 %5 to i64
%7 = shl i64 %6, 2
%8 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.init_task to i8*), i64 %7)
br label %9
9: ; preds = %0, %4
%10 = phi i8* [ %8, %4 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @str.8, i64 0, i64 0), %0 ]
%11 = tail call i32 @puts(i8* dereferenceable(1) %10)
ret void
}