#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 EXIT_SUCCESS;
int lookup(char *, char **);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, char *);
int main(int argc, char *argv[]) {
  char str_input[20];
  char *flab[] = {"O'Reilly", "Wrox", "Elsevier", "Pearson",
                  "Apogeo",   "Sams", NULL};
  printf("String: ");
  scanf("%s", str_input);
  int test = lookup(str_input, flab);
  if (test >= 0)
    puts("stringa trovata");
  else
    puts("stringa non trovata");
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x38,%edx
call   1050 <memset@plt>
lea    0xe80(%rip),%rax
mov    %rax,-0x70(%rbp)
lea    0xe7e(%rip),%rax
mov    %rax,-0x68(%rbp)
lea    0xe78(%rip),%rax
mov    %rax,-0x60(%rbp)
lea    0xe76(%rip),%rax
mov    %rax,-0x58(%rbp)
lea    0xe73(%rip),%rax
mov    %rax,-0x50(%rbp)
lea    0xe6f(%rip),%rax
mov    %rax,-0x48(%rbp)
lea    0xe69(%rip),%rdi
call   1040 <printf@plt>
lea    -0x30(%rbp),%rsi
lea    0xe62(%rip),%rdi
call   1070 <scanf@plt>
lea    -0x30(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1060 <lookup@plt>
mov    %eax,-0x74(%rbp)
cmpl   $0x0,-0x74(%rbp)
jl     1202 <main+0xb2>
lea    0xe3f(%rip),%rdi
call   1030 <puts@plt>
jmp    120e <main+0xbe>
lea    0xe3e(%rip),%rdi
call   1030 <puts@plt>
mov    0x2dcb(%rip),%rax
mov    (%rax),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x60,%rsp
movq   $0x0,0x30(%rsp)
lea    0xeab(%rip),%rax
mov    %rax,(%rsp)
lea    0xea9(%rip),%rax
mov    %rax,0x8(%rsp)
lea    0xea2(%rip),%rax
mov    %rax,0x10(%rsp)
lea    0xe9f(%rip),%rax
mov    %rax,0x18(%rsp)
lea    0xe9b(%rip),%rax
mov    %rax,0x20(%rsp)
lea    0xe96(%rip),%rax
mov    %rax,0x28(%rsp)
lea    0xe8f(%rip),%rdi
call   1040 <printf@plt>
lea    0xe8c(%rip),%rdi
lea    0x40(%rsp),%rbx
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1050 <lookup@plt>
test   %eax,%eax
lea    0xe6e(%rip),%rax
lea    0xe77(%rip),%rdi
cmovns %rax,%rdi
call   1030 <puts@plt>
mov    0x2e00(%rip),%rax
mov    (%rax),%eax
add    $0x60,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [9 x i8] c"O'Reilly\00"
@.str.1 = [5 x i8] c"Wrox\00"
@.str.2 = [9 x i8] c"Elsevier\00"
@.str.3 = [8 x i8] c"Pearson\00"
@.str.4 = [7 x i8] c"Apogeo\00"
@.str.5 = [5 x i8] c"Sams\00"
@.str.6 = [9 x i8] c"String: \00"
@.str.7 = [3 x i8] c"%s\00"
@.str.8 = [16 x i8] c"stringa trovata\00"
@.str.9 = [20 x i8] c"stringa non trovata\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [20 x i8]
%7 = alloca [7 x i8*]
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = bitcast [7 x i8*]* %7 to i8*
%10 = bitcast i8* %9 to [7 x i8*]*
%11 = getelementptr inbounds [7 x i8*], [7 x i8*]* %10, i32 0, i32 0
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i32 0, i32 0), i8** %11
%12 = getelementptr inbounds [7 x i8*], [7 x i8*]* %10, i32 0, i32 1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i8** %12
%13 = getelementptr inbounds [7 x i8*], [7 x i8*]* %10, i32 0, i32 2
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i32 0, i32 0), i8** %13
%14 = getelementptr inbounds [7 x i8*], [7 x i8*]* %10, i32 0, i32 3
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i32 0, i32 0), i8** %14
%15 = getelementptr inbounds [7 x i8*], [7 x i8*]* %10, i32 0, i32 4
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i32 0, i32 0), i8** %15
%16 = getelementptr inbounds [7 x i8*], [7 x i8*]* %10, i32 0, i32 5
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i32 0, i32 0), i8** %16
%17 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%18 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %18)
%20 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%21 = getelementptr inbounds [7 x i8*], [7 x i8*]* %7, i64 0, i64 0
%22 = call i32 @lookup(i8* %20, i8** %21)
store i32 %22, i32* %8
%23 = load i32, i32* %8
%24 = icmp sge i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %2
%26 = call i32 @puts(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0))
br label %29
27: ; preds = %2
%28 = call i32 @puts(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0))
br label %29
29: ; preds = %27, %25
%30 = load i32, i32* @EXIT_SUCCESS
ret i32 %30
}

LLVM IR (-O2):
@.str = [9 x i8] c"O'Reilly\00"
@.str.1 = [5 x i8] c"Wrox\00"
@.str.2 = [9 x i8] c"Elsevier\00"
@.str.3 = [8 x i8] c"Pearson\00"
@.str.4 = [7 x i8] c"Apogeo\00"
@.str.5 = [5 x i8] c"Sams\00"
@.str.6 = [9 x i8] c"String: \00"
@.str.7 = [3 x i8] c"%s\00"
@.str.8 = [16 x i8] c"stringa trovata\00"
@.str.9 = [20 x i8] c"stringa non trovata\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [20 x i8]
%4 = alloca [7 x i8*]
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%6 = bitcast [7 x i8*]* %4 to i8*
%7 = getelementptr inbounds [7 x i8*], [7 x i8*]* %4, i64 0, i64 6
%8 = bitcast i8** %7 to i64*
store i64 0, i64* %8
%9 = getelementptr inbounds [7 x i8*], [7 x i8*]* %4, i64 0, i64 0
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8** %9
%10 = getelementptr inbounds [7 x i8*], [7 x i8*]* %4, i64 0, i64 1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %10
%11 = getelementptr inbounds [7 x i8*], [7 x i8*]* %4, i64 0, i64 2
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8** %11
%12 = getelementptr inbounds [7 x i8*], [7 x i8*]* %4, i64 0, i64 3
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8** %12
%13 = getelementptr inbounds [7 x i8*], [7 x i8*]* %4, i64 0, i64 4
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8** %13
%14 = getelementptr inbounds [7 x i8*], [7 x i8*]* %4, i64 0, i64 5
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8** %14
%15 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %5)
%17 = call i32 @lookup(i8* %5, i8** %9)
%18 = icmp sgt i32 %17, -1
%19 = select i1 %18, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0)
%20 = call i32 @puts(i8* dereferenceable(1) %19)
%21 = load i32, i32* @EXIT_SUCCESS
ret i32 %21
}