#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*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ find_str(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ remove_newline(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int main(void) {
  char buf[50];
  fputs("Search: ", stdout);
  if (fgets(buf, 50, stdin) == NULL) {
    fprintf(stderr, "Err. when working with string %s\n", buf);
    exit(EXIT_FAILURE);
  }
  remove_newline(buf);
  find_str(buf);
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e52(%rip),%rax
mov    (%rax),%esi
lea    0xe81(%rip),%rdi
call   1050 <fputs@plt>
lea    -0x40(%rbp),%rdi
mov    0x2e59(%rip),%rax
mov    (%rax),%edx
mov    $0x32,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
jne    11cc <main+0x6c>
mov    0x2e2c(%rip),%rax
mov    (%rax),%edi
lea    -0x40(%rbp),%rdx
lea    0xe50(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2e0b(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
lea    -0x40(%rbp),%rdi
call   1030 <remove_newline@plt>
lea    -0x40(%rbp),%rdi
call   1040 <find_str@plt>
mov    0x2ddb(%rip),%rax
mov    (%rax),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
mov    0x2e5c(%rip),%rax
mov    (%rax),%esi
lea    0xe8b(%rip),%rdi
call   1050 <fputs@plt>
mov    0x2e67(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rdi
mov    $0x32,%esi
call   1060 <fgets@plt>
test   %rax,%rax
je     11b7 <main+0x57>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <remove_newline@plt>
mov    %rbx,%rdi
call   1040 <find_str@plt>
mov    0x2e11(%rip),%rax
mov    (%rax),%eax
add    $0x40,%rsp
pop    %rbx
ret
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
lea    0xe42(%rip),%rsi
mov    %rsp,%rdx
call   1070 <fprintf@plt>
mov    0x2dfa(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"Search: \00"
@stdout = global i32 0
@stdin = global i32 0
@stderr = global i32 0
@.str.1 = [34 x i8] c"Err. when working with string %s\0A\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [50 x i8]
store i32 0, i32* %1
%3 = load i32, i32* @stdout
%4 = call i32 @fputs(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%6 = load i32, i32* @stdin
%7 = call i32* @fgets(i8* %5, i32 50, i32 %6)
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %15
9: ; preds = %0
%10 = load i32, i32* @stderr
%11 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%12 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = load i32, i32* @EXIT_FAILURE
%14 = call i32 @exit(i32 %13)
unreachable
15: ; preds = %0
%16 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%17 = call i32 @remove_newline(i8* %16)
%18 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%19 = call i32 @find_str(i8* %18)
%20 = load i32, i32* @EXIT_SUCCESS
ret i32 %20
}

LLVM IR (-O2):
@.str = [9 x i8] c"Search: \00"
@stdout = global i32 0
@stdin = global i32 0
@stderr = global i32 0
@.str.1 = [34 x i8] c"Err. when working with string %s\0A\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca [50 x i8]
%2 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @stdout
%4 = tail call i32 @fputs(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = load i32, i32* @stdin
%6 = call i32* @fgets(i8* %2, i32 50, i32 %5)
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %13
8: ; preds = %0
%9 = load i32, i32* @stderr
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%11 = load i32, i32* @EXIT_FAILURE
%12 = call i32 @exit(i32 %11)
unreachable
13: ; preds = %0
%14 = call i32 @remove_newline(i8* %2)
%15 = call i32 @find_str(i8* %2)
%16 = load i32, i32* @EXIT_SUCCESS
ret i32 %16
}