#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 *, int);
int search(char **, int, char *);
main() {
  char *msg[] = {"at", "", "", "", "ball", "ca", "", "car", "", "dad", ""};
  char str[] = "dad";
  printf("%s: %d\n", str, search(msg, 11, str));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
lea    -0x60(%rbp),%rdi
lea    0x2c7d(%rip),%rsi
mov    $0x58,%edx
call   1050 <memcpy@plt>
mov    0xebc(%rip),%eax
mov    %eax,-0x64(%rbp)
lea    -0x64(%rbp),%rax
mov    %rax,-0x70(%rbp)
lea    -0x60(%rbp),%rdi
lea    -0x64(%rbp),%rdx
mov    $0xb,%esi
call   1040 <search@plt>
mov    -0x70(%rbp),%rsi
mov    %eax,%edx
lea    0xe96(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x70,%rsp
mov    0x2ce4(%rip),%rax
mov    %rax,0x60(%rsp)
movaps 0x2cc8(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0x2cac(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0x2c90(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0x2c74(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0x2c58(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movl   $0x646164,0xc(%rsp)
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rbx
mov    $0xb,%esi
mov    %rbx,%rdx
call   1040 <search@plt>
lea    0xe80(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"at\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [5 x i8] c"ball\00"
@.str.3 = [3 x i8] c"ca\00"
@.str.4 = [4 x i8] c"car\00"
@.str.5 = [4 x i8] c"dad\00"
@__const.main.msg = [11 x i8*] [i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i32 0, i32 0)]
@__const.main.str = [4 x i8] c"dad\00"
@.str.6 = [8 x i8] c"%s: %d\0A\00"
define i32 @main() {
%1 = alloca [11 x i8*]
%2 = alloca [4 x i8]
%3 = bitcast [11 x i8*]* %1 to i8*
%4 = bitcast [4 x i8]* %2 to i8*
%5 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [11 x i8*], [11 x i8*]* %1, i64 0, i64 0
%7 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%8 = call i32 @search(i8** %6, i32 11, i8* %7)
%9 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i8* %5, i32 %8)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"at\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [5 x i8] c"ball\00"
@.str.3 = [3 x i8] c"ca\00"
@.str.4 = [4 x i8] c"car\00"
@.str.5 = [4 x i8] c"dad\00"
@__const.main.msg = [11 x i8*] [i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i32 0, i32 0)]
@.str.6 = [8 x i8] c"%s: %d\0A\00"
define i32 @main() {
%1 = alloca [11 x i8*]
%2 = alloca i32
%3 = bitcast [11 x i8*]* %1 to i8*
%4 = bitcast i32* %2 to i8*
store i32 6578532, i32* %2
%5 = getelementptr inbounds [11 x i8*], [11 x i8*]* %1, i64 0, i64 0
%6 = call i32 @search(i8** %5, i32 11, i8* %4)
%7 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i8* %4, i32 %6)
ret i32 0
}