#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(char *, int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ reverse(char *);
int main(int argc, char *argv[]) {
  char str[128];
  int n;
  printf("testing getline:\ninput a line:\n");
  n = getline(str, 128);
  printf("your input line is: '%s'\n", str);
  reverse(str);
  printf("testing reverse, the reverse of your last input line is: '%s'\n",
         str);
  printf("testing atoi and itoa:\n input a string which you wanna to convert "
         "to integer:\n");
  getline(str, 128);
  n = atoi(str);
  itoa(str, 128, n);
  printf("integer is: %d, and its converted string is: '%s'\n", n, str);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x90(%rbp),%rdi
mov    $0x80,%esi
call   1060 <getline@plt>
mov    %eax,-0x94(%rbp)
lea    -0x90(%rbp),%rsi
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x90(%rbp),%rdi
call   1030 <reverse@plt>
lea    -0x90(%rbp),%rsi
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x90(%rbp),%rdi
mov    $0x80,%esi
call   1060 <getline@plt>
lea    -0x90(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x94(%rbp)
lea    -0x90(%rbp),%rdi
mov    -0x94(%rbp),%edx
mov    $0x80,%esi
call   1070 <itoa@plt>
mov    -0x94(%rbp),%esi
lea    -0x90(%rbp),%rdx
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x88,%rsp
lea    0xf1c(%rip),%rdi
call   1040 <puts@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x80,%esi
call   1070 <getline@plt>
lea    0xe74(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <reverse@plt>
lea    0xe75(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xef5(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    $0x80,%esi
call   1070 <getline@plt>
mov    %rbx,%rdi
call   1060 <atoi@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    $0x80,%esi
mov    %eax,%edx
call   1080 <itoa@plt>
lea    0xe71(%rip),%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"testing getline:\0Ainput a line:\0A\00"
@.str.1 = [26 x i8] c"your input line is: '%s'\0A\00"
@.str.2 = [63 x i8] c"testing reverse, the reverse of your last input line is: '%s'\0A\00"
@.str.3 = [79 x i8] c"testing atoi and itoa:\0A input a string which you wanna to convert to integer:\0A\00"
@.str.4 = [51 x i8] c"integer is: %d, and its converted string is: '%s'\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [128 x i8]
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%9 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%10 = call i32 @getline(i8* %9, i32 128)
store i32 %10, i32* %7
%11 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%14 = call i32 @reverse(i8* %13)
%15 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.2, i64 0, i64 0), i8* %15)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.3, i64 0, i64 0))
%18 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%19 = call i32 @getline(i8* %18, i32 128)
%20 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%21 = call i32 @atoi(i8* %20)
store i32 %21, i32* %7
%22 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%23 = load i32, i32* %7
%24 = call i32 @itoa(i8* %22, i32 128, i32 %23)
%25 = load i32, i32* %7
%26 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0), i32 %25, i8* %26)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [26 x i8] c"your input line is: '%s'\0A\00"
@.str.2 = [63 x i8] c"testing reverse, the reverse of your last input line is: '%s'\0A\00"
@.str.4 = [51 x i8] c"integer is: %d, and its converted string is: '%s'\0A\00"
@str = [31 x i8] c"testing getline:\0Ainput a line:\00"
@str.5 = [78 x i8] c"testing atoi and itoa:\0A input a string which you wanna to convert to integer:\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [128 x i8]
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%6 = call i32 @getline(i8* %4, i32 128)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%8 = call i32 @reverse(i8* %4)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([78 x i8], [78 x i8]* @str.5, i64 0, i64 0))
%11 = call i32 @getline(i8* %4, i32 128)
%12 = call i32 @atoi(i8* %4)
%13 = call i32 @itoa(i8* %4, i32 128, i32 %12)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0), i32 %12, i8* %4)
ret i32 0
}