#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*/ assert(int);
char getch();
int ungetch(char);
int main(int argc, char *argv[]) {
  char c1 = getch();
  assert(c1 == '#');
  char c2 = getch();
  assert(c2 == 'i');
  assert(ungetch(c2));
  assert(!ungetch(c1));
}


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   1050 <getch@plt>
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
cmp    $0x23,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    $0x0,%al
call   1050 <getch@plt>
mov    %al,-0x12(%rbp)
movsbl -0x12(%rbp),%eax
cmp    $0x69,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movsbl -0x12(%rbp),%edi
call   1040 <ungetch@plt>
mov    %eax,%edi
call   1030 <assert@plt>
movsbl -0x11(%rbp),%edi
call   1040 <ungetch@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <getch@plt>
mov    %eax,%ebp
xor    %edi,%edi
cmp    $0x23,%al
sete   %dil
call   1030 <assert@plt>
xor    %eax,%eax
call   1050 <getch@plt>
mov    %eax,%ebx
xor    %edi,%edi
cmp    $0x69,%al
sete   %dil
call   1030 <assert@plt>
movsbl %bl,%edi
call   1040 <ungetch@plt>
mov    %eax,%edi
call   1030 <assert@plt>
movsbl %bpl,%edi
call   1040 <ungetch@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1030 <assert@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
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 signext i8 (...) @getch()
store i8 %7, i8* %5
%8 = load i8, i8* %5
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 35
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = call signext i8 (...) @getch()
store i8 %13, i8* %6
%14 = load i8, i8* %6
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 105
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = load i8, i8* %6
%20 = call i32 @ungetch(i8 signext %19)
%21 = call i32 @assert(i32 %20)
%22 = load i8, i8* %5
%23 = call i32 @ungetch(i8 signext %22)
%24 = icmp ne i32 %23, 0
%25 = xor i1 %24, true
%26 = zext i1 %25 to i32
%27 = call i32 @assert(i32 %26)
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call signext i8 (...) @getch()
%4 = icmp eq i8 %3, 35
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = tail call signext i8 (...) @getch()
%8 = icmp eq i8 %7, 105
%9 = zext i1 %8 to i32
%10 = tail call i32 @assert(i32 %9)
%11 = tail call i32 @ungetch(i8 signext %7)
%12 = tail call i32 @assert(i32 %11)
%13 = tail call i32 @ungetch(i8 signext %3)
%14 = icmp eq i32 %13, 0
%15 = zext i1 %14 to i32
%16 = tail call i32 @assert(i32 %15)
ret i32 0
}