#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 */
void *getch();
int /*<<< orphan*/ printf(char *, unsigned char);
int main(int argc, char *argv[]) {
  char a = getch();
  printf("%u\n", a);
  printf("%d\n", a);
  unsigned char b = getch();
  printf("%u\n", b);
  printf("%d\n", b);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1040 <getch@plt>
mov    %al,-0x11(%rbp)
lea    0xec0(%rip),%rdi
movzbl -0x11(%rbp),%esi
call   1030 <printf@plt>
lea    0xeb4(%rip),%rdi
movzbl -0x11(%rbp),%esi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getch@plt>
mov    %al,-0x12(%rbp)
lea    0xe96(%rip),%rdi
movzbl -0x12(%rbp),%esi
call   1030 <printf@plt>
lea    0xe8a(%rip),%rdi
movzbl -0x12(%rbp),%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
xor    %eax,%eax
call   1040 <getch@plt>
movzbl %al,%ebx
lea    0xeca(%rip),%r14
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
lea    0xebd(%rip),%r15
mov    %r15,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <getch@plt>
movzbl %al,%ebx
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%u\0A\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8
%6 = alloca i8
store i32 %0, i32* %3
store i8** %1, i8*** %4
%7 = call i8* (...) @getch()
%8 = ptrtoint i8* %7 to i8
store i8 %8, i8* %5
%9 = load i8, i8* %5
%10 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 zeroext %9)
%11 = load i8, i8* %5
%12 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %11)
%13 = call i8* (...) @getch()
%14 = ptrtoint i8* %13 to i8
store i8 %14, i8* %6
%15 = load i8, i8* %6
%16 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 zeroext %15)
%17 = load i8, i8* %6
%18 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %17)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%u\0A\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i8* (...) @getch()
%4 = ptrtoint i8* %3 to i64
%5 = trunc i64 %4 to i8
%6 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 zeroext %5)
%7 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %5)
%8 = tail call i8* (...) @getch()
%9 = ptrtoint i8* %8 to i64
%10 = trunc i64 %9 to i8
%11 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 zeroext %10)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %10)
ret i32 0
}