#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 str_search(char *);
int main(int argc, char *argv[]) {
  int res;
  if (argc > 1)
    res = str_search(argv[1]);
  else
    res = str_search("root");
  printf("The searched string was %sfound.\n", (res >= 0) ? "" : "NOT ");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1155 <main+0x35>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <str_search@plt>
mov    %eax,-0x14(%rbp)
jmp    1164 <main+0x44>
lea    0xea4(%rip),%rdi
call   1040 <str_search@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%ecx
lea    0xeb9(%rip),%rsi
lea    0xeb1(%rip),%rax
cmp    $0x0,%ecx
cmovge %rax,%rsi
lea    0xe82(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
cmp    $0x2,%edi
jl     112c <main+0xc>
mov    0x8(%rsi),%rdi
jmp    1133 <main+0x13>
lea    0xecd(%rip),%rdi
call   1040 <str_search@plt>
test   %eax,%eax
lea    0xee5(%rip),%rax
lea    0xedf(%rip),%rsi
cmovns %rax,%rsi
lea    0xeb2(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"root\00"
@.str.1 = [34 x i8] c"The searched string was %sfound.\0A\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [5 x i8] c"NOT \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp sgt i32 %7, 1
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i32 @str_search(i8* %12)
store i32 %13, i32* %6
br label %16
14: ; preds = %2
%15 = call i32 @str_search(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 %15, i32* %6
br label %16
16: ; preds = %14, %9
%17 = load i32, i32* %6
%18 = icmp sge i32 %17, 0
%19 = zext i1 %18 to i64
%20 = select i1 %18, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0)
%21 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* %20)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"root\00"
@.str.1 = [34 x i8] c"The searched string was %sfound.\0A\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [5 x i8] c"NOT \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
br label %7
7: ; preds = %2, %4
%8 = phi i8* [ %6, %4 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %2 ]
%9 = tail call i32 @str_search(i8* %8)
%10 = icmp sgt i32 %9, -1
%11 = select i1 %10, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* %11)
ret i32 0
}