#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, char *);
int main(void) {
  char our_string[] = "Rhinozeros";
  char char_to_find = 'z';
  int index = 0;
  while (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    0xeda(%rip),%rax
mov    %rax,-0xf(%rbp)
mov    0xed7(%rip),%ax
mov    %ax,-0x7(%rbp)
mov    0xecf(%rip),%al
mov    %al,-0x5(%rbp)
movb   $0x7a,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movslq -0x14(%rbp),%rax
movsbl -0xf(%rbp,%rax,1),%eax
movsbl -0x10(%rbp),%ecx
cmp    %ecx,%eax
je     116c <main+0x5c>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1149 <main+0x39>
mov    -0x10(%rbp),%al
mov    -0x14(%rbp),%edx
add    $0x1,%edx
lea    -0xf(%rbp),%rcx
lea    0xe8b(%rip),%rdi
movsbl %al,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
movabs $0x72657a6f6e696852,%rax
7a 65 72
mov    %rax,0x8(%rsp)
movl   $0x736f72,0xf(%rsp)
mov    $0x1,%edx
cmpb   $0x7a,0x8(%rsp,%rdx,1)
lea    0x1(%rdx),%rdx
jne    1130 <main+0x20>
lea    0xec9(%rip),%rdi
lea    0x8(%rsp),%rcx
mov    $0x7a,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@__const.main.our_string = [11 x i8] c"Rhinozeros\00"
@.str = [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*
store i8 122, i8* %3
store i32 0, i32* %4
br label %6
6: ; preds = %15, %0
%7 = load i32, i32* %4
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 %8
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = load i8, i8* %3
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %11, %13
br i1 %14, label %15, label %18
15: ; preds = %6
%16 = load i32, i32* %4
%17 = add nsw i32 %16, 1
store i32 %17, i32* %4
br label %6
18: ; preds = %6
%19 = load i8, i8* %3
%20 = load i32, i32* %4
%21 = add nsw i32 %20, 1
%22 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 0
%23 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8 signext %19, i32 %21, i8* %22)
ret i32 0
}

LLVM IR (-O2):
@__const.main.our_string = [11 x i8] c"Rhinozeros\00"
@.str = [36 x i8] c"'%c' is the character #%d in '%s'!\0A\00"
define i32 @main() {
%1 = alloca [11 x i8]
%2 = getelementptr inbounds [11 x i8], [11 x i8]* %1, i64 0, i64 0
br label %3
3: ; preds = %0, %3
%4 = phi i64 [ 1, %0 ], [ %8, %3 ]
%5 = getelementptr inbounds [11 x i8], [11 x i8]* %1, i64 0, i64 %4
%6 = load i8, i8* %5
%7 = icmp eq i8 %6, 122
%8 = add nuw i64 %4, 1
br i1 %7, label %9, label %3
9: ; preds = %3
%10 = trunc i64 %4 to i32
%11 = add nuw nsw i32 %10, 1
%12 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8 signext 122, i32 %11, i8* %2)
ret i32 0
}