#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 WEXITSTATUS(int);
int /*<<< orphan*/ execlp(char *, char *, char *, char *, char *, char *,
                          int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
int fork();
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ wait(int *);
int main(int argc, char *argv[]) {
  int status;
  char prog[20];
  sprintf(prog, "%s.c", argv[1]);
  int pid = fork();
  if (pid > 0) {
    wait(&status);
    printf("Código de terminação: %i\n", WEXITSTATUS(status));
    exit(WEXITSTATUS(status));
  } else {
    execlp("gcc", "gcc", prog, "-Wall", "-o", argv[1], NULL);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe6e(%rip),%rsi
call   1050 <sprintf@plt>
mov    $0x0,%al
call   1090 <fork@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jle    11d9 <main+0x69>
lea    -0x14(%rbp),%rdi
call   1080 <wait@plt>
mov    -0x14(%rbp),%edi
call   1040 <WEXITSTATUS@plt>
mov    %eax,%esi
lea    0xe40(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
call   1040 <WEXITSTATUS@plt>
mov    %eax,%edi
call   1060 <exit@plt>
lea    -0x30(%rbp),%rdx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%r9
lea    0xe36(%rip),%rsi
lea    0xe33(%rip),%rcx
lea    0xe32(%rip),%r8
xor    %eax,%eax
mov    %rsi,%rdi
movq   $0x0,(%rsp)
call   1070 <execlp@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
mov    %rsi,%rbx
mov    0x8(%rsi),%rdx
lea    0xe7d(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1050 <sprintf@plt>
xor    %eax,%eax
call   1090 <fork@plt>
test   %eax,%eax
jg     11ce <main+0x5e>
mov    0x8(%rbx),%r9
movq   $0x0,(%rsp)
lea    0xe77(%rip),%rdi
lea    0xe74(%rip),%rcx
lea    0xe73(%rip),%r8
lea    0x10(%rsp),%rdx
mov    %rdi,%rsi
call   1070 <execlp@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret
lea    0xc(%rsp),%rdi
call   1080 <wait@plt>
mov    0xc(%rsp),%edi
call   1040 <WEXITSTATUS@plt>
lea    0xe1d(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    0xc(%rsp),%edi
call   1040 <WEXITSTATUS@plt>
mov    %eax,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"%s.c\00"
@.str.1 = [29 x i8] c"C\C3\B3digo de termina\C3\A7\C3\A3o: %i\0A\00"
@.str.2 = [4 x i8] c"gcc\00"
@.str.3 = [6 x i8] c"-Wall\00"
@.str.4 = [3 x i8] c"-o\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca [20 x i8]
%7 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%9 = load i8**, i8*** %4
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = call i32 @sprintf(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = call i32 (...) @fork()
store i32 %13, i32* %7
%14 = load i32, i32* %7
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %24
16: ; preds = %2
%17 = call i32 @wait(i32* %5)
%18 = load i32, i32* %5
%19 = call i32 @WEXITSTATUS(i32 %18)
%20 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = load i32, i32* %5
%22 = call i32 @WEXITSTATUS(i32 %21)
%23 = call i32 @exit(i32 %22)
unreachable
24: ; preds = %2
%25 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%26 = load i8**, i8*** %4
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i32 @execlp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %25, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %28, i32* null)
br label %30
30: ; preds = %24
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%s.c\00"
@.str.1 = [29 x i8] c"C\C3\B3digo de termina\C3\A7\C3\A3o: %i\0A\00"
@.str.2 = [4 x i8] c"gcc\00"
@.str.3 = [6 x i8] c"-Wall\00"
@.str.4 = [3 x i8] c"-o\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca [20 x i8]
%5 = bitcast i32* %3 to i8*
%6 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = tail call i32 (...) @fork()
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %20
12: ; preds = %2
%13 = call i32 @wait(i32* %3)
%14 = load i32, i32* %3
%15 = call i32 @WEXITSTATUS(i32 %14)
%16 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = load i32, i32* %3
%18 = call i32 @WEXITSTATUS(i32 %17)
%19 = call i32 @exit(i32 %18)
unreachable
20: ; preds = %2
%21 = load i8*, i8** %7
%22 = call i32 @execlp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %21, i32* null)
ret i32 0
}