#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 */
typedef scalar_t__ pid_t;

/* Variables and functions */
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ fork();
scalar_t__ kbhit();
int /*<<< orphan*/ printf(char *);
int lmain(int argc, char **argv) {
  char *input = argv[0];
  int nomor = argc;
  pid_t pid = 0;
  pid = fork();
  if (pid == 0) {
    int x = 0;
    while (1) {
      if (kbhit())
        printf("you hit keyboard");
    }
  } else {
    exit(0);
  }
}


x86 assembly (clang, -O0):
<lmain>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
mov    $0x0,%al
call   1060 <fork@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11a7 <lmain+0x67>
movl   $0x0,-0x2c(%rbp)
mov    $0x0,%al
call   1040 <kbhit@plt>
cmp    $0x0,%rax
je     11a2 <lmain+0x62>
lea    0xe63(%rip),%rdi
call   1030 <printf@plt>
jmp    1185 <lmain+0x45>
xor    %edi,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<lmain>:
push   %rbx
xor    %eax,%eax
call   1060 <fork@plt>
test   %rax,%rax
jne    1176 <lmain+0x36>
lea    0xeac(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1040 <kbhit@plt>
test   %rax,%rax
je     1160 <lmain+0x20>
mov    %rbx,%rdi
call   1030 <printf@plt>
jmp    1160 <lmain+0x20>
xor    %edi,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"you hit keyboard\00"
define i32 @lmain(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i64
%8 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%9 = load i8**, i8*** %4
%10 = getelementptr inbounds i8*, i8** %9, i64 0
%11 = load i8*, i8** %10
store i8* %11, i8** %5
%12 = load i32, i32* %3
store i32 %12, i32* %6
store i64 0, i64* %7
%13 = call i64 (...) @fork()
store i64 %13, i64* %7
%14 = load i64, i64* %7
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %23
16: ; preds = %2
store i32 0, i32* %8
br label %17
17: ; preds = %16, %22
%18 = call i64 (...) @kbhit()
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %22
22: ; preds = %20, %17
br label %17
23: ; preds = %2
%24 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [17 x i8] c"you hit keyboard\00"
define i32 @lmain(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64 (...) @fork()
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %11
5: ; preds = %2, %10
%6 = tail call i64 (...) @kbhit()
%7 = icmp eq i64 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %5
%9 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %8, %5
br label %5
11: ; preds = %2
%12 = tail call i32 @exit(i32 0)
unreachable
}