#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 get_tracers(char ***);
int /*<<< orphan*/ strlen(char *);
scalar_t__ strncmp(char *, char *, int /*<<< orphan*/);
int valid_tracer(char *tracername) {
  char **list;
  int ntracers;
  int i;
  ntracers = get_tracers(&list);
  if (ntracers == 0 || tracername == NULL)
    return 0;
  for (i = 0; i < ntracers; i++)
    if (strncmp(list[i], tracername, strlen(list[i])) == 0)
      return 1;
  return 0;
}


x86 assembly (clang, -O0):
<valid_tracer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x18(%rbp),%rdi
call   1050 <get_tracers@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     115d <valid_tracer+0x2d>
cmpq   $0x0,-0x10(%rbp)
jne    1169 <valid_tracer+0x39>
movl   $0x0,-0x4(%rbp)
jmp    11e4 <valid_tracer+0xb4>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11dd <valid_tracer+0xad>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11ca <valid_tracer+0x9a>
movl   $0x1,-0x4(%rbp)
jmp    11e4 <valid_tracer+0xb4>
jmp    11cf <valid_tracer+0x9f>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1170 <valid_tracer+0x40>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<valid_tracer>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
mov    %rsp,%rdi
call   1050 <get_tracers@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %r14,%r14
je     1194 <valid_tracer+0x64>
test   %ecx,%ecx
jle    1194 <valid_tracer+0x64>
mov    %ecx,%r15d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%rsp),%rax
mov    (%rax,%rbx,8),%r12
mov    %r12,%rdi
call   1040 <strlen@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     118f <valid_tracer+0x5f>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1160 <valid_tracer+0x30>
xor    %eax,%eax
jmp    1194 <valid_tracer+0x64>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @valid_tracer(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
%7 = call i32 @get_tracers(i8*** %4)
store i32 %7, i32* %5
%8 = load i32, i32* %5
%9 = icmp eq i32 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %14
13: ; preds = %10, %1
store i32 0, i32* %2
br label %40
14: ; preds = %10
store i32 0, i32* %6
br label %15
15: ; preds = %36, %14
%16 = load i32, i32* %6
%17 = load i32, i32* %5
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %39
19: ; preds = %15
%20 = load i8**, i8*** %4
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8*, i8** %20, i64 %22
%24 = load i8*, i8** %23
%25 = load i8*, i8** %3
%26 = load i8**, i8*** %4
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8*, i8** %26, i64 %28
%30 = load i8*, i8** %29
%31 = call i32 @strlen(i8* %30)
%32 = call i64 @strncmp(i8* %24, i8* %25, i32 %31)
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %19
store i32 1, i32* %2
br label %40
35: ; preds = %19
br label %36
36: ; preds = %35
%37 = load i32, i32* %6
%38 = add nsw i32 %37, 1
store i32 %38, i32* %6
br label %15
39: ; preds = %15
store i32 0, i32* %2
br label %40
40: ; preds = %39, %34, %13
%41 = load i32, i32* %2
ret i32 %41
}

LLVM IR (-O2):
define i32 @valid_tracer(i8* %0) {
%2 = alloca i8**
%3 = bitcast i8*** %2 to i8*
%4 = call i32 @get_tracers(i8*** %2)
%5 = icmp ne i8* %0, null
%6 = icmp sgt i32 %4, 0
%7 = and i1 %5, %6
br i1 %7, label %8, label %21
8: ; preds = %1
%9 = zext i32 %4 to i64
br label %12
10: ; preds = %12
%11 = icmp eq i64 %20, %9
br i1 %11, label %21, label %12
12: ; preds = %8, %10
%13 = phi i64 [ 0, %8 ], [ %20, %10 ]
%14 = load i8**, i8*** %2
%15 = getelementptr inbounds i8*, i8** %14, i64 %13
%16 = load i8*, i8** %15
%17 = call i32 @strlen(i8* %16)
%18 = call i64 @strncmp(i8* %16, i8* %0, i32 %17)
%19 = icmp eq i64 %18, 0
%20 = add nuw nsw i64 %13, 1
br i1 %19, label %21, label %10
21: ; preds = %12, %10, %1
%22 = phi i32 [ 0, %1 ], [ 1, %12 ], [ 0, %10 ]
ret i32 %22
}