#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 */
scalar_t__ sdb_calloc(int, int);
scalar_t__ strcmp(char *, char *);
int *num_champs(char **big, int nb_big, char **small, int nb_small) {
  int i, j;
  int *res;
  res = (int *)sdb_calloc(nb_small, sizeof(int));
  for (i = 0; i < nb_small; i++) {
    res[i] = -1;
    for (j = 0; j < nb_big; j++) {
      if (strcmp(big[j], small[i]) == 0) {
        res[i] = j;
      }
    }
  }
  return (res);
}


x86 assembly (clang, -O0):
<num_champs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
mov    $0x4,%esi
call   1030 <sdb_calloc@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11d7 <num_champs+0xb7>
mov    -0x30(%rbp),%rax
movslq -0x20(%rbp),%rcx
movl   $0xffffffff,(%rax,%rcx,4)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11c4 <num_champs+0xa4>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11b1 <num_champs+0x91>
mov    -0x24(%rbp),%edx
mov    -0x30(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
jmp    11b6 <num_champs+0x96>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1170 <num_champs+0x50>
jmp    11c9 <num_champs+0xa9>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    114e <num_champs+0x2e>
mov    -0x30(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<num_champs>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,%r12d
mov    %rdx,%r13
mov    %esi,0xc(%rsp)
mov    %rdi,%rbp
mov    %ecx,%edi
mov    $0x4,%esi
call   1030 <sdb_calloc@plt>
mov    %rax,%r15
test   %r12d,%r12d
jle    11a3 <num_champs+0x83>
mov    %r12d,%eax
mov    %rax,0x10(%rsp)
mov    0xc(%rsp),%ebx
xor    %r14d,%r14d
jmp    116b <num_champs+0x4b>
add    $0x1,%r14
cmp    0x10(%rsp),%r14
je     11a3 <num_champs+0x83>
movl   $0xffffffff,(%r15,%r14,4)
ff
cmpl   $0x0,0xc(%rsp)
jle    1160 <num_champs+0x40>
xor    %r12d,%r12d
jmp    1189 <num_champs+0x69>
nop
add    $0x1,%r12
cmp    %r12,%rbx
je     1160 <num_champs+0x40>
mov    0x0(%rbp,%r12,8),%rdi
mov    0x0(%r13,%r14,8),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1180 <num_champs+0x60>
mov    %r12d,(%r15,%r14,4)
jmp    1180 <num_champs+0x60>
mov    %r15,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32* @num_champs(i8** %0, i32 %1, i8** %2, i32 %3) {
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32*
store i8** %0, i8*** %5
store i32 %1, i32* %6
store i8** %2, i8*** %7
store i32 %3, i32* %8
%12 = load i32, i32* %8
%13 = call i64 @sdb_calloc(i32 %12, i32 4)
%14 = inttoptr i64 %13 to i32*
store i32* %14, i32** %11
store i32 0, i32* %9
br label %15
15: ; preds = %52, %4
%16 = load i32, i32* %9
%17 = load i32, i32* %8
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %55
19: ; preds = %15
%20 = load i32*, i32** %11
%21 = load i32, i32* %9
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i32, i32* %20, i64 %22
store i32 -1, i32* %23
store i32 0, i32* %10
br label %24
24: ; preds = %48, %19
%25 = load i32, i32* %10
%26 = load i32, i32* %6
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %51
28: ; preds = %24
%29 = load i8**, i8*** %5
%30 = load i32, i32* %10
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8*, i8** %29, i64 %31
%33 = load i8*, i8** %32
%34 = load i8**, i8*** %7
%35 = load i32, i32* %9
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8*, i8** %34, i64 %36
%38 = load i8*, i8** %37
%39 = call i64 @strcmp(i8* %33, i8* %38)
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %47
41: ; preds = %28
%42 = load i32, i32* %10
%43 = load i32*, i32** %11
%44 = load i32, i32* %9
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i32, i32* %43, i64 %45
store i32 %42, i32* %46
br label %47
47: ; preds = %41, %28
br label %48
48: ; preds = %47
%49 = load i32, i32* %10
%50 = add nsw i32 %49, 1
store i32 %50, i32* %10
br label %24
51: ; preds = %24
br label %52
52: ; preds = %51
%53 = load i32, i32* %9
%54 = add nsw i32 %53, 1
store i32 %54, i32* %9
br label %15
55: ; preds = %15
%56 = load i32*, i32** %11
ret i32* %56
}

LLVM IR (-O2):
define i32* @num_champs(i8** nocapture %0, i32 %1, i8** nocapture %2, i32 %3) {
%5 = tail call i64 @sdb_calloc(i32 %3, i32 4)
%6 = inttoptr i64 %5 to i32*
%7 = icmp sgt i32 %3, 0
br i1 %7, label %8, label %32
8: ; preds = %4
%9 = icmp sgt i32 %1, 0
%10 = zext i32 %3 to i64
%11 = zext i32 %1 to i64
br label %12
12: ; preds = %8, %29
%13 = phi i64 [ 0, %8 ], [ %30, %29 ]
%14 = getelementptr inbounds i32, i32* %6, i64 %13
store i32 -1, i32* %14
br i1 %9, label %15, label %29
15: ; preds = %12
%16 = getelementptr inbounds i8*, i8** %2, i64 %13
br label %17
17: ; preds = %15, %26
%18 = phi i64 [ 0, %15 ], [ %27, %26 ]
%19 = getelementptr inbounds i8*, i8** %0, i64 %18
%20 = load i8*, i8** %19
%21 = load i8*, i8** %16
%22 = tail call i64 @strcmp(i8* %20, i8* %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %17
%25 = trunc i64 %18 to i32
store i32 %25, i32* %14
br label %26
26: ; preds = %17, %24
%27 = add nuw nsw i64 %18, 1
%28 = icmp eq i64 %27, %11
br i1 %28, label %29, label %17
29: ; preds = %26, %12
%30 = add nuw nsw i64 %13, 1
%31 = icmp eq i64 %30, %10
br i1 %31, label %32, label %12
32: ; preds = %29, %4
ret i32* %6
}