#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[][80];
  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    1193 <search+0x73>
movslq -0xc(%rbp),%rax
mov    0x2e98(%rip),%rdi
imul   $0x50,%rax,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     1180 <search+0x60>
movslq -0xc(%rbp),%rax
mov    0x2e73(%rip),%rsi
imul   $0x50,%rax,%rax
add    %rax,%rsi
lea    0xe85(%rip),%rdi
call   1030 <printf@plt>
jmp    1185 <search+0x65>
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   %r13
push   %r12
push   %rbx
mov    %rdi,%r15
xor    %ebx,%ebx
mov    0x2eab(%rip),%r13
lea    0xec4(%rip),%r14
jmp    114d <search+0x2d>
xchg   %ax,%ax
add    $0x50,%rbx
cmp    $0x5a0,%rbx
je     116e <search+0x4e>
lea    (%rbx,%r13,1),%r12
mov    %r12,%rdi
mov    %r15,%rsi
call   1040 <strstr@plt>
test   %rax,%rax
je     1140 <search+0x20>
mov    %r14,%rdi
mov    %r12,%rsi
call   1030 <printf@plt>
jmp    1140 <search+0x20>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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