#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*/ exit(int);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
char *getCaminhoTabela(char *nomeTabela) {
  int tam;
  char *caminho = NULL;
  if (nomeTabela != NULL) {
    tam = strlen(nomeTabela) + 14;
    caminho = (char *)malloc(tam * sizeof(char));
    if (caminho == NULL) {
      exit(-1);
      printf("Erro de alocacao!\n");
    }
    strcat(nomeTabela, ".ori");
    strcat(caminho, "../dados/");
    strcat(caminho, nomeTabela);
  }
  return caminho;
}


x86 assembly (clang, -O0):
<getCaminhoTabela>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x18(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11c3 <getCaminhoTabela+0x83>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
add    $0xe,%eax
mov    %eax,-0xc(%rbp)
movslq -0xc(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1196 <getCaminhoTabela+0x56>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
mov    -0x8(%rbp),%rdi
lea    0xe5f(%rip),%rsi
call   1050 <strcat@plt>
mov    -0x18(%rbp),%rdi
lea    0xe54(%rip),%rsi
call   1050 <strcat@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1050 <strcat@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getCaminhoTabela>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     118c <getCaminhoTabela+0x4c>
mov    %rdi,%r14
call   1030 <strlen@plt>
lea    0xe(%rax),%edi
call   1040 <malloc@plt>
test   %rax,%rax
je     1199 <getCaminhoTabela+0x59>
mov    %rax,%rbx
lea    0xe98(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcat@plt>
lea    0xe8e(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strcat@plt>
jmp    118e <getCaminhoTabela+0x4e>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    $0xffffffff,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c".ori\00"
@.str.1 = [10 x i8] c"../dados/\00"
define i8* @getCaminhoTabela(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
store i8* %0, i8** %2
store i8* null, i8** %4
%5 = load i8*, i8** %2
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %29
7: ; preds = %1
%8 = load i8*, i8** %2
%9 = call i32 @strlen(i8* %8)
%10 = add nsw i32 %9, 14
store i32 %10, i32* %3
%11 = load i32, i32* %3
%12 = sext i32 %11 to i64
%13 = mul i64 %12, 1
%14 = trunc i64 %13 to i32
%15 = call i64 @malloc(i32 %14)
%16 = inttoptr i64 %15 to i8*
store i8* %16, i8** %4
%17 = load i8*, i8** %4
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %21
19: ; preds = %7
%20 = call i32 @exit(i32 -1)
unreachable
21: ; preds = %7
%22 = load i8*, i8** %2
%23 = call i32 @strcat(i8* %22, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%24 = load i8*, i8** %4
%25 = call i32 @strcat(i8* %24, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%26 = load i8*, i8** %4
%27 = load i8*, i8** %2
%28 = call i32 @strcat(i8* %26, i8* %27)
br label %29
29: ; preds = %21, %1
%30 = load i8*, i8** %4
ret i8* %30
}

LLVM IR (-O2):
@.str = [5 x i8] c".ori\00"
@.str.1 = [10 x i8] c"../dados/\00"
define i8* @getCaminhoTabela(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %15, label %3
3: ; preds = %1
%4 = tail call i32 @strlen(i8* %0)
%5 = add nsw i32 %4, 14
%6 = tail call i64 @malloc(i32 %5)
%7 = inttoptr i64 %6 to i8*
%8 = icmp eq i64 %6, 0
br i1 %8, label %9, label %11
9: ; preds = %3
%10 = tail call i32 @exit(i32 -1)
unreachable
11: ; preds = %3
%12 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%13 = tail call i32 @strcat(i8* %7, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%14 = tail call i32 @strcat(i8* %7, i8* %0)
br label %15
15: ; preds = %11, %1
%16 = phi i8* [ %7, %11 ], [ null, %1 ]
ret i8* %16
}