#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 = 'x';
  int length = 0;
  while (our_string[length] != '\0') {
    length += 1;
  }
  int index = 0;
  while (our_string[index] != '\0' && our_string[index] != char_to_find) {
    index += 1;
  }
  if (length != index) {
    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   $0x78,-0x11(%rbp)
movl   $0x0,-0x18(%rbp)
movslq -0x18(%rbp),%rax
movsbl -0x10(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     115e <main+0x4e>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    113e <main+0x2e>
movl   $0x0,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
movsbl -0x10(%rbp,%rax,1),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x1d(%rbp)
je     1191 <main+0x81>
movslq -0x1c(%rbp),%rax
movsbl -0x10(%rbp,%rax,1),%eax
movsbl -0x11(%rbp),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    11a1 <main+0x91>
jmp    11af <main+0x9f>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1165 <main+0x55>
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
je     11d7 <main+0xc7>
mov    -0x11(%rbp),%al
mov    -0x1c(%rbp),%edx
add    $0x1,%edx
lea    -0x10(%rbp),%rcx
lea    0xe3d(%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)
xor    %eax,%eax
nopl   (%rax)
cmpb   $0x0,0x9(%rsp,%rax,1)
lea    0x1(%rax),%rax
jne    1130 <main+0x20>
mov    $0x48,%cl
xor    %edx,%edx
test   %cl,%cl
je     1162 <main+0x52>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmp    $0x78,%cl
je     1162 <main+0x52>
movzbl 0x9(%rsp,%rdx,1),%ecx
add    $0x1,%rdx
test   %cl,%cl
jne    1150 <main+0x40>
cmp    %edx,%eax
je     117f <main+0x6f>
add    $0x1,%edx
lea    0xe9c(%rip),%rdi
lea    0x8(%rsp),%rcx
mov    $0x78,%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
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [12 x i8]* %2 to i8*
store i8 120, i8* %3
store i32 0, i32* %4
br label %7
7: ; preds = %14, %0
%8 = load i32, i32* %4
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 %9
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %7
%15 = load i32, i32* %4
%16 = add nsw i32 %15, 1
store i32 %16, i32* %4
br label %7
17: ; preds = %7
store i32 0, i32* %5
br label %18
18: ; preds = %36, %17
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 %20
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %34
25: ; preds = %18
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = load i8, i8* %3
%32 = sext i8 %31 to i32
%33 = icmp ne i32 %30, %32
br label %34
34: ; preds = %25, %18
%35 = phi i1 [ false, %18 ], [ %33, %25 ]
br i1 %35, label %36, label %39
36: ; preds = %34
%37 = load i32, i32* %5
%38 = add nsw i32 %37, 1
store i32 %38, i32* %5
br label %18
39: ; preds = %34
%40 = load i32, i32* %4
%41 = load i32, i32* %5
%42 = icmp ne i32 %40, %41
br i1 %42, label %43, label %49
43: ; preds = %39
%44 = load i8, i8* %3
%45 = load i32, i32* %5
%46 = add nsw i32 %45, 1
%47 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
%48 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8 signext %44, i32 %46, i8* %47)
br label %49
49: ; preds = %43, %39
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 = %0, %3
%4 = phi i64 [ 1, %0 ], [ %8, %3 ]
%5 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 %4
%6 = load i8, i8* %5
%7 = icmp eq i8 %6, 0
%8 = add nuw i64 %4, 1
br i1 %7, label %9, label %3
9: ; preds = %3
%10 = trunc i64 %4 to i32
br label %11
11: ; preds = %9, %14
%12 = phi i8 [ 72, %9 ], [ %17, %14 ]
%13 = phi i64 [ 0, %9 ], [ %15, %14 ]
switch i8 %12, label %14 [
i8 0, label %18
i8 120, label %18
]
14: ; preds = %11
%15 = add nuw i64 %13, 1
%16 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 %15
%17 = load i8, i8* %16
br label %11
18: ; preds = %11, %11
%19 = trunc i64 %13 to i32
%20 = icmp eq i32 %10, %19
br i1 %20, label %24, label %21
21: ; preds = %18
%22 = add nuw nsw i32 %19, 1
%23 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8 signext 120, i32 %22, i8* %2)
br label %24
24: ; preds = %21, %18
ret i32 0
}