#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*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
char getch();
char getche();
char *getstring(int);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  char *mystring = (char *)malloc(255);
  mystring = getstring(25);
  fputs(mystring, stdout);
  printf("\nEnter a character: ");
  char a = getch();
  printf("\nEnter a character: ");
  char b = getche();
  printf("\nYou entered, in order, %c and %c \n", a, b);
  free(mystring);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0xff,%edi
call   1080 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    $0x19,%edi
call   1040 <getstring@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2e33(%rip),%rax
mov    (%rax),%esi
call   1060 <fputs@plt>
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1090 <getch@plt>
mov    %al,-0x19(%rbp)
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1070 <getche@plt>
mov    %al,-0x1a(%rbp)
movsbl -0x19(%rbp),%esi
movsbl -0x1a(%rbp),%edx
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    $0xff,%edi
call   1080 <malloc@plt>
mov    $0x19,%edi
call   1040 <getstring@plt>
mov    %rax,%r15
mov    0x2e4d(%rip),%rax
mov    (%rax),%esi
mov    %r15,%rdi
call   1060 <fputs@plt>
lea    0xe5c(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1090 <getch@plt>
mov    %eax,%ebx
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1070 <getche@plt>
movsbl %bl,%esi
movsbl %al,%edx
lea    0xe40(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [21 x i8] c"\0AEnter a character: \00"
@.str.1 = [36 x i8] c"\0AYou entered, in order, %c and %c \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8
%8 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i64 @malloc(i32 255)
%10 = inttoptr i64 %9 to i8*
store i8* %10, i8** %6
%11 = call i8* @getstring(i32 25)
store i8* %11, i8** %6
%12 = load i8*, i8** %6
%13 = load i32, i32* @stdout
%14 = call i32 @fputs(i8* %12, i32 %13)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%16 = call signext i8 (...) @getch()
store i8 %16, i8* %7
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%18 = call signext i8 (...) @getche()
store i8 %18, i8* %8
%19 = load i8, i8* %7
%20 = sext i8 %19 to i32
%21 = load i8, i8* %8
%22 = sext i8 %21 to i32
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i32 %20, i32 %22)
%24 = load i8*, i8** %6
%25 = call i32 @free(i8* %24)
ret i32 0
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [21 x i8] c"\0AEnter a character: \00"
@.str.1 = [36 x i8] c"\0AYou entered, in order, %c and %c \0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64 @malloc(i32 255)
%4 = tail call i8* @getstring(i32 25)
%5 = load i32, i32* @stdout
%6 = tail call i32 @fputs(i8* %4, i32 %5)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%8 = tail call signext i8 (...) @getch()
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%10 = tail call signext i8 (...) @getche()
%11 = sext i8 %8 to i32
%12 = sext i8 %10 to i32
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i32 %11, i32 %12)
%14 = tail call i32 @free(i8* %4)
ret i32 0
}