#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 *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int main(void) {
  char our_string[] = "Rhinozeros";
  char char_to_find;
  printf("You wanna search for the character:");
  scanf("%c", &char_to_find);
  int index = 0;
  while (our_string[index] != '\0' && our_string[index] != char_to_find) {
    index += 1;
  }
  printf("'%c' is the character #%d in '%s'!\n", char_to_find, index + 1,
         our_string);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0xf(%rbp)
mov    0xec7(%rip),%ax
mov    %ax,-0x7(%rbp)
mov    0xebf(%rip),%al
mov    %al,-0x5(%rbp)
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecc(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x14(%rbp)
movslq -0x14(%rbp),%rax
movsbl -0xf(%rbp,%rax,1),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x15(%rbp)
je     119f <main+0x7f>
movslq -0x14(%rbp),%rax
movsbl -0xf(%rbp,%rax,1),%eax
movsbl -0x10(%rbp),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    11af <main+0x8f>
jmp    11bd <main+0x9d>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1173 <main+0x53>
movsbl -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
add    $0x1,%edx
lea    -0xf(%rbp),%rcx
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
movabs $0x72657a6f6e696852,%rax
7a 65 72
mov    %rax,0x10(%rsp)
movl   $0x736f72,0x17(%rsp)
lea    0xec8(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xedc(%rip),%rdi
lea    0xf(%rsp),%rsi
call   1040 <scanf@plt>
movsbl 0xf(%rsp),%esi
cmp    $0x52,%esi
je     1182 <main+0x62>
xor    %ebx,%ebx
nopl   0x0(%rax)
movzbl 0x11(%rsp,%rbx,1),%eax
add    $0x1,%rbx
test   %al,%al
je     1182 <main+0x62>
cmp    %sil,%al
jne    1170 <main+0x50>
add    $0x1,%ebx
lea    0xea6(%rip),%rdi
lea    0x10(%rsp),%rcx
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.our_string = [11 x i8] c"Rhinozeros\00"
@.str = [36 x i8] c"You wanna search for the character:\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [36 x i8] c"'%c' is the character #%d in '%s'!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [11 x i8]
%3 = alloca i8
%4 = alloca i32
store i32 0, i32* %1
%5 = bitcast [11 x i8]* %2 to i8*
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
store i32 0, i32* %4
br label %8
8: ; preds = %26, %0
%9 = load i32, i32* %4
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 %10
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %24
15: ; preds = %8
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = load i8, i8* %3
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %20, %22
br label %24
24: ; preds = %15, %8
%25 = phi i1 [ false, %8 ], [ %23, %15 ]
br i1 %25, label %26, label %29
26: ; preds = %24
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 1
store i32 %28, i32* %4
br label %8
29: ; preds = %24
%30 = load i8, i8* %3
%31 = sext i8 %30 to i32
%32 = load i32, i32* %4
%33 = add nsw i32 %32, 1
%34 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 0
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i32 %31, i32 %33, i8* %34)
ret i32 0
}

LLVM IR (-O2):
@__const.main.our_string = [11 x i8] c"Rhinozeros\00"
@.str = [36 x i8] c"You wanna search for the character:\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [36 x i8] c"'%c' is the character #%d in '%s'!\0A\00"
define i32 @main() {
%1 = alloca [11 x i8]
%2 = alloca i8
%3 = getelementptr inbounds [11 x i8], [11 x i8]* %1, i64 0, i64 0
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%6 = load i8, i8* %2
%7 = icmp eq i8 %6, 82
br i1 %7, label %16, label %8
8: ; preds = %0, %8
%9 = phi i64 [ %15, %8 ], [ 1, %0 ]
%10 = getelementptr inbounds [11 x i8], [11 x i8]* %1, i64 0, i64 %9
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 0
%13 = icmp eq i8 %11, %6
%14 = select i1 %12, i1 true, i1 %13
%15 = add nuw i64 %9, 1
br i1 %14, label %16, label %8
16: ; preds = %8, %0
%17 = phi i64 [ 0, %0 ], [ %9, %8 ]
%18 = trunc i64 %17 to i32
%19 = sext i8 %6 to i32
%20 = add nuw nsw i32 %18, 1
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i32 %19, i32 %20, i8* %3)
ret i32 0
}