#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*/ printf(char *, char const *);
scalar_t__ strstr(char const *, char *);
void search(char input[]) {
  int i;
  extern const char *tracks[];
  for (i = 0; i < 18; ++i) {
    if (strstr(tracks[i], input))
      printf("Found track: %s\n", tracks[i]);
  }
}


x86 assembly (clang, -O0):
<search>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x12,-0xc(%rbp)
jge    118d <search+0x6d>
movslq -0xc(%rbp),%rcx
mov    0x2e98(%rip),%rax
mov    (%rax,%rcx,8),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     117a <search+0x5a>
movslq -0xc(%rbp),%rcx
mov    0x2e76(%rip),%rax
mov    (%rax,%rcx,8),%rsi
lea    0xe8b(%rip),%rdi
call   1030 <printf@plt>
jmp    117f <search+0x5f>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1133 <search+0x13>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<search>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r15
xor    %ebx,%ebx
mov    0x2eac(%rip),%r12
lea    0xec5(%rip),%r14
jmp    114a <search+0x2a>
nopl   (%rax)
add    $0x1,%rbx
cmp    $0x12,%rbx
je     1169 <search+0x49>
mov    (%r12,%rbx,8),%rdi
mov    %r15,%rsi
call   1040 <strstr@plt>
test   %rax,%rax
je     1140 <search+0x20>
mov    (%r12,%rbx,8),%rsi
mov    %r14,%rdi
call   1030 <printf@plt>
jmp    1140 <search+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@tracks = external global [0 x i8*]
@.str = [17 x i8] c"Found track: %s\0A\00"
define void @search(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
br label %4
4: ; preds = %22, %1
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 18
br i1 %6, label %7, label %25
7: ; preds = %4
%8 = load i32, i32* %3
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds [0 x i8*], [0 x i8*]* @tracks, i64 0, i64 %9
%11 = load i8*, i8** %10
%12 = load i8*, i8** %2
%13 = call i64 @strstr(i8* %11, i8* %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %21
15: ; preds = %7
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [0 x i8*], [0 x i8*]* @tracks, i64 0, i64 %17
%19 = load i8*, i8** %18
%20 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %19)
br label %21
21: ; preds = %15, %7
br label %22
22: ; preds = %21
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
br label %4
25: ; preds = %4
ret void
}

LLVM IR (-O2):
@tracks = external global [0 x i8*]
@.str = [17 x i8] c"Found track: %s\0A\00"
define void @search(i8* %0) {
br label %2
2: ; preds = %1, %11
%3 = phi i64 [ 0, %1 ], [ %12, %11 ]
%4 = getelementptr inbounds [0 x i8*], [0 x i8*]* @tracks, i64 0, i64 %3
%5 = load i8*, i8** %4
%6 = tail call i64 @strstr(i8* %5, i8* %0)
%7 = icmp eq i64 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = load i8*, i8** %4
%10 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %9)
br label %11
11: ; preds = %2, %8
%12 = add nuw nsw i64 %3, 1
%13 = icmp eq i64 %12, 18
br i1 %13, label %14, label %2
14: ; preds = %11
ret void
}