#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 */
struct fsm {
  int dummy;
};

/* Variables and functions */
char *flag_type_to_char(int);
struct fsm *fsm_symbol(char *);
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strcmp(char *, char *);
int strlen(char *);
char *xxmalloc(int);
struct fsm *flag_create_symbol(int type, char *name, char *value) {
  char *string;
  if (value == NULL)
    value = "";
  string = xxmalloc(sizeof(char) * strlen(name) + strlen(value) + 6);
  *string = '\0';
  strcat(string, "@");
  strcat(string, flag_type_to_char(type));
  strcat(string, ".");
  strcat(string, name);
  if (strcmp(value, "") != 0) {
    strcat(string, ".");
    strcat(string, value);
  }
  strcat(string, "@");
  return (fsm_symbol(string));
}


x86 assembly (clang, -O0):
<flag_create_symbol>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1189 <flag_create_symbol+0x29>
lea    0xe7e(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cltq
shl    $0x0,%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0x6,%rax
mov    %eax,%edi
call   1060 <xxmalloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rdi
lea    0xe2e(%rip),%rsi
call   1080 <strcat@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <flag_type_to_char@plt>
mov    -0x28(%rbp),%rdi
mov    %rax,%rsi
call   1080 <strcat@plt>
mov    -0x20(%rbp),%rdi
lea    0xe04(%rip),%rsi
call   1080 <strcat@plt>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1080 <strcat@plt>
mov    -0x18(%rbp),%rdi
lea    0xde8(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     1247 <flag_create_symbol+0xe7>
mov    -0x20(%rbp),%rdi
lea    0xdcd(%rip),%rsi
call   1080 <strcat@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1080 <strcat@plt>
mov    -0x20(%rbp),%rdi
lea    0xdae(%rip),%rsi
call   1080 <strcat@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fsm_symbol@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<flag_create_symbol>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r12
mov    %edi,%ebp
test   %rdx,%rdx
lea    0xe89(%rip),%r15
cmove  %r15,%r14
mov    %rsi,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1030 <strlen@plt>
lea    (%rbx,%rax,1),%edi
add    $0x6,%edi
call   1060 <xxmalloc@plt>
mov    %rax,%rbx
movb   $0x0,(%rax)
lea    0xe58(%rip),%rsi
mov    %rax,%rdi
call   1080 <strcat@plt>
mov    %ebp,%edi
call   1050 <flag_type_to_char@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1080 <strcat@plt>
lea    0xe39(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcat@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1080 <strcat@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1206 <flag_create_symbol+0xa6>
lea    0xe0f(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1080 <strcat@plt>
lea    0xdf3(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcat@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fsm_symbol@plt>

LLVM IR (-O0):
%struct.fsm = type { i32 }
@.str = [1 x i8] zeroinitializer
@.str.1 = [2 x i8] c"@\00"
@.str.2 = [2 x i8] c".\00"
define %struct.fsm* @flag_create_symbol(i32 %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i32 %0, i32* %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%8 = load i8*, i8** %6
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %11
10: ; preds = %3
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %6
br label %11
11: ; preds = %10, %3
%12 = load i8*, i8** %5
%13 = call i32 @strlen(i8* %12)
%14 = sext i32 %13 to i64
%15 = mul i64 1, %14
%16 = load i8*, i8** %6
%17 = call i32 @strlen(i8* %16)
%18 = sext i32 %17 to i64
%19 = add i64 %15, %18
%20 = add i64 %19, 6
%21 = trunc i64 %20 to i32
%22 = call i8* @xxmalloc(i32 %21)
store i8* %22, i8** %7
%23 = load i8*, i8** %7
store i8 0, i8* %23
%24 = load i8*, i8** %7
%25 = call i32 @strcat(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%26 = load i8*, i8** %7
%27 = load i32, i32* %4
%28 = call i8* @flag_type_to_char(i32 %27)
%29 = call i32 @strcat(i8* %26, i8* %28)
%30 = load i8*, i8** %7
%31 = call i32 @strcat(i8* %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%32 = load i8*, i8** %7
%33 = load i8*, i8** %5
%34 = call i32 @strcat(i8* %32, i8* %33)
%35 = load i8*, i8** %6
%36 = call i64 @strcmp(i8* %35, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %44
38: ; preds = %11
%39 = load i8*, i8** %7
%40 = call i32 @strcat(i8* %39, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%41 = load i8*, i8** %7
%42 = load i8*, i8** %6
%43 = call i32 @strcat(i8* %41, i8* %42)
br label %44
44: ; preds = %38, %11
%45 = load i8*, i8** %7
%46 = call i32 @strcat(i8* %45, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%47 = load i8*, i8** %7
%48 = call %struct.fsm* @fsm_symbol(i8* %47)
ret %struct.fsm* %48
}

LLVM IR (-O2):
%struct.fsm = type { i32 }
@.str = [1 x i8] zeroinitializer
@.str.1 = [2 x i8] c"@\00"
@.str.2 = [2 x i8] c".\00"
define %struct.fsm* @flag_create_symbol(i32 %0, i8* %1, i8* %2) {
%4 = icmp eq i8* %2, null
%5 = select i1 %4, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* %2
%6 = tail call i32 @strlen(i8* %1)
%7 = tail call i32 @strlen(i8* %5)
%8 = add i32 %6, 6
%9 = add i32 %8, %7
%10 = tail call i8* @xxmalloc(i32 %9)
store i8 0, i8* %10
%11 = tail call i32 @strcat(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = tail call i8* @flag_type_to_char(i32 %0)
%13 = tail call i32 @strcat(i8* %10, i8* %12)
%14 = tail call i32 @strcat(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%15 = tail call i32 @strcat(i8* %10, i8* %1)
%16 = tail call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %3
%19 = tail call i32 @strcat(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%20 = tail call i32 @strcat(i8* %10, i8* %5)
br label %21
21: ; preds = %18, %3
%22 = tail call i32 @strcat(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%23 = tail call %struct.fsm* @fsm_symbol(i8* %10)
ret %struct.fsm* %23
}