#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[] = "Halli Hallo";
  char char_to_find = 'i';
  int index = 0;
  while (our_string[index] != '\0' && our_string[index] != char_to_find) {
    index += 1;
  }
  printf("'%c' is the %d character 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,-0x10(%rbp)
mov    0xed8(%rip),%eax
mov    %eax,-0x8(%rbp)
movb   $0x69,-0x11(%rbp)
movl   $0x0,-0x18(%rbp)
movslq -0x18(%rbp),%rax
movsbl -0x10(%rbp,%rax,1),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x19(%rbp)
je     116a <main+0x5a>
movslq -0x18(%rbp),%rax
movsbl -0x10(%rbp,%rax,1),%eax
movsbl -0x11(%rbp),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    117a <main+0x6a>
jmp    1188 <main+0x78>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    113e <main+0x2e>
mov    -0x11(%rbp),%al
mov    -0x18(%rbp),%edx
add    $0x1,%edx
lea    -0x10(%rbp),%rcx
lea    0xe70(%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 $0x614820696c6c6148,%rax
20 48 61
mov    %rax,0x8(%rsp)
movl   $0x6f6c6c,0x10(%rsp)
mov    $0x48,%al
mov    $0x1,%edx
test   %al,%al
je     1151 <main+0x41>
cs nopw 0x0(%rax,%rax,1)
cmp    $0x69,%al
je     1151 <main+0x41>
movzbl 0x8(%rsp,%rdx,1),%eax
add    $0x1,%rdx
test   %al,%al
jne    1140 <main+0x30>
lea    0xeb4(%rip),%rdi
lea    0x8(%rsp),%rcx
mov    $0x69,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

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

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