#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*/ copia(char *, char *);
char *malloc(int);
int size(char *);
int /*<<< orphan*/ strcat(char *, char *);
char *stringaIntero(int tipo, char *parola) {
  char *finale;
  int l = size(parola);
  if (tipo == 0) {
    l = l + 3;
    finale = malloc(sizeof(char) * l);
    copia(finale, parola);
    strcat(finale, " ,");
  }
  if (tipo == 1) {
    l = l + 5;
    finale = malloc(sizeof(char) * l);
    strcat(finale, " '");
    strcat(finale, parola);
    strcat(finale, "' ,");
  }
  if (tipo == 2) {
    finale = parola;
  }
  if (tipo == 3) {
    l = l + 3;
    finale = malloc(sizeof(char) * l);
    strcat(finale, "'");
    strcat(finale, parola);
    strcat(finale, "'");
  }
  return finale;
}


x86 assembly (clang, -O0):
<stringaIntero>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <size@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    119e <stringaIntero+0x5e>
mov    -0x1c(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <copia@plt>
mov    -0x18(%rbp),%rdi
lea    0xe6b(%rip),%rsi
call   1060 <strcat@plt>
cmpl   $0x1,-0x4(%rbp)
jne    11f1 <stringaIntero+0xb1>
mov    -0x1c(%rbp),%eax
add    $0x5,%eax
mov    %eax,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe31(%rip),%rsi
call   1060 <strcat@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <strcat@plt>
mov    -0x18(%rbp),%rdi
lea    0xe17(%rip),%rsi
call   1060 <strcat@plt>
cmpl   $0x2,-0x4(%rbp)
jne    1203 <stringaIntero+0xc3>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x3,-0x4(%rbp)
jne    1256 <stringaIntero+0x116>
mov    -0x1c(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xdcd(%rip),%rsi
call   1060 <strcat@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <strcat@plt>
mov    -0x18(%rbp),%rdi
lea    0xdb0(%rip),%rsi
call   1060 <strcat@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stringaIntero>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
mov    %rsi,%rdi
call   1030 <size@plt>
cmp    $0x3,%ebp
je     1184 <stringaIntero+0x44>
cmp    $0x1,%ebp
je     11b6 <stringaIntero+0x76>
test   %ebp,%ebp
jne    11ef <stringaIntero+0xaf>
add    $0x3,%eax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %rbx,%rsi
call   1040 <copia@plt>
lea    0xe82(%rip),%rsi
jmp    11e4 <stringaIntero+0xa4>
add    $0x3,%eax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,%rbp
lea    0xe69(%rip),%r14
mov    %rax,%rdi
mov    %r14,%rsi
call   1060 <strcat@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1060 <strcat@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
jmp    11e7 <stringaIntero+0xa7>
add    $0x5,%eax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,%rbp
lea    0xe36(%rip),%rsi
mov    %rax,%rdi
call   1060 <strcat@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1060 <strcat@plt>
lea    0xe1f(%rip),%rsi
mov    %rbp,%rdi
call   1060 <strcat@plt>
mov    %rbp,%rbx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c" ,\00"
@.str.1 = [3 x i8] c" '\00"
@.str.2 = [4 x i8] c"' ,\00"
@.str.3 = [2 x i8] c"'\00"
define i8* @stringaIntero(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
%7 = load i8*, i8** %4
%8 = call i32 @size(i8* %7)
store i32 %8, i32* %6
%9 = load i32, i32* %3
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %24
11: ; preds = %2
%12 = load i32, i32* %6
%13 = add nsw i32 %12, 3
store i32 %13, i32* %6
%14 = load i32, i32* %6
%15 = sext i32 %14 to i64
%16 = mul i64 1, %15
%17 = trunc i64 %16 to i32
%18 = call i8* @malloc(i32 %17)
store i8* %18, i8** %5
%19 = load i8*, i8** %5
%20 = load i8*, i8** %4
%21 = call i32 @copia(i8* %19, i8* %20)
%22 = load i8*, i8** %5
%23 = call i32 @strcat(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %24
24: ; preds = %11, %2
%25 = load i32, i32* %3
%26 = icmp eq i32 %25, 1
br i1 %26, label %27, label %42
27: ; preds = %24
%28 = load i32, i32* %6
%29 = add nsw i32 %28, 5
store i32 %29, i32* %6
%30 = load i32, i32* %6
%31 = sext i32 %30 to i64
%32 = mul i64 1, %31
%33 = trunc i64 %32 to i32
%34 = call i8* @malloc(i32 %33)
store i8* %34, i8** %5
%35 = load i8*, i8** %5
%36 = call i32 @strcat(i8* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%37 = load i8*, i8** %5
%38 = load i8*, i8** %4
%39 = call i32 @strcat(i8* %37, i8* %38)
%40 = load i8*, i8** %5
%41 = call i32 @strcat(i8* %40, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %42
42: ; preds = %27, %24
%43 = load i32, i32* %3
%44 = icmp eq i32 %43, 2
br i1 %44, label %45, label %47
45: ; preds = %42
%46 = load i8*, i8** %4
store i8* %46, i8** %5
br label %47
47: ; preds = %45, %42
%48 = load i32, i32* %3
%49 = icmp eq i32 %48, 3
br i1 %49, label %50, label %65
50: ; preds = %47
%51 = load i32, i32* %6
%52 = add nsw i32 %51, 3
store i32 %52, i32* %6
%53 = load i32, i32* %6
%54 = sext i32 %53 to i64
%55 = mul i64 1, %54
%56 = trunc i64 %55 to i32
%57 = call i8* @malloc(i32 %56)
store i8* %57, i8** %5
%58 = load i8*, i8** %5
%59 = call i32 @strcat(i8* %58, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%60 = load i8*, i8** %5
%61 = load i8*, i8** %4
%62 = call i32 @strcat(i8* %60, i8* %61)
%63 = load i8*, i8** %5
%64 = call i32 @strcat(i8* %63, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %65
65: ; preds = %50, %47
%66 = load i8*, i8** %5
ret i8* %66
}

LLVM IR (-O2):
@.str = [3 x i8] c" ,\00"
@.str.1 = [3 x i8] c" '\00"
@.str.2 = [4 x i8] c"' ,\00"
@.str.3 = [2 x i8] c"'\00"
define i8* @stringaIntero(i32 %0, i8* %1) {
%3 = tail call i32 @size(i8* %1)
switch i32 %0, label %21 [
i32 0, label %4
i32 1, label %9
i32 3, label %15
]
4: ; preds = %2
%5 = add nsw i32 %3, 3
%6 = tail call i8* @malloc(i32 %5)
%7 = tail call i32 @copia(i8* %6, i8* %1)
%8 = tail call i32 @strcat(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %21
9: ; preds = %2
%10 = add nsw i32 %3, 5
%11 = tail call i8* @malloc(i32 %10)
%12 = tail call i32 @strcat(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%13 = tail call i32 @strcat(i8* %11, i8* %1)
%14 = tail call i32 @strcat(i8* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %21
15: ; preds = %2
%16 = add nsw i32 %3, 3
%17 = tail call i8* @malloc(i32 %16)
%18 = tail call i32 @strcat(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%19 = tail call i32 @strcat(i8* %17, i8* %1)
%20 = tail call i32 @strcat(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %21
21: ; preds = %2, %9, %4, %15
%22 = phi i8* [ %17, %15 ], [ %6, %4 ], [ %11, %9 ], [ %1, %2 ]
ret i8* %22
}