#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*/ addarg(char const *);
scalar_t__ strcmp(char const *, char *);
void addlib(const char *lib) {
  if (strcmp(lib, "pthread") == 0)
    addarg("-pthread");
  else if (strcmp(lib, "rt") == 0)
    ;
  else if (strcmp(lib, "xnet") == 0)
    ;
  else {
    addarg("-l");
    addarg(lib);
  }
}


x86 assembly (clang, -O0):
<addlib>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeca(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1157 <addlib+0x37>
lea    0xeb3(%rip),%rdi
call   1040 <addarg@plt>
jmp    11b4 <addlib+0x94>
mov    -0x8(%rbp),%rdi
lea    0xea7(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1176 <addlib+0x56>
jmp    11af <addlib+0x8f>
mov    -0x8(%rbp),%rdi
lea    0xe8b(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1195 <addlib+0x75>
jmp    11aa <addlib+0x8a>
lea    0xe75(%rip),%rdi
call   1040 <addarg@plt>
mov    -0x8(%rbp),%rdi
call   1040 <addarg@plt>
jmp    11af <addlib+0x8f>
jmp    11b4 <addlib+0x94>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<addlib>:
push   %rbx
mov    %rdi,%rbx
lea    0xed6(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     116b <addlib+0x4b>
lea    0xecd(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     117b <addlib+0x5b>
lea    0xebc(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     117b <addlib+0x5b>
lea    0xead(%rip),%rdi
call   1040 <addarg@plt>
jmp    1172 <addlib+0x52>
lea    0xe8e(%rip),%rbx
mov    %rbx,%rdi
pop    %rbx
jmp    1040 <addarg@plt>
pop    %rbx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"pthread\00"
@.str.1 = [9 x i8] c"-pthread\00"
@.str.2 = [3 x i8] c"rt\00"
@.str.3 = [5 x i8] c"xnet\00"
@.str.4 = [3 x i8] c"-l\00"
define void @addlib(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = call i32 @addarg(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %24
8: ; preds = %1
%9 = load i8*, i8** %2
%10 = call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %8
br label %23
13: ; preds = %8
%14 = load i8*, i8** %2
%15 = call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %13
br label %22
18: ; preds = %13
%19 = call i32 @addarg(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%20 = load i8*, i8** %2
%21 = call i32 @addarg(i8* %20)
br label %22
22: ; preds = %18, %17
br label %23
23: ; preds = %22, %12
br label %24
24: ; preds = %23, %6
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"pthread\00"
@.str.1 = [9 x i8] c"-pthread\00"
@.str.2 = [3 x i8] c"rt\00"
@.str.3 = [5 x i8] c"xnet\00"
@.str.4 = [3 x i8] c"-l\00"
define void @addlib(i8* %0) {
%2 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i64 %2, 0
br i1 %3, label %12, label %4
4: ; preds = %1
%5 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %15, label %7
7: ; preds = %4
%8 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %15, label %10
10: ; preds = %7
%11 = tail call i32 @addarg(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %12
12: ; preds = %1, %10
%13 = phi i8* [ %0, %10 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), %1 ]
%14 = tail call i32 @addarg(i8* %13)
br label %15
15: ; preds = %12, %4, %7
ret void
}