#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int main(void) {
  char c, empty;
  printf("Welcome to ASCII:\n");
  while (c != '0' && c != 48 && c != 10) {
    printf("----> ");
    scanf("%c", &c);
    scanf("%c", &empty);
    printf("ascii: %d\n", c);
  }
  printf("Done.\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsbl -0x5(%rbp),%ecx
xor    %eax,%eax
cmp    $0x30,%ecx
mov    %al,-0x7(%rbp)
je     116e <main+0x4e>
movsbl -0x5(%rbp),%ecx
xor    %eax,%eax
cmp    $0x30,%ecx
mov    %al,-0x7(%rbp)
je     116e <main+0x4e>
movsbl -0x5(%rbp),%eax
cmp    $0xa,%eax
setne  %al
mov    %al,-0x7(%rbp)
mov    -0x7(%rbp),%al
test   $0x1,%al
jne    117e <main+0x5e>
jmp    11c3 <main+0xa3>
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe87(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xe77(%rip),%rdi
lea    -0x6(%rbp),%rsi
call   1040 <scanf@plt>
movsbl -0x5(%rbp),%esi
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    113d <main+0x1d>
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb0(%rip),%r14
lea    0xeb0(%rip),%rbx
lea    0xe(%rsp),%r15
lea    0xf(%rsp),%r12
lea    0xea2(%rip),%r13
cmp    $0xa,%al
je     11ac <main+0x7c>
nopl   0x0(%rax)
cmp    $0x30,%al
je     11ac <main+0x7c>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
movsbl 0xe(%rsp),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0xe(%rsp),%eax
cmp    $0xa,%al
jne    1170 <main+0x40>
lea    0xe74(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Welcome to ASCII:\0A\00"
@.str.1 = [7 x i8] c"----> \00"
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [11 x i8] c"ascii: %d\0A\00"
@.str.4 = [7 x i8] c"Done.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i8
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %19, %0
%6 = load i8, i8* %2
%7 = sext i8 %6 to i32
%8 = icmp ne i32 %7, 48
br i1 %8, label %9, label %17
9: ; preds = %5
%10 = load i8, i8* %2
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 48
br i1 %12, label %13, label %17
13: ; preds = %9
%14 = load i8, i8* %2
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 10
br label %17
17: ; preds = %13, %9, %5
%18 = phi i1 [ false, %9 ], [ false, %5 ], [ %16, %13 ]
br i1 %18, label %19, label %26
19: ; preds = %17
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%23 = load i8, i8* %2
%24 = sext i8 %23 to i32
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %24)
br label %5
26: ; preds = %17
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [7 x i8] c"----> \00"
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [11 x i8] c"ascii: %d\0A\00"
@str = [18 x i8] c"Welcome to ASCII:\00"
@str.5 = [6 x i8] c"Done.\00"
define i32 @main() {
%1 = alloca i8
%2 = alloca i8
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
br label %4
4: ; preds = %6, %0
%5 = phi i8 [ %13, %6 ], [ undef, %0 ]
switch i8 %5, label %6 [
i8 48, label %14
i8 10, label %14
]
6: ; preds = %4
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %1)
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%10 = load i8, i8* %1
%11 = sext i8 %10 to i32
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %11)
%13 = load i8, i8* %1
br label %4
14: ; preds = %4, %4
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.5, i64 0, i64 0))
ret i32 0
}