#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 confModules {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ addLine(struct confModules *, char *, int);
char *malloc(int);
int /*<<< orphan*/ removeAlias(struct confModules *, char *, int);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char *);
int strlen(char *);
int addAlias(struct confModules *cf, char *alias, char *aliasdef, int flags) {
  int x;
  char *tmp;
  if (flags & 1 || flags & (1 << 1))
    removeAlias(cf, alias, flags);
  x = strlen(alias) + strlen(aliasdef) + 10;
  tmp = malloc(x);
  snprintf(tmp, x, "alias %s %s", alias, aliasdef);
  addLine(cf, tmp, flags);
  return 0;
}


x86 assembly (clang, -O0):
<addAlias>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
jne    1185 <addAlias+0x35>
mov    -0x1c(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     1195 <addAlias+0x45>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1050 <removeAlias@plt>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
add    %ecx,%eax
add    $0xa,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%edi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%esi
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
lea    0xe27(%rip),%rdx
call   1040 <snprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1070 <addLine@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<addAlias>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r12d
mov    %rdx,%r15
mov    %rsi,%r13
mov    %rdi,%r14
test   $0x3,%r12b
je     117b <addAlias+0x2b>
mov    %r14,%rdi
mov    %r13,%rsi
mov    %r12d,%edx
call   1050 <removeAlias@plt>
mov    %r13,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   1030 <strlen@plt>
add    %eax,%ebp
add    $0xa,%ebp
mov    %ebp,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0xe5d(%rip),%rdx
mov    %rax,%rdi
mov    %ebp,%esi
mov    %r13,%rcx
mov    %r15,%r8
call   1040 <snprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r12d,%edx
call   1070 <addLine@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.confModules = type { i32 }
@.str = [12 x i8] c"alias %s %s\00"
define i32 @addAlias(%struct.confModules* %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca %struct.confModules*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
store %struct.confModules* %0, %struct.confModules** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%11 = load i32, i32* %8
%12 = and i32 %11, 1
%13 = icmp ne i32 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %4
%15 = load i32, i32* %8
%16 = and i32 %15, 2
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %23
18: ; preds = %14, %4
%19 = load %struct.confModules*, %struct.confModules** %5
%20 = load i8*, i8** %6
%21 = load i32, i32* %8
%22 = call i32 @removeAlias(%struct.confModules* %19, i8* %20, i32 %21)
br label %23
23: ; preds = %18, %14
%24 = load i8*, i8** %6
%25 = call i32 @strlen(i8* %24)
%26 = load i8*, i8** %7
%27 = call i32 @strlen(i8* %26)
%28 = add nsw i32 %25, %27
%29 = add nsw i32 %28, 10
store i32 %29, i32* %9
%30 = load i32, i32* %9
%31 = call i8* @malloc(i32 %30)
store i8* %31, i8** %10
%32 = load i8*, i8** %10
%33 = load i32, i32* %9
%34 = load i8*, i8** %6
%35 = load i8*, i8** %7
%36 = call i32 @snprintf(i8* %32, i32 %33, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %34, i8* %35)
%37 = load %struct.confModules*, %struct.confModules** %5
%38 = load i8*, i8** %10
%39 = load i32, i32* %8
%40 = call i32 @addLine(%struct.confModules* %37, i8* %38, i32 %39)
ret i32 0
}

LLVM IR (-O2):
%struct.confModules = type { i32 }
@.str = [12 x i8] c"alias %s %s\00"
define i32 @addAlias(%struct.confModules* %0, i8* %1, i8* %2, i32 %3) {
%5 = and i32 %3, 3
%6 = icmp eq i32 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %4
%8 = tail call i32 @removeAlias(%struct.confModules* %0, i8* %1, i32 %3)
br label %9
9: ; preds = %4, %7
%10 = tail call i32 @strlen(i8* %1)
%11 = tail call i32 @strlen(i8* %2)
%12 = add i32 %10, 10
%13 = add i32 %12, %11
%14 = tail call i8* @malloc(i32 %13)
%15 = tail call i32 @snprintf(i8* %14, i32 %13, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %2)
%16 = tail call i32 @addLine(%struct.confModules* %0, i8* %14, i32 %3)
ret i32 0
}