#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 */
double atof(char *);
int atoi(char *);
int /*<<< orphan*/ getop(char *);
int /*<<< orphan*/ itoa(int, char *);
scalar_t__ lgetline(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ reverse(char *);
int strindex(char *, char);
int main(void) {
  char line[1000];
  char s[20];
  char op[20];
  int found;
  while (lgetline(line, 1000) > 0) {
    printf("Line: %s\n", line);
    if ((found = strindex(line, 'a')) >= 0)
      printf("stindex:Char 'a' found at %d\n", found);
    else if (found < 0)
      printf("There isn't an occurence of t in s\n");
  }
  itoa(5296, s);
  reverse(s);
  printf("\nitoa result = %s\n", s);
  printf("\natoi result = %d\n", atoi(s));
  printf("\natof result = %g\n", atof("123e-1"));
  if (getop(op) == '0')
    printf("\nA number was found %s\n", op);
  else
    printf("\nAn operator or something else was found\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x3f0(%rbp),%rdi
mov    $0x3e8,%esi
call   1060 <lgetline@plt>
cmp    $0x0,%rax
jle    1220 <main+0xa0>
lea    -0x3f0(%rbp),%rsi
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x3f0(%rbp),%rdi
mov    $0x61,%esi
call   1080 <strindex@plt>
mov    %eax,-0x434(%rbp)
cmp    $0x0,%eax
jl     11fb <main+0x7b>
mov    -0x434(%rbp),%esi
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    121b <main+0x9b>
cmpl   $0x0,-0x434(%rbp)
jge    1216 <main+0x96>
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    121b <main+0x9b>
jmp    1192 <main+0x12>
lea    -0x410(%rbp),%rsi
mov    $0x14b0,%edi
call   10a0 <itoa@plt>
lea    -0x410(%rbp),%rdi
call   1030 <reverse@plt>
lea    -0x410(%rbp),%rsi
lea    0xe01(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x410(%rbp),%rdi
call   1090 <atoi@plt>
mov    %eax,%esi
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe10(%rip),%rdi
call   1040 <atof@plt>
lea    0xdf1(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    -0x430(%rbp),%rdi
call   1070 <getop@plt>
cmp    $0x30,%eax
jne    12b7 <main+0x137>
lea    -0x430(%rbp),%rsi
lea    0xde1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    12c5 <main+0x145>
lea    0xde6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x428,%rsp
lea    0x40(%rsp),%rdi
mov    $0x3e8,%esi
call   1070 <lgetline@plt>
test   %rax,%rax
jle    1216 <main+0x86>
lea    0xe47(%rip),%r14
lea    0x40(%rsp),%rbx
lea    0xe45(%rip),%r15
lea    0xedd(%rip),%r12
jmp    11ea <main+0x5a>
xchg   %ax,%ax
mov    %r12,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    $0x3e8,%esi
call   1070 <lgetline@plt>
test   %rax,%rax
jle    1216 <main+0x86>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    $0x61,%esi
call   1090 <strindex@plt>
test   %eax,%eax
js     11d0 <main+0x40>
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    11d8 <main+0x48>
lea    0x20(%rsp),%rbx
mov    $0x14b0,%edi
mov    %rbx,%rsi
call   10b0 <itoa@plt>
mov    %rbx,%rdi
call   1030 <reverse@plt>
lea    0xdf1(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   10a0 <atoi@plt>
lea    0xdeb(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe01(%rip),%rdi
call   1050 <atof@plt>
lea    0xde2(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    %rsp,%rdi
call   1080 <getop@plt>
cmp    $0x30,%eax
jne    1293 <main+0x103>
lea    0xde1(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    129f <main+0x10f>
lea    0xde6(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x428,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [10 x i8] c"Line: %s\0A\00"
@.str.1 = [30 x i8] c"stindex:Char 'a' found at %d\0A\00"
@.str.2 = [36 x i8] c"There isn't an occurence of t in s\0A\00"
@.str.3 = [19 x i8] c"\0Aitoa result = %s\0A\00"
@.str.4 = [19 x i8] c"\0Aatoi result = %d\0A\00"
@.str.5 = [19 x i8] c"\0Aatof result = %g\0A\00"
@.str.6 = [7 x i8] c"123e-1\00"
@.str.7 = [24 x i8] c"\0AA number was found %s\0A\00"
@.str.8 = [42 x i8] c"\0AAn operator or something else was found\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1000 x i8]
%3 = alloca [20 x i8]
%4 = alloca [20 x i8]
%5 = alloca i32
store i32 0, i32* %1
br label %6
6: ; preds = %25, %0
%7 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%8 = call i64 @lgetline(i8* %7, i32 1000)
%9 = icmp sgt i64 %8, 0
br i1 %9, label %10, label %26
10: ; preds = %6
%11 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%14 = call i32 @strindex(i8* %13, i8 signext 97)
store i32 %14, i32* %5
%15 = icmp sge i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %10
%17 = load i32, i32* %5
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %17)
br label %25
19: ; preds = %10
%20 = load i32, i32* %5
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
br label %24
24: ; preds = %22, %19
br label %25
25: ; preds = %24, %16
br label %6
26: ; preds = %6
%27 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%28 = call i32 @itoa(i32 5296, i8* %27)
%29 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%30 = call i32 @reverse(i8* %29)
%31 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %31)
%33 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%34 = call i32 @atoi(i8* %33)
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %34)
%36 = call double @atof(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), double %36)
%38 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%39 = call i32 @getop(i8* %38)
%40 = icmp eq i32 %39, 48
br i1 %40, label %41, label %44
41: ; preds = %26
%42 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i8* %42)
br label %46
44: ; preds = %26
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.8, i64 0, i64 0))
br label %46
46: ; preds = %44, %41
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"Line: %s\0A\00"
@.str.1 = [30 x i8] c"stindex:Char 'a' found at %d\0A\00"
@.str.3 = [19 x i8] c"\0Aitoa result = %s\0A\00"
@.str.4 = [19 x i8] c"\0Aatoi result = %d\0A\00"
@.str.5 = [19 x i8] c"\0Aatof result = %g\0A\00"
@.str.6 = [7 x i8] c"123e-1\00"
@.str.7 = [24 x i8] c"\0AA number was found %s\0A\00"
@str = [41 x i8] c"\0AAn operator or something else was found\00"
@str.9 = [35 x i8] c"There isn't an occurence of t in s\00"
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = alloca [20 x i8]
%3 = alloca [20 x i8]
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%7 = call i64 @lgetline(i8* %4, i32 1000)
%8 = icmp sgt i64 %7, 0
br i1 %8, label %9, label %20
9: ; preds = %0, %17
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %4)
%11 = call i32 @strindex(i8* %4, i8 signext 97)
%12 = icmp sgt i32 %11, -1
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %11)
br label %17
15: ; preds = %9
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.9, i64 0, i64 0))
br label %17
17: ; preds = %15, %13
%18 = call i64 @lgetline(i8* %4, i32 1000)
%19 = icmp sgt i64 %18, 0
br i1 %19, label %9, label %20
20: ; preds = %17, %0
%21 = call i32 @itoa(i32 5296, i8* %5)
%22 = call i32 @reverse(i8* %5)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %5)
%24 = call i32 @atoi(i8* %5)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %24)
%26 = call double @atof(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), double %26)
%28 = call i32 @getop(i8* %6)
%29 = icmp eq i32 %28, 48
br i1 %29, label %30, label %32
30: ; preds = %20
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i8* %6)
br label %34
32: ; preds = %20
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str, i64 0, i64 0))
br label %34
34: ; preds = %32, %30
ret i32 0
}