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

/* Variables and functions */
int /*<<< orphan*/ execlp(char *, char *, char *, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
int fork();
int /*<<< orphan*/ printf(char *);
int wait(int /*<<< orphan*/ *);
int zip(char *path) {
  pid_t pid;
  pid = fork();
  if (pid == -1) {
    printf("Fork error.\n");
    exit(-1);
  } else if (pid == 0) {
    execlp("gzip", "gzip", "-Nr", path, NULL);
  }
  while (wait(NULL) != -1) {
  }
  return (0);
}


x86 assembly (clang, -O0):
<zip>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1070 <fork@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    1186 <zip+0x36>
lea    0xe89(%rip),%rdi
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1040 <exit@plt>
cmpl   $0x0,-0xc(%rbp)
jne    11af <zip+0x5f>
mov    -0x8(%rbp),%rcx
lea    0xe72(%rip),%rsi
lea    0xe70(%rip),%rdx
xor    %eax,%eax
mov    %eax,%r8d
mov    %rsi,%rdi
call   1050 <execlp@plt>
jmp    11b4 <zip+0x64>
jmp    11b9 <zip+0x69>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <wait@plt>
cmp    $0xffffffff,%eax
je     11d0 <zip+0x80>
jmp    11b9 <zip+0x69>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<zip>:
push   %rbx
mov    %rdi,%rbx
xor    %eax,%eax
call   1070 <fork@plt>
test   %eax,%eax
je     117a <zip+0x2a>
cmp    $0xffffffff,%eax
jne    11a0 <zip+0x50>
lea    0xe9e(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%edi
call   1040 <exit@plt>
lea    0xe7f(%rip),%rdi
lea    0xe7d(%rip),%rdx
mov    %rdi,%rsi
mov    %rbx,%rcx
xor    %r8d,%r8d
call   1050 <execlp@plt>
cs nopw 0x0(%rax,%rax,1)
xor    %edi,%edi
call   1060 <wait@plt>
cmp    $0xffffffff,%eax
jne    11a0 <zip+0x50>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [13 x i8] c"Fork error.\0A\00"
@.str.1 = [5 x i8] c"gzip\00"
@.str.2 = [4 x i8] c"-Nr\00"
define i32 @zip(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = call i32 (...) @fork()
store i32 %4, i32* %3
%5 = load i32, i32* %3
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @exit(i32 -1)
unreachable
10: ; preds = %1
%11 = load i32, i32* %3
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = load i8*, i8** %2
%15 = call i32 @execlp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %14, i32* null)
br label %16
16: ; preds = %13, %10
br label %17
17: ; preds = %16
br label %18
18: ; preds = %21, %17
%19 = call i32 @wait(i32* null)
%20 = icmp ne i32 %19, -1
br i1 %20, label %21, label %22
21: ; preds = %18
br label %18
22: ; preds = %18
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [5 x i8] c"gzip\00"
@.str.2 = [4 x i8] c"-Nr\00"
@str = [12 x i8] c"Fork error.\00"
define i32 @zip(i8* %0) {
%2 = tail call i32 (...) @fork()
switch i32 %2, label %8 [
i32 -1, label %3
i32 0, label %6
]
3: ; preds = %1
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 @exit(i32 -1)
unreachable
6: ; preds = %1
%7 = tail call i32 @execlp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %0, i32* null)
br label %8
8: ; preds = %1, %6
br label %9
9: ; preds = %8, %9
%10 = tail call i32 @wait(i32* null)
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %9
12: ; preds = %9
ret i32 0
}