#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*/ abort();
int /*<<< orphan*/ assert(int);
void *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
void *AllocTmpbuff(char type, int n) {
  assert(n > 0);
  void *buff = NULL;
  switch (type) {
  case 'n':
    buff = NULL;
    break;
  case 'c':
    buff = malloc(n * sizeof(char));
    break;
  case 'i':
  case 'S':
  case 'U':
    buff = malloc(n * sizeof(int));
    break;
  case 's':
  case 'u':
    buff = malloc(n * sizeof(short));
    break;
  case 'f':
    buff = malloc(n * sizeof(float));
    break;
  case 'd':
    buff = malloc(n * sizeof(double));
    break;
  default:
    printf("Unexpected bad type error in AllocTmpbuff (%c)\n", type);
    abort();
    break;
  }
  if ((type != 'n') && (buff == NULL)) {
    printf("Memory Allocation error in AllocTmpbuff\n");
  }
  return (buff);
}


x86 assembly (clang, -O0):
<AllocTmpbuff>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
test   %eax,%eax
setg   %al
movzbl %al,%edi
call   1050 <assert@plt>
movq   $0x0,-0x10(%rbp)
movsbl -0x1(%rbp),%eax
add    $0xffffffad,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x22,%eax
ja     1218 <AllocTmpbuff+0xd8>
mov    -0x18(%rbp),%rax
lea    0xe76(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movq   $0x0,-0x10(%rbp)
jmp    1231 <AllocTmpbuff+0xf1>
movslq -0x8(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
jmp    1231 <AllocTmpbuff+0xf1>
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
jmp    1231 <AllocTmpbuff+0xf1>
movslq -0x8(%rbp),%rax
shl    $0x1,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
jmp    1231 <AllocTmpbuff+0xf1>
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
jmp    1231 <AllocTmpbuff+0xf1>
movslq -0x8(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
jmp    1231 <AllocTmpbuff+0xf1>
movsbl -0x1(%rbp),%esi
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
movsbl -0x1(%rbp),%eax
cmp    $0x6e,%eax
je     1257 <AllocTmpbuff+0x117>
cmpq   $0x0,-0x10(%rbp)
jne    1257 <AllocTmpbuff+0x117>
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AllocTmpbuff>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %edi,%r14d
xor    %edi,%edi
test   %esi,%esi
setg   %dil
call   1060 <assert@plt>
lea    -0x53(%r14),%eax
cmp    $0x22,%eax
ja     11b6 <AllocTmpbuff+0x66>
xor    %ebx,%ebx
lea    0xe88(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
shl    $0x2,%ebp
jmp    118d <AllocTmpbuff+0x3d>
add    %ebp,%ebp
jmp    118d <AllocTmpbuff+0x3d>
shl    $0x3,%ebp
mov    %ebp,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
cmp    $0x6e,%r14b
je     11ae <AllocTmpbuff+0x5e>
test   %rbx,%rbx
jne    11ae <AllocTmpbuff+0x5e>
lea    0xf13(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xecf(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@.str = [48 x i8] c"Unexpected bad type error in AllocTmpbuff (%c)\0A\00"
@.str.1 = [41 x i8] c"Memory Allocation error in AllocTmpbuff\0A\00"
define i8* @AllocTmpbuff(i8 signext %0, i32 %1) {
%3 = alloca i8
%4 = alloca i32
%5 = alloca i8*
store i8 %0, i8* %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
%7 = icmp sgt i32 %6, 0
%8 = zext i1 %7 to i32
%9 = call i32 @assert(i32 %8)
store i8* null, i8** %5
%10 = load i8, i8* %3
%11 = sext i8 %10 to i32
switch i32 %11, label %43 [
i32 110, label %12
i32 99, label %13
i32 105, label %19
i32 83, label %19
i32 85, label %19
i32 115, label %25
i32 117, label %25
i32 102, label %31
i32 100, label %37
]
12: ; preds = %2
store i8* null, i8** %5
br label %48
13: ; preds = %2
%14 = load i32, i32* %4
%15 = sext i32 %14 to i64
%16 = mul i64 %15, 1
%17 = trunc i64 %16 to i32
%18 = call i8* @malloc(i32 %17)
store i8* %18, i8** %5
br label %48
19: ; preds = %2, %2, %2
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = mul i64 %21, 4
%23 = trunc i64 %22 to i32
%24 = call i8* @malloc(i32 %23)
store i8* %24, i8** %5
br label %48
25: ; preds = %2, %2
%26 = load i32, i32* %4
%27 = sext i32 %26 to i64
%28 = mul i64 %27, 2
%29 = trunc i64 %28 to i32
%30 = call i8* @malloc(i32 %29)
store i8* %30, i8** %5
br label %48
31: ; preds = %2
%32 = load i32, i32* %4
%33 = sext i32 %32 to i64
%34 = mul i64 %33, 4
%35 = trunc i64 %34 to i32
%36 = call i8* @malloc(i32 %35)
store i8* %36, i8** %5
br label %48
37: ; preds = %2
%38 = load i32, i32* %4
%39 = sext i32 %38 to i64
%40 = mul i64 %39, 8
%41 = trunc i64 %40 to i32
%42 = call i8* @malloc(i32 %41)
store i8* %42, i8** %5
br label %48
43: ; preds = %2
%44 = load i8, i8* %3
%45 = sext i8 %44 to i32
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i32 %45)
%47 = call i32 (...) @abort()
unreachable
48: ; preds = %37, %31, %25, %19, %13, %12
%49 = load i8, i8* %3
%50 = sext i8 %49 to i32
%51 = icmp ne i32 %50, 110
br i1 %51, label %52, label %57
52: ; preds = %48
%53 = load i8*, i8** %5
%54 = icmp eq i8* %53, null
br i1 %54, label %55, label %57
55: ; preds = %52
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
br label %57
57: ; preds = %55, %52, %48
%58 = load i8*, i8** %5
ret i8* %58
}

LLVM IR (-O2):
@.str = [48 x i8] c"Unexpected bad type error in AllocTmpbuff (%c)\0A\00"
@str = [40 x i8] c"Memory Allocation error in AllocTmpbuff\00"
define i8* @AllocTmpbuff(i8 signext %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = sext i8 %0 to i32
switch i32 %6, label %15 [
i32 110, label %21
i32 99, label %18
i32 105, label %7
i32 83, label %7
i32 85, label %7
i32 115, label %9
i32 117, label %9
i32 102, label %11
i32 100, label %13
]
7: ; preds = %2, %2, %2
%8 = shl i32 %1, 2
br label %18
9: ; preds = %2, %2
%10 = shl i32 %1, 1
br label %18
11: ; preds = %2
%12 = shl i32 %1, 2
br label %18
13: ; preds = %2
%14 = shl i32 %1, 3
br label %18
15: ; preds = %2
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i32 %6)
%17 = tail call i32 (...) @abort()
unreachable
18: ; preds = %2, %7, %9, %11, %13
%19 = phi i32 [ %14, %13 ], [ %12, %11 ], [ %10, %9 ], [ %8, %7 ], [ %1, %2 ]
%20 = tail call i8* @malloc(i32 %19)
br label %21
21: ; preds = %18, %2
%22 = phi i8* [ null, %2 ], [ %20, %18 ]
%23 = icmp ne i8 %0, 110
%24 = icmp eq i8* %22, null
%25 = and i1 %23, %24
br i1 %25, label %26, label %28
26: ; preds = %21
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
br label %28
28: ; preds = %26, %21
ret i8* %22
}