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

/* Variables and functions */
int /*<<< orphan*/ execve(char *, char **, char **);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fork();
int /*<<< orphan*/ printf(char *);
void call_gcc(char **envp) {
  pid_t pid;
  switch (pid = fork()) {
  case -1:
    printf("Ein kritischer Fehler der Prozessgenerierung ist aufgetreten!\n");
    exit(1);
    break;
  case 0:
    printf("Starte GCC\n");
    char *args[] = {"/usr/bin/gcc", "-o", "/Users/florian/Desktop/test",
                    "/Users/florian/Desktop/test.c", NULL};
    execve("/usr/bin/gcc", args, envp);
    break;
  default:
    printf("Sie befinden sich im Elternprozess\n");
    break;
  }
}


x86 assembly (clang, -O0):
<call_gcc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
xor    %eax,%eax
call   1070 <fork@plt>
mov    %eax,-0xc(%rbp)
mov    %eax,%ecx
mov    %ecx,-0x44(%rbp)
sub    $0xffffffff,%eax
je     1189 <call_gcc+0x39>
jmp    1179 <call_gcc+0x29>
mov    -0x44(%rbp),%eax
test   %eax,%eax
je     119f <call_gcc+0x4f>
jmp    1200 <call_gcc+0xb0>
lea    0xe70(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
lea    0xe99(%rip),%rdi
call   1030 <printf@plt>
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1040 <memset@plt>
lea    0xe89(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xe8b(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    0xe83(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xe94(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    -0x40(%rbp),%rsi
mov    -0x8(%rbp),%rdx
lea    0xe55(%rip),%rdi
call   1050 <execve@plt>
jmp    120c <call_gcc+0xbc>
lea    0xe8e(%rip),%rdi
call   1030 <printf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<call_gcc>:
push   %rbx
sub    $0x30,%rsp
mov    %rdi,%rbx
xor    %eax,%eax
call   1060 <fork@plt>
test   %eax,%eax
je     1169 <call_gcc+0x29>
cmp    $0xffffffff,%eax
je     11be <call_gcc+0x7e>
lea    0xf34(%rip),%rdi
add    $0x30,%rsp
pop    %rbx
jmp    1030 <puts@plt>
lea    0xeda(%rip),%rdi
call   1030 <puts@plt>
movq   $0x0,0x20(%rsp)
lea    0xe7b(%rip),%rdi
mov    %rdi,(%rsp)
lea    0xe7d(%rip),%rax
mov    %rax,0x8(%rsp)
lea    0xe74(%rip),%rax
mov    %rax,0x10(%rsp)
lea    0xe84(%rip),%rax
mov    %rax,0x18(%rsp)
mov    %rsp,%rsi
mov    %rbx,%rdx
call   1040 <execve@plt>
add    $0x30,%rsp
pop    %rbx
ret
lea    0xe90(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [63 x i8] c"Ein kritischer Fehler der Prozessgenerierung ist aufgetreten!\0A\00"
@.str.1 = [12 x i8] c"Starte GCC\0A\00"
@.str.2 = [13 x i8] c"/usr/bin/gcc\00"
@.str.3 = [3 x i8] c"-o\00"
@.str.4 = [28 x i8] c"/Users/florian/Desktop/test\00"
@.str.5 = [30 x i8] c"/Users/florian/Desktop/test.c\00"
@.str.6 = [36 x i8] c"Sie befinden sich im Elternprozess\0A\00"
define void @call_gcc(i8** %0) {
%2 = alloca i8**
%3 = alloca i32
%4 = alloca [5 x i8*]
store i8** %0, i8*** %2
%5 = call i32 (...) @fork()
store i32 %5, i32* %3
switch i32 %5, label %20 [
i32 -1, label %6
i32 0, label %9
]
6: ; preds = %1
%7 = call i32 @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @exit(i32 1)
unreachable
9: ; preds = %1
%10 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%11 = bitcast [5 x i8*]* %4 to i8*
%12 = bitcast i8* %11 to [5 x i8*]*
%13 = getelementptr inbounds [5 x i8*], [5 x i8*]* %12, i32 0, i32 0
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i32 0, i32 0), i8** %13
%14 = getelementptr inbounds [5 x i8*], [5 x i8*]* %12, i32 0, i32 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i32 0, i32 0), i8** %14
%15 = getelementptr inbounds [5 x i8*], [5 x i8*]* %12, i32 0, i32 2
store i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i32 0, i32 0), i8** %15
%16 = getelementptr inbounds [5 x i8*], [5 x i8*]* %12, i32 0, i32 3
store i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i32 0, i32 0), i8** %16
%17 = getelementptr inbounds [5 x i8*], [5 x i8*]* %4, i64 0, i64 0
%18 = load i8**, i8*** %2
%19 = call i32 @execve(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8** %17, i8** %18)
br label %22
20: ; preds = %1
%21 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0))
br label %22
22: ; preds = %20, %9
ret void
}

LLVM IR (-O2):
@.str.2 = [13 x i8] c"/usr/bin/gcc\00"
@.str.3 = [3 x i8] c"-o\00"
@.str.4 = [28 x i8] c"/Users/florian/Desktop/test\00"
@.str.5 = [30 x i8] c"/Users/florian/Desktop/test.c\00"
@str = [11 x i8] c"Starte GCC\00"
@str.7 = [62 x i8] c"Ein kritischer Fehler der Prozessgenerierung ist aufgetreten!\00"
@str.8 = [35 x i8] c"Sie befinden sich im Elternprozess\00"
define void @call_gcc(i8** %0) {
%2 = alloca [5 x i8*]
%3 = tail call i32 (...) @fork()
switch i32 %3, label %16 [
i32 -1, label %4
i32 0, label %7
]
4: ; preds = %1
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @str.7, i64 0, i64 0))
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %1
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
%9 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 4
%10 = bitcast i8** %9 to i64*
store i64 0, i64* %10
%11 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 0
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8** %11
%12 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8** %12
%13 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 2
store i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i8** %13
%14 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 3
store i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i8** %14
%15 = call i32 @execve(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8** %11, i8** %0)
br label %18
16: ; preds = %1
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.8, i64 0, i64 0))
br label %18
18: ; preds = %16, %7
ret void
}