#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 scalar_t__ pid_t;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
scalar_t__ fork();
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sleep(int);
int strtol(char *, int /*<<< orphan*/ *, int);
int main(int argc, char *argv[]) {
  int a;
  pid_t pid;
  if (argc != 2) {
    printf("error en los argumentos");
    exit(-1);
  }
  a = strtol(argv[1], NULL, 10);
  printf("el numero es %d\n", a);
  if ((pid = fork()) < 0) {
    perror("\nError en el fork");
    exit(-1);
  } else if (pid == 0) {
    if (a % 2 == 0)
      printf("Es divisible entre 2\n");
    else
      printf("No es divisible entre 2\n");
  } else {
    sleep(1);
    if (a % 4 == 0)
      printf("Es divisible entre 4\n");
    else
      printf("No es divisible entre 4\n");
  }
  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   $0x2,-0x8(%rbp)
je     1198 <main+0x38>
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1080 <fork@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jge    11ed <main+0x8d>
lea    0xe4b(%rip),%rdi
call   1050 <perror@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
cmpq   $0x0,-0x20(%rbp)
jne    1232 <main+0xd2>
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    121f <main+0xbf>
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122d <main+0xcd>
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1276 <main+0x116>
mov    $0x1,%edi
call   1070 <sleep@plt>
mov    -0x14(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1263 <main+0x103>
lea    0xe13(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1271 <main+0x111>
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1276 <main+0x116>
jmp    127b <main+0x11b>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x2,%edi
jne    11e1 <main+0x71>
mov    0x8(%rsi),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,%ebx
lea    0xe89(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1090 <fork@plt>
test   %rax,%rax
js     11f9 <main+0x89>
je     11c3 <main+0x53>
mov    $0x1,%edi
call   1080 <sleep@plt>
test   $0x3,%bl
lea    0xe99(%rip),%rax
lea    0xe7a(%rip),%rdi
jmp    11d4 <main+0x64>
test   $0x1,%bl
lea    0xeb3(%rip),%rax
lea    0xe94(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret
lea    0xe18(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
lea    0xe29(%rip),%rdi
call   1060 <perror@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [24 x i8] c"error en los argumentos\00"
@.str.1 = [17 x i8] c"el numero es %d\0A\00"
@.str.2 = [18 x i8] c"\0AError en el fork\00"
@.str.3 = [22 x i8] c"Es divisible entre 2\0A\00"
@.str.4 = [25 x i8] c"No es divisible entre 2\0A\00"
@.str.5 = [22 x i8] c"Es divisible entre 4\0A\00"
@.str.6 = [25 x i8] c"No es divisible entre 4\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i64
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, 2
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @exit(i32 -1)
unreachable
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @strtol(i8* %16, i32* null, i32 10)
store i32 %17, i32* %6
%18 = load i32, i32* %6
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = call i64 (...) @fork()
store i64 %20, i64* %7
%21 = icmp slt i64 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %13
%23 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%24 = call i32 @exit(i32 -1)
unreachable
25: ; preds = %13
%26 = load i64, i64* %7
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %37
28: ; preds = %25
%29 = load i32, i32* %6
%30 = srem i32 %29, 2
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
br label %36
34: ; preds = %28
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
br label %36
36: ; preds = %34, %32
br label %47
37: ; preds = %25
%38 = call i32 @sleep(i32 1)
%39 = load i32, i32* %6
%40 = srem i32 %39, 4
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %37
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
br label %46
44: ; preds = %37
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0))
br label %46
46: ; preds = %44, %42
br label %47
47: ; preds = %46, %36
br label %48
48: ; preds = %47
ret i32 0
}

LLVM IR (-O2):
@.str = [24 x i8] c"error en los argumentos\00"
@.str.1 = [17 x i8] c"el numero es %d\0A\00"
@.str.2 = [18 x i8] c"\0AError en el fork\00"
@str = [24 x i8] c"No es divisible entre 4\00"
@str.7 = [21 x i8] c"Es divisible entre 4\00"
@str.8 = [24 x i8] c"No es divisible entre 2\00"
@str.9 = [21 x i8] c"Es divisible entre 2\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @exit(i32 -1)
unreachable
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @strtol(i8* nocapture %9, i32* null, i32 10)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%12 = tail call i64 (...) @fork()
%13 = icmp slt i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %7
%15 = tail call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%16 = tail call i32 @exit(i32 -1)
unreachable
17: ; preds = %7
%18 = icmp eq i64 %12, 0
br i1 %18, label %19, label %23
19: ; preds = %17
%20 = and i32 %10, 1
%21 = icmp eq i32 %20, 0
%22 = select i1 %21, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @str.9, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @str.8, i64 0, i64 0)
br label %28
23: ; preds = %17
%24 = tail call i32 @sleep(i32 1)
%25 = and i32 %10, 3
%26 = icmp eq i32 %25, 0
%27 = select i1 %26, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @str.7, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0)
br label %28
28: ; preds = %23, %19
%29 = phi i8* [ %22, %19 ], [ %27, %23 ]
%30 = tail call i32 @puts(i8* dereferenceable(1) %29)
ret i32 0
}