#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 */
typedef int /*<<< orphan*/ a;

/* Variables and functions */
int /*<<< orphan*/ findstring(char **, int /*<<< orphan*/, int, char *);
int /*<<< orphan*/ printf(char *, char *);
void main() {
  char *a[] = {"ab", "", "bs"};
  for (int i = 0; i < (sizeof(a) / sizeof a[0]); i++) {
    printf("%s\n", a[i]);
  }
  int len = (sizeof(a) / sizeof a[0]);
  findstring(a, 0, len, "bs");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x2cd1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2cce(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0x2ccb(%rip),%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
movslq -0x24(%rbp),%rax
cmp    $0x3,%rax
jae    1181 <main+0x61>
movslq -0x24(%rbp),%rax
mov    -0x20(%rbp,%rax,8),%rsi
lea    0xe98(%rip),%rdi
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1150 <main+0x30>
movl   $0x3,-0x28(%rbp)
lea    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%edx
xor    %esi,%esi
lea    0xe6b(%rip),%rcx
call   1030 <findstring@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    0x2ce2(%rip),%rax
mov    %rax,0x10(%rsp)
movaps 0x2cc6(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xec1(%rip),%rbx
lea    0xeb4(%rip),%rsi
mov    %rbx,%rdi
call   1040 <printf@plt>
lea    0xeae(%rip),%rsi
mov    %rbx,%rdi
call   1040 <printf@plt>
lea    0xe99(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0x3,%edx
mov    %r14,%rcx
call   1030 <findstring@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"ab\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [3 x i8] c"bs\00"
@__const.main.a = [3 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 ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0)]
@.str.3 = [4 x i8] c"%s\0A\00"
define void @main() {
%1 = alloca [3 x i8*]
%2 = alloca i32
%3 = alloca i32
%4 = bitcast [3 x i8*]* %1 to i8*
store i32 0, i32* %2
br label %5
5: ; preds = %15, %0
%6 = load i32, i32* %2
%7 = sext i32 %6 to i64
%8 = icmp ult i64 %7, 3
br i1 %8, label %9, label %18
9: ; preds = %5
%10 = load i32, i32* %2
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [3 x i8*], [3 x i8*]* %1, i64 0, i64 %11
%13 = load i8*, i8** %12
%14 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %13)
br label %15
15: ; preds = %9
%16 = load i32, i32* %2
%17 = add nsw i32 %16, 1
store i32 %17, i32* %2
br label %5
18: ; preds = %5
store i32 3, i32* %3
%19 = getelementptr inbounds [3 x i8*], [3 x i8*]* %1, i64 0, i64 0
%20 = load i32, i32* %3
%21 = call i32 @findstring(i8** %19, i32 0, i32 %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"ab\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [3 x i8] c"bs\00"
@__const.main.a = [3 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 ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0)]
@.str.3 = [4 x i8] c"%s\0A\00"
define void @main() {
%1 = alloca [3 x i8*]
%2 = bitcast [3 x i8*]* %1 to i8*
%3 = getelementptr inbounds [3 x i8*], [3 x i8*]* %1, i64 0, i64 0
%4 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @findstring(i8** %3, i32 0, i32 3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
ret void
}