#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 *calloc(int, int /*<<< orphan*/);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strlen(char *);
unsigned char *return_pdu_type_string(unsigned char pdu_type) {
  char *pdu_type_string = NULL;
  char GetRequest[] = {'G', 'e', 't', 'R', 'e', 'q', 'u', 'e', 's', 't', '\0'};
  char GetResponse[] = {'G', 'e', 't', 'R', 'e', 's',
                        'p', 'o', 'n', 's', 'e', '\0'};
  char GetNext[] = {'G', 'e', 't', 'N', 'e', 'x', 't', '\0'};
  char SetRequest[] = {'S', 'e', 't', 'R', 'e', 'q', 'u', 'e', 's', 't', '\0'};
  char Error[] = {'w', 'r', 'o', 'n', 'g', 0x20, 'P', 'D', 'U', '\0'};
  switch (pdu_type) {
  case 0xA0:
    pdu_type_string = calloc(1, strlen(GetRequest) + 1);
    strcpy(pdu_type_string, GetRequest);
    break;
  case 0xA1:
    pdu_type_string = calloc(1, strlen(GetNext) + 1);
    strcpy(pdu_type_string, GetNext);
    break;
  case 0xA2:
    pdu_type_string = calloc(1, strlen(GetResponse) + 1);
    strcpy(pdu_type_string, GetResponse);
    break;
  case 0xA3:
    pdu_type_string = calloc(1, strlen(SetRequest) + 1);
    strcpy(pdu_type_string, SetRequest);
    break;
  default:
    pdu_type_string = calloc(1, strlen(Error) + 1);
    strcpy(pdu_type_string, Error);
    break;
  }
  return (unsigned char *)pdu_type_string;
}


x86 assembly (clang, -O0):
<return_pdu_type_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movq   $0x0,-0x10(%rbp)
movabs $0x6575716552746547,%rax
71 75 65
mov    %rax,-0x20(%rbp)
movl   $0x747365,-0x19(%rbp)
movabs $0x6f70736552746547,%rax
73 70 6f
mov    %rax,-0x30(%rbp)
movl   $0x65736e,-0x28(%rbp)
movabs $0x7478654e746547,%rax
mov    %rax,-0x38(%rbp)
movabs $0x6575716552746553,%rax
71 75 65
mov    %rax,-0x48(%rbp)
movl   $0x747365,-0x41(%rbp)
movabs $0x445020676e6f7277,%rax
20 50 44
mov    %rax,-0x58(%rbp)
movw   $0x55,-0x50(%rbp)
movzbl -0x1(%rbp),%eax
add    $0xffffff60,%eax
mov    %eax,%ecx
mov    %rcx,-0x60(%rbp)
sub    $0x3,%eax
ja     128b <return_pdu_type_string+0x15b>
mov    -0x60(%rbp),%rax
lea    0xe36(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%esi
add    $0x1,%esi
mov    $0x1,%edi
call   1050 <calloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    12b4 <return_pdu_type_string+0x184>
lea    -0x38(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%esi
add    $0x1,%esi
mov    $0x1,%edi
call   1050 <calloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    12b4 <return_pdu_type_string+0x184>
lea    -0x30(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%esi
add    $0x1,%esi
mov    $0x1,%edi
call   1050 <calloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    12b4 <return_pdu_type_string+0x184>
lea    -0x48(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%esi
add    $0x1,%esi
mov    $0x1,%edi
call   1050 <calloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x48(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    12b4 <return_pdu_type_string+0x184>
lea    -0x58(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%esi
add    $0x1,%esi
mov    $0x1,%edi
call   1050 <calloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x58(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<return_pdu_type_string>:
push   %r14
push   %rbx
sub    $0x48,%rsp
movabs $0x6575716552746547,%rax
71 75 65
mov    %rax,0x20(%rsp)
movl   $0x747365,0x27(%rsp)
movabs $0x6f70736552746547,%rax
73 70 6f
mov    %rax,0x38(%rsp)
movl   $0x65736e,0x40(%rsp)
movabs $0x7478654e746547,%rax
mov    %rax,0x30(%rsp)
movabs $0x6575716552746553,%rax
71 75 65
mov    %rax,0x10(%rsp)
movl   $0x747365,0x17(%rsp)
movabs $0x445020676e6f7277,%rax
20 50 44
mov    %rax,(%rsp)
movw   $0x55,0x8(%rsp)
add    $0x60,%dil
cmp    $0x3,%dil
ja     11c5 <return_pdu_type_string+0x95>
movzbl %dil,%eax
lea    0xe4b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0x20(%rsp),%r14
jmp    11dd <return_pdu_type_string+0xad>
mov    %rsp,%r14
jmp    11dd <return_pdu_type_string+0xad>
lea    0x30(%rsp),%r14
jmp    11dd <return_pdu_type_string+0xad>
lea    0x38(%rsp),%r14
jmp    11dd <return_pdu_type_string+0xad>
lea    0x10(%rsp),%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%esi
mov    $0x1,%edi
call   1050 <calloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rax
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.return_pdu_type_string.GetRequest = [11 x i8] c"GetRequest\00"
@__const.return_pdu_type_string.GetResponse = [12 x i8] c"GetResponse\00"
@__const.return_pdu_type_string.GetNext = [8 x i8] c"GetNext\00"
@__const.return_pdu_type_string.SetRequest = [11 x i8] c"SetRequest\00"
@__const.return_pdu_type_string.Error = [10 x i8] c"wrong PDU\00"
define i8* @return_pdu_type_string(i8 zeroext %0) {
%2 = alloca i8
%3 = alloca i8*
%4 = alloca [11 x i8]
%5 = alloca [12 x i8]
%6 = alloca [8 x i8]
%7 = alloca [11 x i8]
%8 = alloca [10 x i8]
store i8 %0, i8* %2
store i8* null, i8** %3
%9 = bitcast [11 x i8]* %4 to i8*
%10 = bitcast [12 x i8]* %5 to i8*
%11 = bitcast [8 x i8]* %6 to i8*
%12 = bitcast [11 x i8]* %7 to i8*
%13 = bitcast [10 x i8]* %8 to i8*
%14 = load i8, i8* %2
%15 = zext i8 %14 to i32
switch i32 %15, label %48 [
i32 160, label %16
i32 161, label %24
i32 162, label %32
i32 163, label %40
]
16: ; preds = %1
%17 = getelementptr inbounds [11 x i8], [11 x i8]* %4, i64 0, i64 0
%18 = call i32 @strlen(i8* %17)
%19 = add nsw i32 %18, 1
%20 = call i8* @calloc(i32 1, i32 %19)
store i8* %20, i8** %3
%21 = load i8*, i8** %3
%22 = getelementptr inbounds [11 x i8], [11 x i8]* %4, i64 0, i64 0
%23 = call i32 @strcpy(i8* %21, i8* %22)
br label %56
24: ; preds = %1
%25 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
%26 = call i32 @strlen(i8* %25)
%27 = add nsw i32 %26, 1
%28 = call i8* @calloc(i32 1, i32 %27)
store i8* %28, i8** %3
%29 = load i8*, i8** %3
%30 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
%31 = call i32 @strcpy(i8* %29, i8* %30)
br label %56
32: ; preds = %1
%33 = getelementptr inbounds [12 x i8], [12 x i8]* %5, i64 0, i64 0
%34 = call i32 @strlen(i8* %33)
%35 = add nsw i32 %34, 1
%36 = call i8* @calloc(i32 1, i32 %35)
store i8* %36, i8** %3
%37 = load i8*, i8** %3
%38 = getelementptr inbounds [12 x i8], [12 x i8]* %5, i64 0, i64 0
%39 = call i32 @strcpy(i8* %37, i8* %38)
br label %56
40: ; preds = %1
%41 = getelementptr inbounds [11 x i8], [11 x i8]* %7, i64 0, i64 0
%42 = call i32 @strlen(i8* %41)
%43 = add nsw i32 %42, 1
%44 = call i8* @calloc(i32 1, i32 %43)
store i8* %44, i8** %3
%45 = load i8*, i8** %3
%46 = getelementptr inbounds [11 x i8], [11 x i8]* %7, i64 0, i64 0
%47 = call i32 @strcpy(i8* %45, i8* %46)
br label %56
48: ; preds = %1
%49 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 0
%50 = call i32 @strlen(i8* %49)
%51 = add nsw i32 %50, 1
%52 = call i8* @calloc(i32 1, i32 %51)
store i8* %52, i8** %3
%53 = load i8*, i8** %3
%54 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 0
%55 = call i32 @strcpy(i8* %53, i8* %54)
br label %56
56: ; preds = %48, %40, %32, %24, %16
%57 = load i8*, i8** %3
ret i8* %57
}

LLVM IR (-O2):
@__const.return_pdu_type_string.GetRequest = [11 x i8] c"GetRequest\00"
@__const.return_pdu_type_string.GetResponse = [12 x i8] c"GetResponse\00"
@__const.return_pdu_type_string.SetRequest = [11 x i8] c"SetRequest\00"
@__const.return_pdu_type_string.Error = [10 x i8] c"wrong PDU\00"
define i8* @return_pdu_type_string(i8 zeroext %0) {
%2 = alloca [11 x i8]
%3 = alloca [12 x i8]
%4 = alloca i64
%5 = alloca [11 x i8]
%6 = alloca [10 x i8]
%7 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 0
%8 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 0
%9 = bitcast i64* %4 to i8*
store i64 32783473801717063, i64* %4
%10 = getelementptr inbounds [11 x i8], [11 x i8]* %5, i64 0, i64 0
%11 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
switch i8 %0, label %32 [
i8 -96, label %12
i8 -95, label %17
i8 -94, label %22
i8 -93, label %27
]
12: ; preds = %1
%13 = call i32 @strlen(i8* %7)
%14 = add nsw i32 %13, 1
%15 = call i8* @calloc(i32 1, i32 %14)
%16 = call i32 @strcpy(i8* %15, i8* %7)
br label %37
17: ; preds = %1
%18 = call i32 @strlen(i8* %9)
%19 = add nsw i32 %18, 1
%20 = call i8* @calloc(i32 1, i32 %19)
%21 = call i32 @strcpy(i8* %20, i8* %9)
br label %37
22: ; preds = %1
%23 = call i32 @strlen(i8* %8)
%24 = add nsw i32 %23, 1
%25 = call i8* @calloc(i32 1, i32 %24)
%26 = call i32 @strcpy(i8* %25, i8* %8)
br label %37
27: ; preds = %1
%28 = call i32 @strlen(i8* %10)
%29 = add nsw i32 %28, 1
%30 = call i8* @calloc(i32 1, i32 %29)
%31 = call i32 @strcpy(i8* %30, i8* %10)
br label %37
32: ; preds = %1
%33 = call i32 @strlen(i8* %11)
%34 = add nsw i32 %33, 1
%35 = call i8* @calloc(i32 1, i32 %34)
%36 = call i32 @strcpy(i8* %35, i8* %11)
br label %37
37: ; preds = %32, %27, %22, %17, %12
%38 = phi i8* [ %35, %32 ], [ %30, %27 ], [ %25, %22 ], [ %20, %17 ], [ %15, %12 ]
ret i8* %38
}