#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 */
scalar_t__ lgetline(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int strindex(char *, char);
int main(void) {
  char line[1000];
  int found = 0;
  while (lgetline(line, 1000) > 0) {
    if ((found = strindex(line, 'a')) >= 0)
      printf("found at %d\n", found);
    else if (found < 0)
      printf("There isn't an occurence of t in s\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x3f4(%rbp)
lea    -0x3f0(%rbp),%rdi
mov    $0x3e8,%esi
call   1040 <lgetline@plt>
cmp    $0x0,%rax
jle    11c5 <main+0x95>
lea    -0x3f0(%rbp),%rdi
mov    $0x61,%esi
call   1050 <strindex@plt>
mov    %eax,-0x3f4(%rbp)
cmp    $0x0,%eax
jl     11a0 <main+0x70>
mov    -0x3f4(%rbp),%esi
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c0 <main+0x90>
cmpl   $0x0,-0x3f4(%rbp)
jge    11bb <main+0x8b>
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c0 <main+0x90>
jmp    114c <main+0x1c>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x3f0,%rsp
mov    %rsp,%rdi
mov    $0x3e8,%esi
call   1050 <lgetline@plt>
test   %rax,%rax
jle    11b9 <main+0x79>
mov    %rsp,%rbx
lea    0xe98(%rip),%r14
lea    0xe9e(%rip),%r15
jmp    119a <main+0x5a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0x3e8,%esi
call   1050 <lgetline@plt>
test   %rax,%rax
jle    11b9 <main+0x79>
mov    %rbx,%rdi
mov    $0x61,%esi
call   1060 <strindex@plt>
test   %eax,%eax
js     1180 <main+0x40>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1188 <main+0x48>
xor    %eax,%eax
add    $0x3f0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [13 x i8] c"found at %d\0A\00"
@.str.1 = [36 x i8] c"There isn't an occurence of t in s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1000 x i8]
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
br label %4
4: ; preds = %21, %0
%5 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%6 = call i64 @lgetline(i8* %5, i32 1000)
%7 = icmp sgt i64 %6, 0
br i1 %7, label %8, label %22
8: ; preds = %4
%9 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%10 = call i32 @strindex(i8* %9, i8 signext 97)
store i32 %10, i32* %3
%11 = icmp sge i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %8
%13 = load i32, i32* %3
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %13)
br label %21
15: ; preds = %8
%16 = load i32, i32* %3
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
br label %20
20: ; preds = %18, %15
br label %21
21: ; preds = %20, %12
br label %4
22: ; preds = %4
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"found at %d\0A\00"
@str = [35 x i8] c"There isn't an occurence of t in s\00"
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%3 = call i64 @lgetline(i8* %2, i32 1000)
%4 = icmp sgt i64 %3, 0
br i1 %4, label %5, label %15
5: ; preds = %0, %12
%6 = call i32 @strindex(i8* %2, i8 signext 97)
%7 = icmp sgt i32 %6, -1
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %6)
br label %12
10: ; preds = %5
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
br label %12
12: ; preds = %10, %8
%13 = call i64 @lgetline(i8* %2, i32 1000)
%14 = icmp sgt i64 %13, 0
br i1 %14, label %5, label %15
15: ; preds = %12, %0
ret i32 0
}