#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 */
struct keyseq {
  int dummy;
};

/* Variables and functions */
int getch();
int /*<<< orphan*/ print_seq(struct keyseq *);
int /*<<< orphan*/ printf(char *, int);
void test(struct keyseq *k) {
  int c = getch();
  while ((c > 0 && c < 127)) {
    c = getch();
    switch (c) {
    case 4:
      break;
    default:
      printf("%d \n", c);
      break;
    }
  }
  print_seq(k);
}


x86 assembly (clang, -O0):
<test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1050 <getch@plt>
mov    %eax,-0xc(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0xc(%rbp)
mov    %al,-0xd(%rbp)
jle    115f <test+0x2f>
cmpl   $0x7f,-0xc(%rbp)
setl   %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    116f <test+0x3f>
jmp    11a3 <test+0x73>
xor    %eax,%eax
call   1050 <getch@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x4,%eax
jne    118f <test+0x5f>
jmp    118a <test+0x5a>
jmp    119e <test+0x6e>
mov    -0xc(%rbp),%esi
lea    0xe67(%rip),%rdi
call   1030 <printf@plt>
jmp    1146 <test+0x16>
mov    -0x8(%rbp),%rdi
call   1040 <print_seq@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
xor    %eax,%eax
call   1050 <getch@plt>
add    $0xffffffff,%eax
cmp    $0x7d,%eax
ja     1172 <test+0x42>
lea    0xeb3(%rip),%rbx
jmp    1158 <test+0x28>
nop
add    $0xffffffff,%ebp
cmp    $0x7e,%ebp
jae    1172 <test+0x42>
xor    %eax,%eax
call   1050 <getch@plt>
mov    %eax,%ebp
cmp    $0x4,%eax
je     1150 <test+0x20>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
jmp    1150 <test+0x20>
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <print_seq@plt>

LLVM IR (-O0):
%struct.keyseq = type { i32 }
@.str = [5 x i8] c"%d \0A\00"
define void @test(%struct.keyseq* %0) {
%2 = alloca %struct.keyseq*
%3 = alloca i32
store %struct.keyseq* %0, %struct.keyseq** %2
%4 = call i32 (...) @getch()
store i32 %4, i32* %3
br label %5
5: ; preds = %20, %1
%6 = load i32, i32* %3
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %5
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 127
br label %11
11: ; preds = %8, %5
%12 = phi i1 [ false, %5 ], [ %10, %8 ]
br i1 %12, label %13, label %21
13: ; preds = %11
%14 = call i32 (...) @getch()
store i32 %14, i32* %3
%15 = load i32, i32* %3
switch i32 %15, label %17 [
i32 4, label %16
]
16: ; preds = %13
br label %20
17: ; preds = %13
%18 = load i32, i32* %3
%19 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %18)
br label %20
20: ; preds = %17, %16
br label %5
21: ; preds = %11
%22 = load %struct.keyseq*, %struct.keyseq** %2
%23 = call i32 @print_seq(%struct.keyseq* %22)
ret void
}

LLVM IR (-O2):
%struct.keyseq = type { i32 }
@.str = [5 x i8] c"%d \0A\00"
define void @test(%struct.keyseq* %0) {
%2 = tail call i32 (...) @getch()
%3 = add i32 %2, -1
%4 = icmp ult i32 %3, 126
br i1 %4, label %5, label %13
5: ; preds = %1, %10
%6 = tail call i32 (...) @getch()
%7 = icmp eq i32 %6, 4
br i1 %7, label %10, label %8
8: ; preds = %5
%9 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %6)
br label %10
10: ; preds = %5, %8
%11 = add i32 %6, -1
%12 = icmp ult i32 %11, 126
br i1 %12, label %5, label %13
13: ; preds = %10, %1
%14 = tail call i32 @print_seq(%struct.keyseq* %0)
ret void
}