#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 */
char *getAlias(struct confModules *, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, int);
int /*<<< orphan*/ strcmp(char *, char *);
int isAliased(struct confModules *cf, char *alias, char *module) {
  char tmp[128];
  char *modalias;
  int x = 0, retval = -1;
  if ((modalias = getAlias(cf, alias)) && (!strcmp(module, modalias)))
    retval = 0;
  else
    while (1) {
      snprintf(tmp, 128, "%s%d", alias, x);
      if ((modalias = getAlias(cf, tmp)) && (!strcmp(module, modalias))) {
        retval = x;
        break;
      }
      if (!modalias && x != 0)
        break;
      x++;
    }
  return retval;
}


x86 assembly (clang, -O0):
<isAliased>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0xac(%rbp)
movl   $0xffffffff,-0xb0(%rbp)
ff ff ff
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <getAlias@plt>
mov    %rax,-0xa8(%rbp)
cmp    $0x0,%rax
je     11a1 <isAliased+0x71>
mov    -0x18(%rbp),%rdi
mov    -0xa8(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11a1 <isAliased+0x71>
movl   $0x0,-0xb0(%rbp)
jmp    124d <isAliased+0x11d>
jmp    11a6 <isAliased+0x76>
lea    -0xa0(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    -0xac(%rbp),%r8d
mov    $0x80,%esi
lea    0xe3c(%rip),%rdx
call   1030 <snprintf@plt>
mov    -0x8(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
call   1050 <getAlias@plt>
mov    %rax,-0xa8(%rbp)
cmp    $0x0,%rax
je     1214 <isAliased+0xe4>
mov    -0x18(%rbp),%rdi
mov    -0xa8(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1214 <isAliased+0xe4>
mov    -0xac(%rbp),%eax
mov    %eax,-0xb0(%rbp)
jmp    1248 <isAliased+0x118>
cmpq   $0x0,-0xa8(%rbp)
jne    1234 <isAliased+0x104>
cmpl   $0x0,-0xac(%rbp)
je     1234 <isAliased+0x104>
jmp    1248 <isAliased+0x118>
mov    -0xac(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xac(%rbp)
jmp    11a6 <isAliased+0x76>
jmp    124d <isAliased+0x11d>
mov    -0xb0(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isAliased>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r13
call   1050 <getAlias@plt>
test   %rax,%rax
je     1163 <isAliased+0x33>
mov    %r14,%rdi
mov    %rax,%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11c5 <isAliased+0x95>
xor    %ebp,%ebp
lea    0xe94(%rip),%r12
mov    %rsp,%rbx
jmp    1187 <isAliased+0x57>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
test   %ebp,%ebp
jne    11be <isAliased+0x8e>
add    $0x1,%ebp
mov    %rbx,%rdi
mov    $0x80,%esi
mov    %r12,%rdx
mov    %r15,%rcx
mov    %ebp,%r8d
call   1030 <snprintf@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1050 <getAlias@plt>
test   %rax,%rax
je     1180 <isAliased+0x50>
mov    %r14,%rdi
mov    %rax,%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
jne    1184 <isAliased+0x54>
jmp    11c7 <isAliased+0x97>
mov    $0xffffffff,%ebp
jmp    11c7 <isAliased+0x97>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.confModules = type { i32 }
@.str = [5 x i8] c"%s%d\00"
define i32 @isAliased(%struct.confModules* %0, i8* %1, i8* nocapture %2) {
%4 = alloca [128 x i8]
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%6 = tail call i8* @getAlias(%struct.confModules* %0, i8* %1)
%7 = icmp eq i8* %6, null
br i1 %7, label %11, label %8
8: ; preds = %3
%9 = tail call i32 @strcmp(i8* dereferenceable(1) %2, i8* %6)
%10 = icmp eq i32 %9, 0
br i1 %10, label %24, label %11
11: ; preds = %8, %3
br label %12
12: ; preds = %11, %22
%13 = phi i32 [ %23, %22 ], [ 0, %11 ]
%14 = call i32 @snprintf(i8* %5, i32 128, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %1, i32 %13)
%15 = call i8* @getAlias(%struct.confModules* %0, i8* %5)
%16 = icmp eq i8* %15, null
br i1 %16, label %20, label %17
17: ; preds = %12
%18 = call i32 @strcmp(i8* dereferenceable(1) %2, i8* %15)
%19 = icmp eq i32 %18, 0
br i1 %19, label %24, label %22
20: ; preds = %12
%21 = icmp eq i32 %13, 0
br i1 %21, label %22, label %24
22: ; preds = %17, %20
%23 = add nuw nsw i32 %13, 1
br label %12
24: ; preds = %17, %20, %8
%25 = phi i32 [ 0, %8 ], [ %13, %17 ], [ -1, %20 ]
ret i32 %25
}