#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*/ message(int, char *, char *, char const *, ...);
scalar_t__ strchr(char *, char);
scalar_t__ strcmp(char *, char *);
int strcspn(char *, char *);
int strlen(char *);
void mod_in_use(int log, const char *modname, char *usedby) {
  if (usedby[0] == '-' || strcmp(usedby, "") == 0) {
    message(log, "ERROR: ", "Module %s is in use\n", modname);
    return;
  }
  if (strchr(usedby, ','))
    usedby[strcspn(usedby, " \n") - 1] = '\0';
  else {
    usedby[strlen(usedby) - 1] = '\0';
  }
  message(log, "ERROR: ", "Module %s is in use by %s\n", modname, usedby);
}


x86 assembly (clang, -O0):
<mod_in_use>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
je     118d <mod_in_use+0x3d>
mov    -0x18(%rbp),%rdi
lea    0xea1(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    11ae <mod_in_use+0x5e>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rcx
lea    0xe65(%rip),%rsi
lea    0xe66(%rip),%rdx
mov    $0x0,%al
call   1030 <message@plt>
jmp    1234 <mod_in_use+0xe4>
mov    -0x18(%rbp),%rdi
mov    $0x2c,%esi
call   1050 <strchr@plt>
cmp    $0x0,%rax
je     11f3 <mod_in_use+0xa3>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe44(%rip),%rsi
call   1060 <strcspn@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    1214 <mod_in_use+0xc4>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
lea    0xdda(%rip),%rsi
lea    0xdf3(%rip),%rdx
mov    $0x0,%al
call   1030 <message@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mod_in_use>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebp
cmpb   $0x2d,(%rdx)
je     1198 <mod_in_use+0x48>
mov    %rdx,%rbx
lea    0xeb7(%rip),%rsi
mov    %rdx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1198 <mod_in_use+0x48>
mov    %rbx,%rdi
mov    $0x2c,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     11b6 <mod_in_use+0x66>
lea    0xe8f(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcspn@plt>
jmp    11be <mod_in_use+0x6e>
lea    0xe61(%rip),%rsi
lea    0xe62(%rip),%rdx
mov    %ebp,%edi
mov    %r14,%rcx
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <message@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
lea    0xe34(%rip),%rsi
lea    0xe4d(%rip),%rdx
mov    %ebp,%edi
mov    %r14,%rcx
mov    %rbx,%r8
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <message@plt>

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [8 x i8] c"ERROR: \00"
@.str.2 = [21 x i8] c"Module %s is in use\0A\00"
@.str.3 = [3 x i8] c" \0A\00"
@.str.4 = [27 x i8] c"Module %s is in use by %s\0A\00"
define void @mod_in_use(i32 %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
store i32 %0, i32* %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%7 = load i8*, i8** %6
%8 = getelementptr inbounds i8, i8* %7, i64 0
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 45
br i1 %11, label %16, label %12
12: ; preds = %3
%13 = load i8*, i8** %6
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %12, %3
%17 = load i32, i32* %4
%18 = load i8*, i8** %5
%19 = call i32 (i32, i8*, i8*, i8*, ...) @message(i32 %17, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %18)
br label %43
20: ; preds = %12
%21 = load i8*, i8** %6
%22 = call i64 @strchr(i8* %21, i8 signext 44)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %31
24: ; preds = %20
%25 = load i8*, i8** %6
%26 = load i8*, i8** %6
%27 = call i32 @strcspn(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%28 = sub nsw i32 %27, 1
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %25, i64 %29
store i8 0, i8* %30
br label %38
31: ; preds = %20
%32 = load i8*, i8** %6
%33 = load i8*, i8** %6
%34 = call i32 @strlen(i8* %33)
%35 = sub nsw i32 %34, 1
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %32, i64 %36
store i8 0, i8* %37
br label %38
38: ; preds = %31, %24
%39 = load i32, i32* %4
%40 = load i8*, i8** %5
%41 = load i8*, i8** %6
%42 = call i32 (i32, i8*, i8*, i8*, ...) @message(i32 %39, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8* %40, i8* %41)
br label %43
43: ; preds = %38, %16
ret void
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [8 x i8] c"ERROR: \00"
@.str.2 = [21 x i8] c"Module %s is in use\0A\00"
@.str.3 = [3 x i8] c" \0A\00"
@.str.4 = [27 x i8] c"Module %s is in use by %s\0A\00"
define void @mod_in_use(i32 %0, i8* %1, i8* %2) {
%4 = load i8, i8* %2
%5 = icmp eq i8 %4, 45
br i1 %5, label %9, label %6
6: ; preds = %3
%7 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %6, %3
%10 = tail call i32 (i32, i8*, i8*, i8*, ...) @message(i32 %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %1)
br label %24
11: ; preds = %6
%12 = tail call i64 @strchr(i8* %2, i8 signext 44)
%13 = icmp eq i64 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %11
%15 = tail call i32 @strcspn(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %18
16: ; preds = %11
%17 = tail call i32 @strlen(i8* %2)
br label %18
18: ; preds = %16, %14
%19 = phi i32 [ %17, %16 ], [ %15, %14 ]
%20 = add nsw i32 %19, -1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %2, i64 %21
store i8 0, i8* %22
%23 = tail call i32 (i32, i8*, i8*, i8*, ...) @message(i32 %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8* %1, i8* %2)
br label %24
24: ; preds = %18, %9
ret void
}