#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*/ display(int, int, int);
char getchar();
int /*<<< orphan*/ printf(char *);
int scanf(char *, int *, int *);
int main(void) {
  int ch;
  int rows, cols;
  printf("Enter a character and two integers:\n");
  while ((ch = getchar()) != '\n') {
    if (scanf("%d %d", &rows, &cols) != 2)
      break;
    display(ch, rows, cols);
    while (getchar() != '\n')
      continue;
    printf("Enter another character and two integers;\n");
    printf("Enter a newline to quit.\n");
  }
  printf("Bye.\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
movsbl %al,%eax
mov    %eax,-0x8(%rbp)
cmp    $0xa,%eax
je     11d6 <main+0x96>
lea    0xead(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
call   1060 <scanf@plt>
cmp    $0x2,%eax
je     1193 <main+0x53>
jmp    11d6 <main+0x96>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1030 <display@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     11b9 <main+0x79>
jmp    11a1 <main+0x61>
lea    0xe6b(%rip),%rdi
call   1040 <printf@plt>
lea    0xe8a(%rip),%rdi
call   1040 <printf@plt>
jmp    115b <main+0x1b>
lea    0xe93(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xeb4(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
je     11e8 <main+0xa8>
mov    %eax,%ebx
lea    0xe91(%rip),%r14
lea    0x4(%rsp),%r15
mov    %rsp,%r13
lea    0xeb1(%rip),%r12
lea    0xed4(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r13,%rdx
call   1060 <scanf@plt>
cmp    $0x2,%eax
jne    11e8 <main+0xa8>
movsbl %bl,%edi
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
call   1040 <display@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
jne    11c0 <main+0x80>
mov    %r12,%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebx
cmp    $0xa,%al
jne    1190 <main+0x50>
lea    0xe3b(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [37 x i8] c"Enter a character and two integers:\0A\00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [43 x i8] c"Enter another character and two integers;\0A\00"
@.str.3 = [26 x i8] c"Enter a newline to quit.\0A\00"
@.str.4 = [6 x i8] c"Bye.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %24, %0
%7 = call signext i8 (...) @getchar()
%8 = sext i8 %7 to i32
store i32 %8, i32* %2
%9 = icmp ne i32 %8, 10
br i1 %9, label %10, label %27
10: ; preds = %6
%11 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4)
%12 = icmp ne i32 %11, 2
br i1 %12, label %13, label %14
13: ; preds = %10
br label %27
14: ; preds = %10
%15 = load i32, i32* %2
%16 = load i32, i32* %3
%17 = load i32, i32* %4
%18 = call i32 @display(i32 %15, i32 %16, i32 %17)
br label %19
19: ; preds = %23, %14
%20 = call signext i8 (...) @getchar()
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %21, 10
br i1 %22, label %23, label %24
23: ; preds = %19
br label %19
24: ; preds = %19
%25 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
%26 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
br label %6
27: ; preds = %13, %6
%28 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c"%d %d\00"
@str = [36 x i8] c"Enter a character and two integers:\00"
@str.5 = [5 x i8] c"Bye.\00"
@str.6 = [42 x i8] c"Enter another character and two integers;\00"
@str.7 = [25 x i8] c"Enter a newline to quit.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0))
%6 = call signext i8 (...) @getchar()
%7 = icmp eq i8 %6, 10
br i1 %7, label %25, label %8
8: ; preds = %0, %20
%9 = phi i8 [ %23, %20 ], [ %6, %0 ]
%10 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%11 = icmp eq i32 %10, 2
br i1 %11, label %12, label %25
12: ; preds = %8
%13 = sext i8 %9 to i32
%14 = load i32, i32* %1
%15 = load i32, i32* %2
%16 = call i32 @display(i32 %13, i32 %14, i32 %15)
br label %17
17: ; preds = %17, %12
%18 = call signext i8 (...) @getchar()
%19 = icmp eq i8 %18, 10
br i1 %19, label %20, label %17
20: ; preds = %17
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.6, i64 0, i64 0))
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.7, i64 0, i64 0))
%23 = call signext i8 (...) @getchar()
%24 = icmp eq i8 %23, 10
br i1 %24, label %25, label %8
25: ; preds = %20, %8, %0
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.5, i64 0, i64 0))
ret i32 0
}