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


x86 assembly (clang, -O0):
<mod_in_use>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
je     118a <mod_in_use+0x3a>
mov    -0x10(%rbp),%rdi
lea    0xe9c(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    11a1 <mod_in_use+0x51>
mov    -0x8(%rbp),%rsi
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1070 <error@plt>
jmp    121d <mod_in_use+0xcd>
mov    -0x10(%rbp),%rdi
mov    $0x2c,%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
je     11e6 <mod_in_use+0x96>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe49(%rip),%rsi
call   1050 <strcspn@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    1207 <mod_in_use+0xb7>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1070 <error@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mod_in_use>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
cmpb   $0x2d,(%rsi)
je     1196 <mod_in_use+0x46>
mov    %rsi,%rbx
lea    0xeb1(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1196 <mod_in_use+0x46>
mov    %rbx,%rdi
mov    $0x2c,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     11ae <mod_in_use+0x5e>
lea    0xe89(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcspn@plt>
jmp    11b6 <mod_in_use+0x66>
lea    0xe63(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1070 <error@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
lea    0xe54(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1070 <error@plt>

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

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