#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 */
char getchar();
int /*<<< orphan*/ printf(char *, char);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ serialInit();
int app_main() {
  char ch;
  serialInit();
  puts("\r\nSample printf function demo program \r\n");
  while (1) {
    ch = getchar();
    printf("You entered character         : %c\r\n", ch);
    printf("Its ASCII code in hex is      : %x\r\n", ch);
    printf("Its ASCII code in decimal is  : %d\r\n", ch);
  }
  return 0;
}


x86 assembly (clang, -O0):
<app_main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1050 <serialInit@plt>
lea    0xeaa(%rip),%rdi
call   1030 <puts@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %al,-0x1(%rbp)
lea    0xebd(%rip),%rdi
movsbl -0x1(%rbp),%esi
call   1040 <printf@plt>
lea    0xed2(%rip),%rdi
movsbl -0x1(%rbp),%esi
call   1040 <printf@plt>
lea    0xee7(%rip),%rdi
movsbl -0x1(%rbp),%esi
call   1040 <printf@plt>
jmp    115b <app_main+0x1b>

x86 assembly (clang, -O2):
<app_main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <serialInit@plt>
lea    0xeab(%rip),%rdi
call   1030 <puts@plt>
lea    0xec8(%rip),%r14
lea    0xee6(%rip),%r15
lea    0xf04(%rip),%rbx
nop
xor    %eax,%eax
call   1060 <getchar@plt>
movsbl %al,%ebp
mov    %r14,%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
jmp    1170 <app_main+0x30>

LLVM IR (-O0):
@.str = [41 x i8] c"\0D\0ASample printf function demo program \0D\0A\00"
@.str.1 = [37 x i8] c"You entered character : %c\0D\0A\00"
@.str.2 = [37 x i8] c"Its ASCII code in hex is : %x\0D\0A\00"
@.str.3 = [37 x i8] c"Its ASCII code in decimal is : %d\0D\0A\00"
define i32 @app_main() {
%1 = alloca i8
%2 = call i32 (...) @serialInit()
%3 = call i32 @puts(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %0, %4
%5 = call signext i8 (...) @getchar()
store i8 %5, i8* %1
%6 = load i8, i8* %1
%7 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8 signext %6)
%8 = load i8, i8* %1
%9 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8 signext %8)
%10 = load i8, i8* %1
%11 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i8 signext %10)
br label %4
}

LLVM IR (-O2):
@.str = [41 x i8] c"\0D\0ASample printf function demo program \0D\0A\00"
@.str.1 = [37 x i8] c"You entered character : %c\0D\0A\00"
@.str.2 = [37 x i8] c"Its ASCII code in hex is : %x\0D\0A\00"
@.str.3 = [37 x i8] c"Its ASCII code in decimal is : %d\0D\0A\00"
define i32 @app_main() {
%1 = tail call i32 (...) @serialInit()
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
br label %3
3: ; preds = %3, %0
%4 = tail call signext i8 (...) @getchar()
%5 = tail call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8 signext %4)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8 signext %4)
%7 = tail call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i8 signext %4)
br label %3
}