#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 int /*<<< orphan*/ buf;

/* Variables and functions */
scalar_t__ WIFEXITED(int);
int /*<<< orphan*/ execl(char *, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
scalar_t__ fork();
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int strlen(char *);
int wait(int *);
int main() {
  char buf[1024];
  for (;;) {
    printf("yes, master..");
    fgets(buf, sizeof(buf), stdin);
    buf[strlen(buf) - 1] = 0;
    if (fork() != 0) {
      int status, pid;
      pid = wait(&status);
      printf("%d termino %smente\n", pid,
             WIFEXITED(status) ? "normal" : "anormal");
    } else {
      execl(buf, buf, NULL);
      perror("exec");
      exit(-1);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x410(%rbp),%rdi
mov    0x2e2a(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%esi
call   1050 <fgets@plt>
lea    -0x410(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x410(%rbp,%rax,1)
mov    $0x0,%al
call   10b0 <fork@plt>
cmp    $0x0,%rax
je     124f <main+0xbf>
lea    -0x414(%rbp),%rdi
call   10a0 <wait@plt>
mov    %eax,-0x418(%rbp)
mov    -0x418(%rbp),%eax
mov    %eax,-0x41c(%rbp)
mov    -0x414(%rbp),%edi
call   1070 <WIFEXITED@plt>
mov    -0x41c(%rbp),%esi
mov    %rax,%rcx
lea    0xdf5(%rip),%rdx
lea    0xdef(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%rdx
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    127c <main+0xec>
lea    -0x410(%rbp),%rdi
lea    -0x410(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1090 <execl@plt>
lea    0xdbd(%rip),%rdi
call   1060 <perror@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
jmp    11a2 <main+0x12>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
lea    0xe58(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e32(%rip),%r13
mov    0x0(%r13),%edx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x400,%esi
call   1050 <fgets@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
xor    %eax,%eax
call   10b0 <fork@plt>
test   %rax,%rax
je     1268 <main+0xd8>
lea    0xe31(%rip),%r14
lea    0xe15(%rip),%r15
lea    0xe00(%rip),%r12
lea    0xc(%rsp),%rdi
call   10a0 <wait@plt>
mov    %eax,%ebp
mov    0xc(%rsp),%edi
call   1070 <WIFEXITED@plt>
test   %rax,%rax
mov    %r14,%rdx
lea    0xe00(%rip),%rax
cmove  %rax,%rdx
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x0(%r13),%edx
mov    %rbx,%rdi
mov    $0x400,%esi
call   1050 <fgets@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
xor    %eax,%eax
call   10b0 <fork@plt>
test   %rax,%rax
jne    1200 <main+0x70>
lea    0x10(%rsp),%rdi
mov    %rdi,%rsi
xor    %edx,%edx
call   1090 <execl@plt>
lea    0xdac(%rip),%rdi
call   1060 <perror@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"yes, master..\00"
@stdin = global i32 0
@.str.1 = [20 x i8] c"%d termino %smente\0A\00"
@.str.2 = [7 x i8] c"normal\00"
@.str.3 = [8 x i8] c"anormal\00"
@.str.4 = [5 x i8] c"exec\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1024 x i8]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
br label %5
5: ; preds = %32, %0
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%8 = load i32, i32* @stdin
%9 = call i32 @fgets(i8* %7, i32 1024, i32 %8)
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%11 = call i32 @strlen(i8* %10)
%12 = sub nsw i32 %11, 1
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %13
store i8 0, i8* %14
%15 = call i64 (...) @fork()
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %26
17: ; preds = %5
%18 = call i32 @wait(i32* %3)
store i32 %18, i32* %4
%19 = load i32, i32* %4
%20 = load i32, i32* %3
%21 = call i64 @WIFEXITED(i32 %20)
%22 = icmp ne i64 %21, 0
%23 = zext i1 %22 to i64
%24 = select i1 %22, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0)
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %19, i8* %24)
br label %32
26: ; preds = %5
%27 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%29 = call i32 @execl(i8* %27, i8* %28, i32* null)
%30 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%31 = call i32 @exit(i32 -1)
unreachable
32: ; preds = %17
br label %5
}

LLVM IR (-O2):
@.str = [14 x i8] c"yes, master..\00"
@stdin = global i32 0
@.str.1 = [20 x i8] c"%d termino %smente\0A\00"
@.str.2 = [7 x i8] c"normal\00"
@.str.3 = [8 x i8] c"anormal\00"
@.str.4 = [5 x i8] c"exec\00"
define i32 @main() {
%1 = alloca [1024 x i8]
%2 = alloca i32
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%5 = load i32, i32* @stdin
%6 = call i32 @fgets(i8* %3, i32 1024, i32 %5)
%7 = call i32 @strlen(i8* %3)
%8 = add nsw i32 %7, -1
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 %9
store i8 0, i8* %10
%11 = call i64 (...) @fork()
%12 = icmp eq i64 %11, 0
br i1 %12, label %31, label %13
13: ; preds = %0
%14 = bitcast i32* %2 to i8*
br label %15
15: ; preds = %13, %15
%16 = call i32 @wait(i32* %2)
%17 = load i32, i32* %2
%18 = call i64 @WIFEXITED(i32 %17)
%19 = icmp eq i64 %18, 0
%20 = select i1 %19, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %16, i8* %20)
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%23 = load i32, i32* @stdin
%24 = call i32 @fgets(i8* %3, i32 1024, i32 %23)
%25 = call i32 @strlen(i8* %3)
%26 = add nsw i32 %25, -1
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 %27
store i8 0, i8* %28
%29 = call i64 (...) @fork()
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %15
31: ; preds = %15, %0
%32 = call i32 @execl(i8* %3, i8* %3, i32* null)
%33 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%34 = call i32 @exit(i32 -1)
unreachable
}