#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 atoi(char *);
int getline(char *, int);
int /*<<< orphan*/ itoa(int, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ reverse(char *);
int strindex(char *, char *);
int main(void) {
  int lim = 10;
  char str1[1000];
  int length;
  length = getline(str1, lim);
  printf("%d\n", length);
  char *str2 = "1234";
  printf("%d\n", atoi(str2));
  char str3[] = "teststring";
  reverse(str3);
  printf("%s\n", str3);
  int n = 1002;
  char s[1000];
  itoa(n, s);
  printf("%s\n", s);
  char s4[] = "biglong string";
  char s5[] = "long";
  printf("%d\n", strindex(s4, s5));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%rsp
movl   $0xa,-0x4(%rbp)
lea    -0x3f0(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1070 <getline@plt>
mov    %eax,-0x3f4(%rbp)
mov    -0x3f4(%rbp),%esi
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe62(%rip),%rax
mov    %rax,-0x400(%rbp)
mov    -0x400(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,%esi
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0xe3d(%rip),%rax
mov    %rax,-0x40b(%rbp)
mov    0xe37(%rip),%ax
mov    %ax,-0x403(%rbp)
mov    0xe2c(%rip),%al
mov    %al,-0x401(%rbp)
lea    -0x40b(%rbp),%rdi
call   1030 <reverse@plt>
lea    -0x40b(%rbp),%rsi
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x3ea,-0x410(%rbp)
mov    -0x410(%rbp),%edi
lea    -0x800(%rbp),%rsi
call   1080 <itoa@plt>
lea    -0x800(%rbp),%rsi
lea    0xddc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0xdd2(%rip),%rax
mov    %rax,-0x80f(%rbp)
mov    0xdcd(%rip),%eax
mov    %eax,-0x807(%rbp)
mov    0xdc4(%rip),%ax
mov    %ax,-0x803(%rbp)
mov    0xdb9(%rip),%al
mov    %al,-0x801(%rbp)
mov    0xdae(%rip),%eax
mov    %eax,-0x814(%rbp)
mov    0xda6(%rip),%al
mov    %al,-0x810(%rbp)
lea    -0x80f(%rbp),%rdi
lea    -0x814(%rbp),%rsi
call   1050 <strindex@plt>
mov    %eax,%esi
lea    0xd59(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x808,%rsp
lea    0x420(%rsp),%rdi
mov    $0xa,%esi
call   1070 <getline@plt>
lea    0xe7d(%rip),%r14
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    $0x4d2,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movabs $0x6972747374736574,%rax
74 72 69
mov    %rax,0x10(%rsp)
movl   $0x676e69,0x17(%rsp)
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <reverse@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
lea    0x30(%rsp),%rbx
mov    $0x3ea,%edi
mov    %rbx,%rsi
call   1080 <itoa@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
movabs $0x676e6972747320,%rax
mov    %rax,0x27(%rsp)
movabs $0x20676e6f6c676962,%rax
6e 67 20
mov    %rax,0x20(%rsp)
movb   $0x0,0xc(%rsp)
movl   $0x676e6f6c,0x8(%rsp)
67
lea    0x20(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1060 <strindex@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x808,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [5 x i8] c"1234\00"
@__const.main.str3 = [11 x i8] c"teststring\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@__const.main.s4 = [15 x i8] c"biglong string\00"
@__const.main.s5 = [5 x i8] c"long\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1000 x i8]
%3 = alloca i32
%4 = alloca i8*
%5 = alloca [11 x i8]
%6 = alloca i32
%7 = alloca [1000 x i8]
%8 = alloca [15 x i8]
%9 = alloca [5 x i8]
store i32 10, i32* %1
%10 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%11 = load i32, i32* %1
%12 = call i32 @getline(i8* %10, i32 %11)
store i32 %12, i32* %3
%13 = load i32, i32* %3
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %13)
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %4
%15 = load i8*, i8** %4
%16 = call i32 @atoi(i8* %15)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = bitcast [11 x i8]* %5 to i8*
%19 = getelementptr inbounds [11 x i8], [11 x i8]* %5, i64 0, i64 0
%20 = call i32 @reverse(i8* %19)
%21 = getelementptr inbounds [11 x i8], [11 x i8]* %5, i64 0, i64 0
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %21)
store i32 1002, i32* %6
%23 = load i32, i32* %6
%24 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%25 = call i32 @itoa(i32 %23, i8* %24)
%26 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %26)
%28 = bitcast [15 x i8]* %8 to i8*
%29 = bitcast [5 x i8]* %9 to i8*
%30 = getelementptr inbounds [15 x i8], [15 x i8]* %8, i64 0, i64 0
%31 = getelementptr inbounds [5 x i8], [5 x i8]* %9, i64 0, i64 0
%32 = call i32 @strindex(i8* %30, i8* %31)
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %32)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
@__const.main.str3 = [11 x i8] c"teststring\00"
@__const.main.s4 = [15 x i8] c"biglong string\00"
@__const.main.s5 = [5 x i8] c"long\00"
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = alloca [11 x i8]
%3 = alloca [1000 x i8]
%4 = alloca [15 x i8]
%5 = alloca [5 x i8]
%6 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%7 = call i32 @getline(i8* %6, i32 10)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 1234)
%10 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 0
%11 = call i32 @reverse(i8* %10)
%12 = call i32 @puts(i8* %10)
%13 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%14 = call i32 @itoa(i32 1002, i8* %13)
%15 = call i32 @puts(i8* %13)
%16 = getelementptr inbounds [15 x i8], [15 x i8]* %4, i64 0, i64 0
%17 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
%18 = call i32 @strindex(i8* %16, i8* %17)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %18)
ret i32 0
}