#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 fork();
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ smoker_matches();
int /*<<< orphan*/ smoker_paper();
int /*<<< orphan*/ smoker_tobacco();
int main(int argc, char *argv[]) {
  int pid, i;
  if (argc != 1) {
    printf("forma de uso: %s\n", argv[0]);
  }
  if ((pid = fork()) < 0) {
    perror("fork1");
    return -1;
  } else if (pid == 0) {
    printf("SMOKER WITH TOBACCO ...\n");
    smoker_tobacco();
  }
  if ((pid = fork()) < 0) {
    perror("fork2");
    return -1;
  } else if (pid == 0) {
    printf("SMOKER WITH MATCHES ... \n");
    smoker_matches();
  }
  if ((pid = fork()) < 0) {
    perror("fork3");
    return -1;
  } else if (pid == 0) {
    printf("SMOKER WITH PAPER ... \n");
    smoker_paper();
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
je     1195 <main+0x35>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1080 <fork@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    11c0 <main+0x60>
lea    0xe63(%rip),%rdi
call   1050 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1289 <main+0x129>
cmpl   $0x0,-0x14(%rbp)
jne    11df <main+0x7f>
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <smoker_tobacco@plt>
jmp    11e4 <main+0x84>
mov    $0x0,%al
call   1080 <fork@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    120f <main+0xaf>
lea    0xe33(%rip),%rdi
call   1050 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1289 <main+0x129>
cmpl   $0x0,-0x14(%rbp)
jne    122e <main+0xce>
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1060 <smoker_matches@plt>
jmp    1233 <main+0xd3>
mov    $0x0,%al
call   1080 <fork@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    125e <main+0xfe>
lea    0xe04(%rip),%rdi
call   1050 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1289 <main+0x129>
cmpl   $0x0,-0x14(%rbp)
jne    127d <main+0x11d>
lea    0xde8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1070 <smoker_paper@plt>
jmp    1282 <main+0x122>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x1,%edi
je     1187 <main+0x17>
mov    (%rsi),%rsi
lea    0xe80(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1090 <fork@plt>
test   %eax,%eax
js     11ed <main+0x7d>
jne    11a7 <main+0x37>
lea    0xeb9(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <smoker_tobacco@plt>
xor    %eax,%eax
call   1090 <fork@plt>
test   %eax,%eax
js     11f6 <main+0x86>
jne    11c7 <main+0x57>
lea    0xe80(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1070 <smoker_matches@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1090 <fork@plt>
test   %eax,%eax
js     11ff <main+0x8f>
jne    1210 <main+0xa0>
lea    0xe47(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1080 <smoker_paper@plt>
jmp    1210 <main+0xa0>
lea    0xe1e(%rip),%rdi
jmp    1206 <main+0x96>
lea    0xe1b(%rip),%rdi
jmp    1206 <main+0x96>
lea    0xe18(%rip),%rdi
call   1060 <perror@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [18 x i8] c"forma de uso: %s\0A\00"
@.str.1 = [6 x i8] c"fork1\00"
@.str.2 = [25 x i8] c"SMOKER WITH TOBACCO ...\0A\00"
@.str.3 = [6 x i8] c"fork2\00"
@.str.4 = [26 x i8] c"SMOKER WITH MATCHES ... \0A\00"
@.str.5 = [6 x i8] c"fork3\00"
@.str.6 = [24 x i8] c"SMOKER WITH PAPER ... \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 1
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %13)
br label %15
15: ; preds = %10, %2
%16 = call i32 (...) @fork()
store i32 %16, i32* %6
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %3
br label %52
20: ; preds = %15
%21 = load i32, i32* %6
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%25 = call i32 (...) @smoker_tobacco()
br label %26
26: ; preds = %23, %20
br label %27
27: ; preds = %26
%28 = call i32 (...) @fork()
store i32 %28, i32* %6
%29 = icmp slt i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %3
br label %52
32: ; preds = %27
%33 = load i32, i32* %6
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %32
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%37 = call i32 (...) @smoker_matches()
br label %38
38: ; preds = %35, %32
br label %39
39: ; preds = %38
%40 = call i32 (...) @fork()
store i32 %40, i32* %6
%41 = icmp slt i32 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %39
%43 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %3
br label %52
44: ; preds = %39
%45 = load i32, i32* %6
%46 = icmp eq i32 %45, 0
br i1 %46, label %47, label %50
47: ; preds = %44
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0))
%49 = call i32 (...) @smoker_paper()
br label %50
50: ; preds = %47, %44
br label %51
51: ; preds = %50
store i32 0, i32* %3
br label %52
52: ; preds = %51, %42, %30, %18
%53 = load i32, i32* %3
ret i32 %53
}

LLVM IR (-O2):
@.str = [18 x i8] c"forma de uso: %s\0A\00"
@.str.1 = [6 x i8] c"fork1\00"
@.str.3 = [6 x i8] c"fork2\00"
@.str.5 = [6 x i8] c"fork3\00"
@str = [23 x i8] c"SMOKER WITH PAPER ... \00"
@str.7 = [25 x i8] c"SMOKER WITH MATCHES ... \00"
@str.8 = [24 x i8] c"SMOKER WITH TOBACCO ...\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %7
7: ; preds = %4, %2
%8 = tail call i32 (...) @fork()
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %37
12: ; preds = %7
%13 = icmp eq i32 %8, 0
br i1 %13, label %14, label %17
14: ; preds = %12
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.8, i64 0, i64 0))
%16 = tail call i32 (...) @smoker_tobacco()
br label %17
17: ; preds = %12, %14
%18 = tail call i32 (...) @fork()
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %37
22: ; preds = %17
%23 = icmp eq i32 %18, 0
br i1 %23, label %24, label %27
24: ; preds = %22
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.7, i64 0, i64 0))
%26 = tail call i32 (...) @smoker_matches()
br label %27
27: ; preds = %22, %24
%28 = tail call i32 (...) @fork()
%29 = icmp slt i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
br label %37
32: ; preds = %27
%33 = icmp eq i32 %28, 0
br i1 %33, label %34, label %37
34: ; preds = %32
%35 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%36 = tail call i32 (...) @smoker_paper()
br label %37
37: ; preds = %34, %32, %30, %20, %10
%38 = phi i32 [ -1, %10 ], [ -1, %20 ], [ -1, %30 ], [ 0, %32 ], [ 0, %34 ]
ret i32 %38
}