#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*/ printf(char *, unsigned int, unsigned int, char *);
int /*<<< orphan*/ sprintf(char *, char *, unsigned int);
int /*<<< orphan*/ strcpy(char *, char *);
void show_task(int port, unsigned data) {
  unsigned code = data >> 16;
  char buf[16];
  switch (code) {
  case 0:
    strcpy(buf, "run");
    break;
  case 1:
    strcpy(buf, "block");
    break;
  case 2:
    strcpy(buf, "create");
    break;
  case 3:
    strcpy(buf, "destroy");
    break;
  default:
    sprintf(buf, "code %d", code);
    break;
  }
  printf("TASK %d, pri %d: %s", (data >> 0) & 0xff, (data >> 8) & 0xff, buf);
}


x86 assembly (clang, -O0):
<show_task>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movzwl -0x6(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %rax,-0x28(%rbp)
sub    $0x3,%rax
ja     11be <show_task+0x8e>
mov    -0x28(%rbp),%rax
lea    0xe9f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    -0x20(%rbp),%rdi
lea    0xe9b(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11d1 <show_task+0xa1>
lea    -0x20(%rbp),%rdi
lea    0xe8a(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11d1 <show_task+0xa1>
lea    -0x20(%rbp),%rdi
lea    0xe7b(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11d1 <show_task+0xa1>
lea    -0x20(%rbp),%rdi
lea    0xe6d(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11d1 <show_task+0xa1>
lea    -0x20(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xe5d(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x8(%rbp),%esi
shr    $0x0,%esi
and    $0xff,%esi
mov    -0x8(%rbp),%edx
shr    $0x8,%edx
and    $0xff,%edx
lea    -0x20(%rbp),%rcx
lea    0xe3d(%rip),%rdi
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_task>:
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebx
mov    %esi,%edx
shr    $0x10,%edx
cmp    $0x3,%dx
ja     115b <show_task+0x2b>
lea    0xeb7(%rip),%rax
movslq (%rax,%rdx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
lea    0xeb7(%rip),%rsi
jmp    1185 <show_task+0x55>
lea    0xec7(%rip),%rsi
mov    %rsp,%rdi
call   1050 <sprintf@plt>
jmp    118d <show_task+0x5d>
lea    0xea1(%rip),%rsi
jmp    1185 <show_task+0x55>
lea    0xe9e(%rip),%rsi
jmp    1185 <show_task+0x55>
lea    0xe9c(%rip),%rsi
mov    %rsp,%rdi
call   1030 <strcpy@plt>
movzbl %bl,%esi
movzbl %bh,%edx
lea    0xe97(%rip),%rdi
mov    %rsp,%rcx
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"run\00"
@.str.1 = [6 x i8] c"block\00"
@.str.2 = [7 x i8] c"create\00"
@.str.3 = [8 x i8] c"destroy\00"
@.str.4 = [8 x i8] c"code %d\00"
@.str.5 = [20 x i8] c"TASK %d, pri %d: %s\00"
define void @show_task(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [16 x i8]
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
%8 = lshr i32 %7, 16
store i32 %8, i32* %5
%9 = load i32, i32* %5
switch i32 %9, label %22 [
i32 0, label %10
i32 1, label %13
i32 2, label %16
i32 3, label %19
]
10: ; preds = %2
%11 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%12 = call i32 @strcpy(i8* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %26
13: ; preds = %2
%14 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%15 = call i32 @strcpy(i8* %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %26
16: ; preds = %2
%17 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%18 = call i32 @strcpy(i8* %17, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %26
19: ; preds = %2
%20 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%21 = call i32 @strcpy(i8* %20, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %26
22: ; preds = %2
%23 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%24 = load i32, i32* %5
%25 = call i32 @sprintf(i8* %23, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %24)
br label %26
26: ; preds = %22, %19, %16, %13, %10
%27 = load i32, i32* %4
%28 = lshr i32 %27, 0
%29 = and i32 %28, 255
%30 = load i32, i32* %4
%31 = lshr i32 %30, 8
%32 = and i32 %31, 255
%33 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%34 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i32 %29, i32 %32, i8* %33)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"run\00"
@.str.1 = [6 x i8] c"block\00"
@.str.2 = [7 x i8] c"create\00"
@.str.3 = [8 x i8] c"destroy\00"
@.str.4 = [8 x i8] c"code %d\00"
@.str.5 = [20 x i8] c"TASK %d, pri %d: %s\00"
define void @show_task(i32 %0, i32 %1) {
%3 = alloca [16 x i8]
%4 = lshr i32 %1, 16
%5 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%6 = trunc i32 %4 to i16
switch i16 %6, label %15 [
i16 0, label %7
i16 1, label %9
i16 2, label %11
i16 3, label %13
]
7: ; preds = %2
%8 = call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %17
9: ; preds = %2
%10 = call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %17
11: ; preds = %2
%12 = call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %17
13: ; preds = %2
%14 = call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %17
15: ; preds = %2
%16 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %4)
br label %17
17: ; preds = %15, %13, %11, %9, %7
%18 = and i32 %1, 255
%19 = lshr i32 %1, 8
%20 = and i32 %19, 255
%21 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i32 %18, i32 %20, i8* %5)
ret void
}