#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ rt_clear();
int /*<<< orphan*/ rt_render(int);
int /*<<< orphan*/ save_image(char *);
void keyb(unsigned char key, int x, int y) {
  switch (key) {
  case 27:
    exit(0);
  case '\n':
  case '\r':
    rt_clear();
    rt_render(5);
    break;
  case ' ':
    rt_render(5);
    break;
  case 's':
    save_image("output.ppm");
    break;
  }
}


x86 assembly (clang, -O0):
<keyb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movzbl -0x1(%rbp),%eax
mov    %eax,-0x10(%rbp)
sub    $0xa,%eax
je     11b4 <keyb+0x74>
jmp    1169 <keyb+0x29>
mov    -0x10(%rbp),%eax
sub    $0xd,%eax
je     11b4 <keyb+0x74>
jmp    117a <keyb+0x3a>
mov    -0x10(%rbp),%eax
sub    $0x1b,%eax
je     11ad <keyb+0x6d>
jmp    118b <keyb+0x4b>
mov    -0x10(%rbp),%eax
sub    $0x20,%eax
je     11ca <keyb+0x8a>
jmp    119c <keyb+0x5c>
mov    -0x10(%rbp),%eax
sub    $0x73,%eax
je     11d9 <keyb+0x99>
jmp    11e5 <keyb+0xa5>
xor    %edi,%edi
call   1060 <exit@plt>
mov    $0x0,%al
call   1040 <rt_clear@plt>
mov    $0x5,%edi
call   1050 <rt_render@plt>
jmp    11e5 <keyb+0xa5>
mov    $0x5,%edi
call   1050 <rt_render@plt>
jmp    11e5 <keyb+0xa5>
lea    0xe20(%rip),%rdi
call   1030 <save_image@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<keyb>:
push   %rax
lea    -0xa(%rdi),%eax
cmp    $0x16,%al
ja     116d <keyb+0x2d>
movzbl %al,%eax
lea    0xeae(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
xor    %eax,%eax
call   1040 <rt_clear@plt>
mov    $0x5,%edi
pop    %rax
jmp    1050 <rt_render@plt>
cmp    $0x73,%dil
jne    1180 <keyb+0x40>
lea    0xee2(%rip),%rdi
pop    %rax
jmp    1030 <save_image@plt>
pop    %rax
ret
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"output.ppm\00"
define void @keyb(i8 zeroext %0, i32 %1, i32 %2) {
%4 = alloca i8
%5 = alloca i32
%6 = alloca i32
store i8 %0, i8* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i8, i8* %4
%8 = zext i8 %7 to i32
switch i32 %8, label %18 [
i32 27, label %9
i32 10, label %11
i32 13, label %11
i32 32, label %14
i32 115, label %16
]
9: ; preds = %3
%10 = call i32 @exit(i32 0)
unreachable
11: ; preds = %3, %3
%12 = call i32 (...) @rt_clear()
%13 = call i32 @rt_render(i32 5)
br label %18
14: ; preds = %3
%15 = call i32 @rt_render(i32 5)
br label %18
16: ; preds = %3
%17 = call i32 @save_image(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %3, %16, %14, %11
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"output.ppm\00"
define void @keyb(i8 zeroext %0, i32 %1, i32 %2) {
switch i8 %0, label %13 [
i8 27, label %4
i8 10, label %6
i8 13, label %6
i8 32, label %9
i8 115, label %11
]
4: ; preds = %3
%5 = tail call i32 @exit(i32 0)
unreachable
6: ; preds = %3, %3
%7 = tail call i32 (...) @rt_clear()
%8 = tail call i32 @rt_render(i32 5)
br label %13
9: ; preds = %3
%10 = tail call i32 @rt_render(i32 5)
br label %13
11: ; preds = %3
%12 = tail call i32 @save_image(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %3, %11, %9, %6
ret void
}