#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 EOF;
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int main() {
  char a, b, ch;
  printf("Please insert two chars:\n");
  scanf("%c", &a);
  while ((ch = getchar()) != '\n' && ch != EOF) {
  };
  scanf("%c", &b);
  while ((ch = getchar()) != '\n' && ch != EOF) {
  };
  printf("char a: %c\nchar b: %c\n", a, b);
  printf("[Press enter]\n");
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec6(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1050 <scanf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x7(%rbp)
movsbl %al,%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x8(%rbp)
je     118e <main+0x5e>
movsbl -0x7(%rbp),%eax
mov    0x2e65(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0x8(%rbp)
mov    -0x8(%rbp),%al
test   $0x1,%al
jne    119e <main+0x6e>
jmp    11a3 <main+0x73>
jmp    115d <main+0x2d>
lea    0xe70(%rip),%rdi
lea    -0x6(%rbp),%rsi
call   1050 <scanf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x7(%rbp)
movsbl %al,%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x9(%rbp)
je     11e4 <main+0xb4>
movsbl -0x7(%rbp),%eax
mov    0x2e0f(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
test   $0x1,%al
jne    11f4 <main+0xc4>
jmp    11f9 <main+0xc9>
jmp    11b3 <main+0x83>
movsbl -0x5(%rbp),%esi
movsbl -0x6(%rbp),%edx
lea    0xe15(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xece(%rip),%rdi
call   1030 <puts@plt>
lea    0xea8(%rip),%rdi
lea    0xf(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x2e7f(%rip),%rbx
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
je     117f <main+0x3f>
cmp    (%rbx),%al
jne    1170 <main+0x30>
lea    0xe7a(%rip),%rdi
lea    0xe(%rsp),%rsi
call   1060 <scanf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
je     119f <main+0x5f>
cmp    (%rbx),%al
jne    1190 <main+0x50>
movsbl 0xf(%rsp),%esi
movsbl 0xe(%rsp),%edx
lea    0xe53(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe75(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Please insert two chars:\0A\00"
@.str.1 = [3 x i8] c"%c\00"
@EOF = global i8 0
@.str.2 = [23 x i8] c"char a: %c\0Achar b: %c\0A\00"
@.str.3 = [15 x i8] c"[Press enter]\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i8
%4 = alloca i8
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
br label %7
7: ; preds = %19, %0
%8 = call signext i8 (...) @getchar()
store i8 %8, i8* %4
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 10
br i1 %10, label %11, label %17
11: ; preds = %7
%12 = load i8, i8* %4
%13 = sext i8 %12 to i32
%14 = load i8, i8* @EOF
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %13, %15
br label %17
17: ; preds = %11, %7
%18 = phi i1 [ false, %7 ], [ %16, %11 ]
br i1 %18, label %19, label %20
19: ; preds = %17
br label %7
20: ; preds = %17
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
br label %22
22: ; preds = %34, %20
%23 = call signext i8 (...) @getchar()
store i8 %23, i8* %4
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %24, 10
br i1 %25, label %26, label %32
26: ; preds = %22
%27 = load i8, i8* %4
%28 = sext i8 %27 to i32
%29 = load i8, i8* @EOF
%30 = sext i8 %29 to i32
%31 = icmp ne i32 %28, %30
br label %32
32: ; preds = %26, %22
%33 = phi i1 [ false, %22 ], [ %31, %26 ]
br i1 %33, label %34, label %35
34: ; preds = %32
br label %22
35: ; preds = %32
%36 = load i8, i8* %2
%37 = sext i8 %36 to i32
%38 = load i8, i8* %3
%39 = sext i8 %38 to i32
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %37, i32 %39)
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%42 = call signext i8 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%c\00"
@EOF = global i8 0
@.str.2 = [23 x i8] c"char a: %c\0Achar b: %c\0A\00"
@str = [25 x i8] c"Please insert two chars:\00"
@str.4 = [14 x i8] c"[Press enter]\00"
define i32 @main() {
%1 = alloca i8
%2 = alloca i8
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %1)
br label %5
5: ; preds = %5, %0
%6 = call signext i8 (...) @getchar()
%7 = icmp ne i8 %6, 10
%8 = load i8, i8* @EOF
%9 = icmp ne i8 %6, %8
%10 = select i1 %7, i1 %9, i1 false
br i1 %10, label %5, label %11
11: ; preds = %5
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
br label %13
13: ; preds = %13, %11
%14 = call signext i8 (...) @getchar()
%15 = icmp ne i8 %14, 10
%16 = load i8, i8* @EOF
%17 = icmp ne i8 %14, %16
%18 = select i1 %15, i1 %17, i1 false
br i1 %18, label %13, label %19
19: ; preds = %13
%20 = load i8, i8* %1
%21 = sext i8 %20 to i32
%22 = load i8, i8* %2
%23 = sext i8 %22 to i32
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %21, i32 %23)
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.4, i64 0, i64 0))
%26 = call signext i8 (...) @getchar()
ret i32 0
}