#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*/ EXIT_FAILURE;
int /*<<< orphan*/ errno;
int execve(char *, char **, char **);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
void create_tao_process(int id_tao, int lifetime, int tao_processes_msqid) {
  char str_lifetime[32];
  char str_tao_processes_msqid[32];
  char str_id_tao[32];
  sprintf(str_lifetime, "%d", lifetime);
  sprintf(str_tao_processes_msqid, "%d", tao_processes_msqid);
  sprintf(str_id_tao, "%d", id_tao);
  int tao_process_pid = fork();
  if (tao_process_pid == -1) {
    printf("[auctioneer] Error: Tao process not created.\n");
    fprintf(stderr, "\t%s\n", strerror(errno));
    perror("fork");
    exit(EXIT_FAILURE);
  } else if (tao_process_pid == 0) {
    char *envp[] = {NULL};
    char *argv[] = {"./tao_process",         "-t", str_lifetime, "-m",
                    str_tao_processes_msqid, "-i", str_id_tao,   NULL};
    int auct_execve_err = execve("./tao_process", argv, envp);
    if (auct_execve_err == -1) {
      fprintf(stderr, "[Tao process] Error: cannot start tao_process process "
                      "(Try running main from ./bin).\n");
      fprintf(stderr, "\t%s\n", strerror(errno));
    }
  }
}


x86 assembly (clang, -O0):
<create_tao_process>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%edx
lea    0xe4e(%rip),%rsi
call   1080 <sprintf@plt>
lea    -0x50(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xe3b(%rip),%rsi
call   1080 <sprintf@plt>
lea    -0x70(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xe28(%rip),%rsi
call   1080 <sprintf@plt>
mov    $0x0,%al
call   10b0 <fork@plt>
mov    %eax,-0x74(%rbp)
cmpl   $0xffffffff,-0x74(%rbp)
jne    124b <create_tao_process+0xbb>
lea    0xe0b(%rip),%rdi
call   1030 <printf@plt>
mov    0x2ddc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc8(%rbp)
mov    0x2dc5(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0xc8(%rbp),%edi
mov    %rax,%rdx
lea    0xe07(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
lea    0xdfe(%rip),%rdi
call   1070 <perror@plt>
mov    0x2d8c(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
cmpl   $0x0,-0x74(%rbp)
jne    1343 <create_tao_process+0x1b3>
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
lea    0xdcf(%rip),%rax
mov    %rax,-0xc0(%rbp)
lea    0xdcf(%rip),%rax
mov    %rax,-0xb8(%rbp)
lea    -0x30(%rbp),%rax
mov    %rax,-0xb0(%rbp)
lea    0xdb9(%rip),%rax
mov    %rax,-0xa8(%rbp)
lea    -0x50(%rbp),%rax
mov    %rax,-0xa0(%rbp)
lea    0xda3(%rip),%rax
mov    %rax,-0x98(%rbp)
lea    -0x70(%rbp),%rax
mov    %rax,-0x90(%rbp)
movq   $0x0,-0x88(%rbp)
lea    -0xc0(%rbp),%rsi
lea    -0x80(%rbp),%rdx
lea    0xd60(%rip),%rdi
call   1050 <execve@plt>
mov    %eax,-0xc4(%rbp)
cmpl   $0xffffffff,-0xc4(%rbp)
jne    133e <create_tao_process+0x1ae>
mov    0x2ce6(%rip),%rax
mov    (%rax),%edi
lea    0xd4f(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2ccf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xcc(%rbp)
mov    0x2cb8(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0xcc(%rbp),%edi
mov    %rax,%rdx
lea    0xcfa(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    1343 <create_tao_process+0x1b3>
jmp    1348 <create_tao_process+0x1b8>
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_tao_process>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xb0,%rsp
mov    %edx,%ebx
mov    %esi,%edx
mov    %edi,%r12d
lea    0xe63(%rip),%rbp
lea    0x90(%rsp),%r14
mov    %r14,%rdi
mov    %rbp,%rsi
call   1070 <sprintf@plt>
lea    0x70(%rsp),%r15
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %ebx,%edx
call   1070 <sprintf@plt>
lea    0x50(%rsp),%rbx
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r12d,%edx
call   1070 <sprintf@plt>
xor    %eax,%eax
call   10a0 <fork@plt>
test   %eax,%eax
je     1239 <create_tao_process+0xb9>
cmp    $0xffffffff,%eax
jne    12d8 <create_tao_process+0x158>
lea    0xe8a(%rip),%rdi
call   1030 <puts@plt>
mov    0x2de4(%rip),%rax
mov    (%rax),%ebx
mov    0x2dd3(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xdf0(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    0xde2(%rip),%rdi
call   1060 <perror@plt>
mov    0x2d9e(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
movq   $0x0,0x8(%rsp)
lea    0xdc4(%rip),%rdi
mov    %rdi,0x10(%rsp)
lea    0xdc6(%rip),%rax
mov    %rax,0x18(%rsp)
mov    %r14,0x20(%rsp)
lea    0xdb8(%rip),%rax
mov    %rax,0x28(%rsp)
mov    %r15,0x30(%rsp)
lea    0xdaa(%rip),%rax
mov    %rax,0x38(%rsp)
mov    %rbx,0x40(%rsp)
movq   $0x0,0x48(%rsp)
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1040 <execve@plt>
cmp    $0xffffffff,%eax
jne    12d8 <create_tao_process+0x158>
mov    0x2d3b(%rip),%rbx
mov    (%rbx),%edi
lea    0xd76(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%rbx),%ebx
mov    0x2d1a(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xd37(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
add    $0xb0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [46 x i8] c"[auctioneer] Error: Tao process not created.\0A\00"
@stderr = global i32 0
@.str.2 = [5 x i8] c"\09%s\0A\00"
@errno = global i32 0
@.str.3 = [5 x i8] c"fork\00"
@EXIT_FAILURE = global i32 0
@.str.4 = [14 x i8] c"./tao_process\00"
@.str.5 = [3 x i8] c"-t\00"
@.str.6 = [3 x i8] c"-m\00"
@.str.7 = [3 x i8] c"-i\00"
@.str.8 = [86 x i8] c"[Tao process] Error: cannot start tao_process process (Try running main from ./bin).\0A\00"
define void @create_tao_process(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [32 x i8]
%8 = alloca [32 x i8]
%9 = alloca [32 x i8]
%10 = alloca i32
%11 = alloca [1 x i8*]
%12 = alloca [8 x i8*]
%13 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%14 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%15 = load i32, i32* %5
%16 = call i32 @sprintf(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%18 = load i32, i32* %6
%19 = call i32 @sprintf(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%21 = load i32, i32* %4
%22 = call i32 @sprintf(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %21)
%23 = call i32 (...) @fork()
store i32 %23, i32* %10
%24 = load i32, i32* %10
%25 = icmp eq i32 %24, -1
br i1 %25, label %26, label %35
26: ; preds = %3
%27 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0))
%28 = load i32, i32* @stderr
%29 = load i32, i32* @errno
%30 = call i8* @strerror(i32 %29)
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %30)
%32 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%33 = load i32, i32* @EXIT_FAILURE
%34 = call i32 @exit(i32 %33)
unreachable
35: ; preds = %3
%36 = load i32, i32* %10
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %64
38: ; preds = %35
%39 = bitcast [1 x i8*]* %11 to i8*
%40 = getelementptr inbounds [8 x i8*], [8 x i8*]* %12, i64 0, i64 0
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8** %40
%41 = getelementptr inbounds i8*, i8** %40, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8** %41
%42 = getelementptr inbounds i8*, i8** %41, i64 1
%43 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
store i8* %43, i8** %42
%44 = getelementptr inbounds i8*, i8** %42, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8** %44
%45 = getelementptr inbounds i8*, i8** %44, i64 1
%46 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
store i8* %46, i8** %45
%47 = getelementptr inbounds i8*, i8** %45, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8** %47
%48 = getelementptr inbounds i8*, i8** %47, i64 1
%49 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
store i8* %49, i8** %48
%50 = getelementptr inbounds i8*, i8** %48, i64 1
store i8* null, i8** %50
%51 = getelementptr inbounds [8 x i8*], [8 x i8*]* %12, i64 0, i64 0
%52 = getelementptr inbounds [1 x i8*], [1 x i8*]* %11, i64 0, i64 0
%53 = call i32 @execve(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8** %51, i8** %52)
store i32 %53, i32* %13
%54 = load i32, i32* %13
%55 = icmp eq i32 %54, -1
br i1 %55, label %56, label %63
56: ; preds = %38
%57 = load i32, i32* @stderr
%58 = call i32 (i32, i8*, ...) @fprintf(i32 %57, i8* getelementptr inbounds ([86 x i8], [86 x i8]* @.str.8, i64 0, i64 0))
%59 = load i32, i32* @stderr
%60 = load i32, i32* @errno
%61 = call i8* @strerror(i32 %60)
%62 = call i32 (i32, i8*, ...) @fprintf(i32 %59, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %61)
br label %63
63: ; preds = %56, %38
br label %64
64: ; preds = %63, %35
br label %65
65: ; preds = %64
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@stderr = global i32 0
@.str.2 = [5 x i8] c"\09%s\0A\00"
@errno = global i32 0
@.str.3 = [5 x i8] c"fork\00"
@EXIT_FAILURE = global i32 0
@.str.4 = [14 x i8] c"./tao_process\00"
@.str.5 = [3 x i8] c"-t\00"
@.str.6 = [3 x i8] c"-m\00"
@.str.7 = [3 x i8] c"-i\00"
@.str.8 = [86 x i8] c"[Tao process] Error: cannot start tao_process process (Try running main from ./bin).\0A\00"
@str = [45 x i8] c"[auctioneer] Error: Tao process not created.\00"
define void @create_tao_process(i32 %0, i32 %1, i32 %2) {
%4 = alloca [32 x i8]
%5 = alloca [32 x i8]
%6 = alloca [32 x i8]
%7 = alloca [1 x i8*]
%8 = alloca [8 x i8*]
%9 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%10 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%11 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%12 = call i32 @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %1)
%13 = call i32 @sprintf(i8* %10, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %2)
%14 = call i32 @sprintf(i8* %11, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %0)
%15 = tail call i32 (...) @fork()
switch i32 %15, label %48 [
i32 -1, label %16
i32 0, label %25
]
16: ; preds = %3
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str, i64 0, i64 0))
%18 = load i32, i32* @stderr
%19 = load i32, i32* @errno
%20 = tail call i8* @strerror(i32 %19)
%21 = tail call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %20)
%22 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%23 = load i32, i32* @EXIT_FAILURE
%24 = tail call i32 @exit(i32 %23)
unreachable
25: ; preds = %3
%26 = bitcast [1 x i8*]* %7 to i8*
%27 = bitcast [1 x i8*]* %7 to i64*
store i64 0, i64* %27
%28 = bitcast [8 x i8*]* %8 to i8*
%29 = getelementptr inbounds [8 x i8*], [8 x i8*]* %8, i64 0, i64 0
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8** %29
%30 = getelementptr inbounds [8 x i8*], [8 x i8*]* %8, i64 0, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8** %30
%31 = getelementptr inbounds [8 x i8*], [8 x i8*]* %8, i64 0, i64 2
store i8* %9, i8** %31
%32 = getelementptr inbounds [8 x i8*], [8 x i8*]* %8, i64 0, i64 3
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8** %32
%33 = getelementptr inbounds [8 x i8*], [8 x i8*]* %8, i64 0, i64 4
store i8* %10, i8** %33
%34 = getelementptr inbounds [8 x i8*], [8 x i8*]* %8, i64 0, i64 5
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8** %34
%35 = getelementptr inbounds [8 x i8*], [8 x i8*]* %8, i64 0, i64 6
store i8* %11, i8** %35
%36 = getelementptr inbounds [8 x i8*], [8 x i8*]* %8, i64 0, i64 7
store i8* null, i8** %36
%37 = getelementptr inbounds [1 x i8*], [1 x i8*]* %7, i64 0, i64 0
%38 = call i32 @execve(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8** %29, i8** %37)
%39 = icmp eq i32 %38, -1
br i1 %39, label %40, label %47
40: ; preds = %25
%41 = load i32, i32* @stderr
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([86 x i8], [86 x i8]* @.str.8, i64 0, i64 0))
%43 = load i32, i32* @stderr
%44 = load i32, i32* @errno
%45 = call i8* @strerror(i32 %44)
%46 = call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %45)
br label %47
47: ; preds = %40, %25
br label %48
48: ; preds = %3, %47
ret void
}