#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*/ execlp(char *, char *, char *);
int /*<<< orphan*/ exit(int);
scalar_t__ fork();
int /*<<< orphan*/ *gets(char *);
int printf(char *, ...);
int /*<<< orphan*/ wait(int /*<<< orphan*/);
main() {
  char line[100];
  while (printf("> "), gets(line) != NULL) {
    if (fork() == 0) {
      execlp(line, line, (char *)0);
      printf("%s: not found\n", line);
      exit(1);
    } else
      wait(0);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x70(%rbp),%rdi
call   1040 <gets@plt>
cmp    $0x0,%rax
je     11da <main+0x7a>
mov    $0x0,%al
call   1080 <fork@plt>
cmp    $0x0,%rax
jne    11ce <main+0x6e>
lea    -0x70(%rbp),%rdi
lea    -0x70(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1060 <execlp@plt>
lea    -0x70(%rbp),%rsi
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
xor    %edi,%edi
call   1070 <wait@plt>
jmp    116f <main+0xf>
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x68,%rsp
lea    0xe92(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rsp,%rdi
call   1040 <gets@plt>
test   %rax,%rax
je     11ba <main+0x5a>
lea    0xe77(%rip),%r14
mov    %rsp,%rbx
nopl   0x0(%rax)
xor    %eax,%eax
call   1080 <fork@plt>
test   %rax,%rax
je     11c4 <main+0x64>
xor    %edi,%edi
call   1070 <wait@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1040 <gets@plt>
test   %rax,%rax
jne    1190 <main+0x30>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
ret
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
call   1060 <execlp@plt>
lea    0xe28(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"> \00"
@.str.1 = [15 x i8] c"%s: not found\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
store i32 0, i32* %1
br label %3
3: ; preds = %20, %0
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%6 = call i32* @gets(i8* %5)
%7 = icmp ne i32* %6, null
br i1 %7, label %8, label %21
8: ; preds = %3
%9 = call i64 (...) @fork()
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %18
11: ; preds = %8
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%14 = call i32 @execlp(i8* %12, i8* %13, i8* null)
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %8
%19 = call i32 @wait(i32 0)
br label %20
20: ; preds = %18
br label %3
21: ; preds = %3
%22 = load i32, i32* %1
ret i32 %22
}

LLVM IR (-O2):
@.str = [3 x i8] c"> \00"
@.str.1 = [15 x i8] c"%s: not found\0A\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = call i32* @gets(i8* %2)
%5 = icmp eq i32* %4, null
br i1 %5, label %18, label %6
6: ; preds = %0, %13
%7 = call i64 (...) @fork()
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %6
%10 = call i32 @execlp(i8* %2, i8* %2, i8* null)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %6
%14 = call i32 @wait(i32 0)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%16 = call i32* @gets(i8* %2)
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %6
18: ; preds = %13, %0
ret i32 0
}