#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 *malloc(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strlen(char *);
char *hdlExtension(int hdl) {
  char *ext = NULL;
  switch (hdl) {
  case 1:
    ext = malloc((strlen(".v") + 1) * sizeof(char));
    strcpy(ext, ".v");
    break;
  default:
    printf("Not supported HDL provided\n");
    break;
  }
  return ext;
}


x86 assembly (clang, -O0):
<hdlExtension>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
jne    1199 <hdlExtension+0x59>
jmp    1164 <hdlExtension+0x24>
lea    0xe95(%rip),%rdi
call   1040 <strlen@plt>
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe71(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11a5 <hdlExtension+0x65>
lea    0xe63(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hdlExtension>:
push   %r14
push   %rbx
push   %rax
cmp    $0x1,%edi
jne    1170 <hdlExtension+0x30>
lea    0xeb0(%rip),%r14
mov    %r14,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
jmp    117e <hdlExtension+0x3e>
lea    0xe8c(%rip),%rdi
call   1040 <puts@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c".v\00"
@.str.1 = [28 x i8] c"Not supported HDL provided\0A\00"
define i8* @hdlExtension(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
store i32 %0, i32* %2
store i8* null, i8** %3
%4 = load i32, i32* %2
switch i32 %4, label %14 [
i32 1, label %5
]
5: ; preds = %1
%6 = call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = add nsw i32 %6, 1
%8 = sext i32 %7 to i64
%9 = mul i64 %8, 1
%10 = trunc i64 %9 to i32
%11 = call i8* @malloc(i32 %10)
store i8* %11, i8** %3
%12 = load i8*, i8** %3
%13 = call i32 @strcpy(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %16
14: ; preds = %1
%15 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
br label %16
16: ; preds = %14, %5
%17 = load i8*, i8** %3
ret i8* %17
}

LLVM IR (-O2):
@.str = [3 x i8] c".v\00"
@str = [27 x i8] c"Not supported HDL provided\00"
define i8* @hdlExtension(i32 %0) {
%2 = icmp eq i32 %0, 1
br i1 %2, label %3, label %8
3: ; preds = %1
%4 = tail call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = add nsw i32 %4, 1
%6 = tail call i8* @malloc(i32 %5)
%7 = tail call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %10
8: ; preds = %1
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
br label %10
10: ; preds = %8, %3
%11 = phi i8* [ %6, %3 ], [ null, %8 ]
ret i8* %11
}