#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 *, ...);
size_t strlen(char *);
size_t strutil_index_of(char *, char);
int main(void) {
  char *str1 = "Hello, world!";
  size_t length = strlen(str1), index = 0;
  char H = 'H', w = 'w', x = 'x';
  index = strutil_index_of(str1, H);
  printf("The index of '%c' in \"%s\" is: ", H, str1);
  if (index < length) {
    printf("%lu\n", index);
  } else {
    printf("Does Not Exist\n");
  }
  index = strutil_index_of(str1, w);
  printf("The index of '%c' in \"%s\" is: ", w, str1);
  if (index < length) {
    printf("%lu\n", index);
  } else {
    printf("Does Not Exist\n");
  }
  index = strutil_index_of(str1, x);
  printf("The index of '%c' in \"%s\" is: ", x, str1);
  if (index == length) {
    printf("%lu\n", index);
  } else {
    printf("Does Not Exist\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movb   $0x48,-0x21(%rbp)
movb   $0x77,-0x22(%rbp)
movb   $0x78,-0x23(%rbp)
mov    -0x10(%rbp),%rdi
movsbl -0x21(%rbp),%esi
call   1050 <strutil_index_of@plt>
mov    %rax,-0x20(%rbp)
movsbl -0x21(%rbp),%esi
mov    -0x10(%rbp),%rdx
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11b7 <main+0x87>
mov    -0x20(%rbp),%rsi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11c5 <main+0x95>
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
movsbl -0x22(%rbp),%esi
call   1050 <strutil_index_of@plt>
mov    %rax,-0x20(%rbp)
movsbl -0x22(%rbp),%esi
mov    -0x10(%rbp),%rdx
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1211 <main+0xe1>
mov    -0x20(%rbp),%rsi
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    121f <main+0xef>
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
movsbl -0x23(%rbp),%esi
call   1050 <strutil_index_of@plt>
mov    %rax,-0x20(%rbp)
movsbl -0x23(%rbp),%esi
mov    -0x10(%rbp),%rdx
lea    0xdcf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jne    126b <main+0x13b>
mov    -0x20(%rbp),%rsi
lea    0xdce(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1279 <main+0x149>
lea    0xdc0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xec5(%rip),%r14
mov    %r14,%rdi
mov    $0x48,%esi
call   1050 <strutil_index_of@plt>
mov    %rax,%rbx
lea    0xebc(%rip),%rdi
mov    $0x48,%esi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0xc,%rbx
ja     117a <main+0x4a>
lea    0xebf(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1186 <main+0x56>
lea    0xeb1(%rip),%rdi
call   1030 <puts@plt>
lea    0xe73(%rip),%r14
mov    %r14,%rdi
mov    $0x77,%esi
call   1050 <strutil_index_of@plt>
mov    %rax,%rbx
lea    0xe6a(%rip),%rdi
mov    $0x77,%esi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0xc,%rbx
ja     11cc <main+0x9c>
lea    0xe6d(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11d8 <main+0xa8>
lea    0xe5f(%rip),%rdi
call   1030 <puts@plt>
lea    0xe21(%rip),%r14
mov    %r14,%rdi
mov    $0x78,%esi
call   1050 <strutil_index_of@plt>
mov    %rax,%rbx
lea    0xe18(%rip),%rdi
mov    $0x78,%esi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0xd,%rbx
jne    1220 <main+0xf0>
lea    0xe1b(%rip),%rdi
mov    $0xd,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    122c <main+0xfc>
lea    0xe0b(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Hello, world!\00"
@.str.1 = [31 x i8] c"The index of '%c' in \22%s\22 is: \00"
@.str.2 = [5 x i8] c"%lu\0A\00"
@.str.3 = [16 x i8] c"Does Not Exist\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i64
%5 = alloca i8
%6 = alloca i8
%7 = alloca i8
store i32 0, i32* %1
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8** %2
%8 = load i8*, i8** %2
%9 = call i64 @strlen(i8* %8)
store i64 %9, i64* %3
store i64 0, i64* %4
store i8 72, i8* %5
store i8 119, i8* %6
store i8 120, i8* %7
%10 = load i8*, i8** %2
%11 = load i8, i8* %5
%12 = call i64 @strutil_index_of(i8* %10, i8 signext %11)
store i64 %12, i64* %4
%13 = load i8, i8* %5
%14 = sext i8 %13 to i32
%15 = load i8*, i8** %2
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %14, i8* %15)
%17 = load i64, i64* %4
%18 = load i64, i64* %3
%19 = icmp ult i64 %17, %18
br i1 %19, label %20, label %23
20: ; preds = %0
%21 = load i64, i64* %4
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %21)
br label %25
23: ; preds = %0
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %25
25: ; preds = %23, %20
%26 = load i8*, i8** %2
%27 = load i8, i8* %6
%28 = call i64 @strutil_index_of(i8* %26, i8 signext %27)
store i64 %28, i64* %4
%29 = load i8, i8* %6
%30 = sext i8 %29 to i32
%31 = load i8*, i8** %2
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %30, i8* %31)
%33 = load i64, i64* %4
%34 = load i64, i64* %3
%35 = icmp ult i64 %33, %34
br i1 %35, label %36, label %39
36: ; preds = %25
%37 = load i64, i64* %4
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %37)
br label %41
39: ; preds = %25
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %41
41: ; preds = %39, %36
%42 = load i8*, i8** %2
%43 = load i8, i8* %7
%44 = call i64 @strutil_index_of(i8* %42, i8 signext %43)
store i64 %44, i64* %4
%45 = load i8, i8* %7
%46 = sext i8 %45 to i32
%47 = load i8*, i8** %2
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %46, i8* %47)
%49 = load i64, i64* %4
%50 = load i64, i64* %3
%51 = icmp eq i64 %49, %50
br i1 %51, label %52, label %55
52: ; preds = %41
%53 = load i64, i64* %4
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %53)
br label %57
55: ; preds = %41
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %57
57: ; preds = %55, %52
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"Hello, world!\00"
@.str.1 = [31 x i8] c"The index of '%c' in \22%s\22 is: \00"
@.str.2 = [5 x i8] c"%lu\0A\00"
@str.5 = [15 x i8] c"Does Not Exist\00"
define i32 @main() {
%1 = tail call i64 @strutil_index_of(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8 signext 72)
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 72, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%3 = icmp ult i64 %1, 13
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %1)
br label %8
6: ; preds = %0
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.5, i64 0, i64 0))
br label %8
8: ; preds = %6, %4
%9 = tail call i64 @strutil_index_of(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8 signext 119)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 119, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%11 = icmp ult i64 %9, 13
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %9)
br label %16
14: ; preds = %8
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.5, i64 0, i64 0))
br label %16
16: ; preds = %14, %12
%17 = tail call i64 @strutil_index_of(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8 signext 120)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 120, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i64 %17, 13
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 13)
br label %24
22: ; preds = %16
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.5, i64 0, i64 0))
br label %24
24: ; preds = %22, %20
ret i32 0
}